Skip to content

Commit 45ad19f

Browse files
committed
Revert "(chore): improves testing"
This reverts commit 3058bc5.
1 parent 17a491a commit 45ad19f

File tree

14 files changed

+52
-98
lines changed

14 files changed

+52
-98
lines changed

Diff for: Core/Analytics/Metrics/Active.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function increment()
5454
{
5555
$cacher = Core\Data\cache\factory::build('apcu');
5656
if ($cacher->get("{$this->namespace}active:$p:$ts:$this->key") == true) {
57-
return;
57+
continue;
5858
}
5959
$this->db->insert("{$this->namespace}active:$p:$ts", array($this->key => time()));
6060
$cacher->set("{$this->namespace}active:$p:$ts:$this->key", time());

Diff for: Core/Sandbox.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
namespace Minds\Core;
33

44
use Minds\Core\Di\Di;
5-
use Minds\Entities\User;
5+
use Minds\Entities;
66

77
class Sandbox
88
{
@@ -22,6 +22,6 @@ public static function user($default, $sandbox = 'default')
2222
error_log(json_encode($config));
2323

2424
error_log(':: [Sandbox] Sandboxing user ' . $guid);
25-
return new User($guid);
25+
return new Entities\User($guid);
2626
}
2727
}

Diff for: Core/Security/ACL.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Minds\Core\Security;
66

77
use Minds\Core;
8-
use Minds\Core\Di\Di;
98

109
class ACL
1110
{
@@ -21,7 +20,7 @@ public function __construct()
2120
*/
2221
private function init()
2322
{
24-
Di::_()->get('Security\ACL\Block')->listen();
23+
ACL\Block::_()->listen();
2524
}
2625

2726
public function setIgnore($ignore = false)

Diff for: Core/Security/ACL/Block.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ class Block
1414
private static $_;
1515
private $db;
1616
private $cacher;
17-
private $cqlType;
1817

19-
public function __construct($db = null, $cql = null, $cacher = null, $cqlTypes = null)
18+
public function __construct($db = null, $cql = null, $cacher = null)
2019
{
2120
$this->db = $db ?: Di::_()->get('Database\Cassandra\Indexes');
2221
$this->cql = $cql ?: Di::_()->get('Database\Cassandra\Cql');
2322
$this->cacher = $cacher ?: Core\Data\cache\factory::build();
24-
$this->cqlTypes = $cqlTypes ?: new \Cassandra\Type;
2523
}
2624

2725
public function setDb($db)
@@ -94,7 +92,7 @@ public function isBlocked($users, $from = null)
9492
}
9593

9694
$prepared = new Cassandra\Prepared\Custom();
97-
$collection = $this->cqlTypes::collection($this->cqlTypes::text())
95+
$collection = \Cassandra\Type::collection(\Cassandra\Type::text())
9896
->create(... $user_guids);
9997
$prepared->query("SELECT * from entities_by_time WHERE key= ? AND column1 IN ? LIMIT ?",
10098
[ "acl:blocked:$from", $collection, 1000 ]);

Diff for: Jenkinsfile

+10-31
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,12 @@
1-
pipeline {
2-
agent any
3-
4-
stages {
5-
stage('Checkout'){
6-
steps {
7-
checkout scm
8-
//Get dependencies
9-
sh '/var/www/composer.phar install'
10-
}
11-
}
12-
13-
stage('Test'){
14-
steps {
15-
sh 'bin/phpspec run'
16-
}
17-
}
18-
19-
stage('Deploy'){
20-
when {
21-
expression {
22-
GIT_BRANCH = 'origin/' + sh(returnStdout: true, script: 'git rev-parse --abbrev-ref HEAD').trim()
23-
return GIT_BRANCH == 'origin/master'
24-
}
25-
}
26-
steps {
27-
input "Deploy?"
28-
echo "Depoying to production";
29-
}
30-
}
31-
}
1+
node {
2+
3+
stage 'Checkout'
4+
checkout scm
5+
//Get dependencies
6+
sh '/var/www/composer.phar install'
7+
8+
stage 'Test'
9+
10+
sh 'bin/phpspec run'
3211

3312
}

Diff for: Spec/Core/Analytics/Metrics/RetentionSpec.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ function it_should_increment_the_metric(Call $db)
2323
$timestamps = Timestamps::span(30, 'day');
2424

2525
//mock the calls that are expected
26-
$db->getRow(Argument::containingString(':signup'), Argument::type('array'))->willReturn(['foo'=>time(), 'bar'=>time(), 'foobar'=>time()]);
27-
$db->getRow(Argument::containingString(':signup'), Argument::type('array'))->willReturn([]); //return empty for offset
28-
$db->getRow(Argument::containingString(':active'), Argument::type('array'))->willReturn(['foo'=>time(), 'bar'=>time(), 'barfoo'=>time()]);
29-
$db->getRow(Argument::containingString(':active'), Argument::type('array'))->willReturn([]);
26+
$db->getRow(Argument::containingString(':signup'), ['limit'=>10000])->willReturn(['foo'=>time(), 'bar'=>time(), 'foobar'=>time()]);
27+
$db->getRow(Argument::containingString(':active'), ['limit'=>10000])->willReturn(['foo'=>time(), 'bar'=>time(), 'barfoo'=>time()]);
3028

3129
$now = Timestamps::span(2, 'day')[0];
3230
foreach([1,3,7,28] as $x){

Diff for: Spec/Core/Monetization/AdsSpec.php

+6-15
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,20 @@ function it_should_get_revenue_list_from_service_and_format_it(
5555
[ 'url' => '/blog/view/1', 'title' => 'Blog 1', 'views' => 100, 'revenue' => 1.50 ],
5656
[ 'url' => '/blog/view/2', 'title' => 'Blog 2', 'views' => 50, 'revenue' => 1.00 ],
5757
], '']);
58-
$service->getTotalRevenueAndViews(10, new \DateTime('2017-01-01'), new \DateTime('2017-02-01'))
59-
->shouldBeCalled()
60-
->willReturn([100, 10]);
61-
58+
6259
$payouts->calcUserAmount(Argument::cetera())->will(function ($args, $payouts) {
6360
return $args[0] * 0.5;
6461
});
6562

