Completed
Push — master ( 297f5c...7c9e2e )
by Dmitry
05:43
created

BootstrapTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 40
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test() 0 19 1
A registration() 0 4 1
A subscription() 0 4 1
1
<?php
2
3
namespace Test;
4
5
use Basis\Test;
6
use Basis\Filesystem;
7
8
class BootstrapTest extends Test
9
{
10
    public $mocks = [
11
        ['event.subscribe', [], 'subscription'],
12
        ['web.register', [], 'registration'],
13
    ];
14
15
    public function test()
16
    {
17
        $this->assertCount(0, $this->subscriptions);
18
        $this->assertCount(0, $this->registrations);
19
        $result = $this->dispatch('module.bootstrap');
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
20
21
        // web.register was called
22
        $this->assertCount(1, $this->registrations);
23
24
        // event.subscribe was called
25
        $this->assertCount(1, $this->subscriptions);
26
        $this->assertSame($this->subscriptions[0]->event, 'person.created');
27
        $this->assertSame($this->subscriptions[0]->service, 'test');
28
29
        // cache exists
30
        $cache = getcwd().'/.cache';
31
        $this->assertTrue(is_dir($cache));
32
        rmdir($cache);
33
    }
34
35
36
    private $registrations = [];
37
    public function registration($params)
38
    {
39
        $this->registrations[] = $params;
40
    }
41
42
    private $subscriptions = [];
43
    public function subscription($params)
44
    {
45
        $this->subscriptions[] = $params;
46
    }
47
}
48