Completed
Push — master ( 4848aa...64d9da )
by Dmitry
03:44
created

anonymous//test/php/Test/TestingTest.php$0   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 23
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Test;
4
5
use Basis\Filesystem;
6
use Basis\Job;
7
use Tarantool\Mapper\Pool;
8
use Basis\Test;
9
10
class TestingTest extends Test
11
{
12
    public $mocks = [
13
        ['say.hello', ['name' => 'nekufa'], ['text' => 'Hola, nekufa']],
14
        ['say.hello', ['name' => 'vasiliy'], ['text' => 'Vasya, privet!']],
15
        ['web.services', [], ['services' => ['web', 'tester', 'basis']]]
16
    ];
17
18
    public $data = [
19
        'web.services' => [
20
            ['id' => 1, 'name' => 'tester'],
21
            ['id' => 2, 'name' => 'basis'],
22
            ['id' => 3, 'name' => 'web'],
23
        ],
24
        'tester.data' => [
25
            ['id' => 3, 'value' => 'test'],
26
            ['id' => 4, 'value' => 'test'],
27
        ],
28
    ];
29
30
    public function testMagicProperties()
31
    {
32
        foreach ($this->mocks as [$job, $params, $result]) {
33
            $jobResult = get_object_vars($this->dispatch($job, $params));
0 ignored issues
show
Bug introduced by
The variable $job does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $params does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
34
            $this->assertSame($jobResult, $result);
0 ignored issues
show
Bug introduced by
The variable $result does not exist. Did you mean $jobResult?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
35
        }
36
    }
37
38
    public function testPool()
39
    {
40
        $web = $this->get(Pool::class)->get('web');
41
        $services = $web->find('services');
42
        $this->assertCount(3, $services);
43
        $this->assertCount(1, $web->find('services', ['name' => 'web']));
44
45
        $tester = $this->get(Pool::class)->get('tester');
46
        $this->assertCount(0, $tester->find('data', ['id' => 2]));
47
        $this->assertCount(1, $tester->find('data', ['id' => 3]));
48
        $this->assertCount(2, $tester->find('data', ['value' => 'test']));
49
    }
50
}
51