66-
$rpm = ((10*0.5) / 100) * 1000; //this is really messy
67-
6863
$this->setUser(10);
69-
$this->getList(new \DateTime('2017-01-01'), new \DateTime('2017-02-01'))->shouldReturn([
64+
$this->getList(new \DateTime('2017-01-01'), new \DateTime('2017-02-01'), '', 50)->shouldReturn([
7065
[
7166
'entity' => [ 'guid' => '1', 'title' => 'Blog 1' ],
72-
'views' => 100, 'revenue' => (100/1000) * $rpm, 'rpm' => $rpm
67+
'views' => 100, 'revenue' => 0.75, 'rpm' => 7.5,
7368
],
7469
[
7570
'entity' => [ 'guid' => '2', 'title' => 'Blog 2' ],
76-
'views' => 50, 'revenue' => (50/1000) * $rpm, 'rpm' => $rpm
71+
'views' => 50, 'revenue' => 0.50, 'rpm' => 10.0,
7772
],
7873
]);
7974
}
@@ -91,14 +86,10 @@ function it_should_get_the_last_offset(
9186
$service->getRevenuePerPage(10, new \DateTime('2017-01-01'), new \DateTime('2017-02-01'), '', 50)
9287
->shouldBeCalled()
9388
->willReturn([[], '2']);
94-
95-
$service->getTotalRevenueAndViews(10, new \DateTime('2017-01-01'), new \DateTime('2017-02-01'))
96-
->shouldBeCalled()
97-
->willReturn([1000, 20.23]);
98-
89+
9990
$this->setUser(10);
10091
$this->getList(new \DateTime('2017-01-01'), new \DateTime('2017-02-01'), '', 50);
101-
92+
10293
$this->getLastOffset()->shouldReturn('2');
10394
}
10495
}

Diff for: Spec/Core/Navigation/ManagerSpec.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ public function it_should_add_an_item_to_a_container(Item $item)
2121
public function it_should_export_items_for_a_container(Item $item)
2222
{
2323
$this::add($item, "phpspec");
24-
//$this::export("phpspec")->shouldHaveKey("phpspec");
24+
$this::export("phpspec")->shouldHaveKey("phpspec");
2525
}
2626
}

Diff for: Spec/Core/Provisioner/InstallerSpec.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ function let(Minds $minds) {
3737
$CONFIG->site_name = 'PHPSpec Minds';
3838
}
3939

40-
//function it_should_check_options_valid()
41-
//{
42-
//$this
43-
// ->shouldNotThrow('Minds\\Exceptions\\ProvisionException')
44-
// ->duringCheckOptions();
45-
//}
40+
function it_should_check_options_valid()
41+
{
42+
$this
43+
->shouldNotThrow('Minds\\Exceptions\\ProvisionException')
44+
->duringCheckOptions();
45+
}
4646

