|
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)); |
|
|
|
|
|
|
34
|
|
|
$this->assertSame($jobResult, $result); |
|
|
|
|
|
|
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
|
|
|
|
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.