4747
function it_should_check_options_invalid_domain()
4848
{
@@ -79,7 +79,7 @@ function it_should_check_options_invalid_username()
7979
$this
8080
->shouldThrow('Minds\\Exceptions\\ProvisionException')
8181
->duringCheckOptions();
82-
82+
8383
$this->setOptions([
8484
'domain' => 'phpspec.minds.io',
8585
'username' => 'foo.bar$',

Diff for: Spec/Core/Search/DocumentsSpec.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function it_should_format_a_user_document()
4242
'Harding Edward Mark'
4343
],
4444
'output' => "@mark",
45-
'weight' => 2,
45+
'weight' => 1,
4646
'payload' => [
4747
'guid' => 'abc',
4848
'name' => 'MarkEdward Harding',

Diff for: Spec/Core/Security/ACL/BlockSpec.php

+16-25
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,48 @@
55
use PhpSpec\ObjectBehavior;
66
use Prophecy\Argument;
77
use Prophecy\Prophet;
8-
use Mockery;
9-
use Minds\Core\Data\Cassandra\Thrift\Indexes as Call;
8+
use Minds\Core\Data\Call as Call;
109
use Minds\Core\Data\Call as DataPool;
11-
use Minds\Core\Data\Cassandra\Client as Cql;
1210
use Minds\Entities\Entity;
1311

1412
class BlockSpec extends ObjectBehavior
1513
{
16-
public function it_is_initializable(Call $db, Cql $cql)
14+
public function it_is_initializable()
1715
{
18-
$this->beConstructedWith($db, $cql, null, Argument::any());
1916
$this->shouldHaveType('Minds\Core\Security\ACL\Block');
2017
}
2118

2219
//function it_should_listen_to_interact_acl_event(Entity $entity){
2320
//$this->
2421
//}
2522

26-
public function it_should_return_if_blocked(Call $db, Cql $cql)
23+
public function it_should_return_if_blocked(Call $db)
2724
{
28-
$cqlTypes = Mockery::mock('alias:Cassandra\Types');
29-
$cqlTypes->shouldReceive('collection')->andReturn($cqlTypes);
30-
$cqlTypes->shouldReceive('text')->andReturn();
31-
$cqlTypes->shouldReceive('collection->create')->andReturn([]);
32-
33-
$cql->request(Argument::type('\Minds\Core\Data\Cassandra\Prepared\Custom'))->willReturn([
34-
[
35-
'key' => 'foo',
36-
'column1' => 'bar',
37-
'value' => time()
38-
]
39-
]);
40-
41-
$this->beConstructedWith($db, $cql, null, $cqlTypes);
25+
$db->beConstructedWith(['entities_by_time']);
26+
$db->getRow("acl:blocked:foo", Argument::any())->willReturn(array(
27+
"bar" => time()
28+
));
29+
30+
$this->beConstructedWith($db);
4231
$this->isBlocked("bar", "foo")->shouldReturn(true);
4332
$this->isBlocked("boo", "foo")->shouldReturn(false);
4433
}
4534

46-
public function it_should_add_a_user_to_the_list(Call $db, Cql $cql)
35+
public function it_should_add_a_user_to_the_list(Call $db)
4736
{
37+
$db->beConstructedWith(['entities_by_time']);
4838
$db->insert("acl:blocked:foo", Argument::type('array'))->willReturn("bar");
4939

50-
$this->beConstructedWith($db, $cql, null, Argument::any());
40+
$this->beConstructedWith($db);
5141
$this->block("bar", "foo")->shouldReturn("bar");
5242
}
5343

54-
public function it_should_remove_a_user_from_the_list(Call $db, Cql $cql)
44+
public function it_should_remove_a_user_from_the_list(Call $db)
5545
{
56-
$db->remove("acl:blocked:foo", array("bar"))->willReturn(true);
46+
$db->beConstructedWith(['entities_by_time']);
47+
$db->removeAttributes("acl:blocked:foo", array("bar"))->willReturn(true);
5748

58-
$this->beConstructedWith($db, $cql, null, Argument::any());
49+
$this->beConstructedWith($db);
5950
$this->unBlock("bar", "foo")->shouldReturn(true);
6051
}
6152
}

Diff for: Spec/Entities/Boost/NetworkSpec.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ public function let()
3232
'transactionId' => null,
3333
'handler' => 'newsfeed',
3434
'time_created' => time(),
35-
'last_updated' => time(),
36-
'rating' => 0
35+
'last_updated' => time()
3736
];
3837
}
3938

Diff for: Spec/Entities/PageSpec.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function it_should_load_from_json()
6262

6363
public function it_should_should_save(Call $db)
6464
{
65-
$db->insert(Argument::type('string'), Argument::any(), null)->willReturn($this->getGuid());
65+
$db->insert(Argument::type('string'), Argument::any())->willReturn($this->getGuid());
6666
$this->save()->shouldReturn($this);
6767
}
6868

Diff for: composer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
"phpspec/phpspec": "~2.0",
5252
"fabpot/php-cs-fixer": "dev-master",
5353
"bossa/phpspec2-expect": "*",
54-
"apigen/apigen": "4.1.1",
55-
"mockery/mockery": "dev-master"
54+
"apigen/apigen": "4.1.1"
5655
}
5756
}

0 commit comments

Comments
 (0)