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

MockTest::hello()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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 MockTest extends Test
11
{
12
    public $mocks = [
13
        ['say.hello', ['nick' => 'nekufa'], 'hello'],
14
        ['service.call', ['name' => 'nekufa'], ['value' => 'nekufa!']],
15
        ['service.call', ['name' => 'bazyaba'], ['value' => 'bazyaba!']],
16
        ['service.call', [], ['value' => 'anonymous!']],
17
    ];
18
19
    public function hello($params)
20
    {
21
        return ['text' => 'Hello, '.$params->nick];
22
    }
23
24
    public function testContext()
25
    {
26
        $this->assertSame('Hello, nekufa', $this->dispatch('say.hello', ['nick' => 'nekufa'])->text);
27
    }
28
29
    public function testMocking()
30
    {
31
        foreach ($this->mocks as [$job, $params, $value]) {
32
            if (is_string($value) || is_callable($value)) {
0 ignored issues
show
Bug introduced by
The variable $value 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...
33
                continue;
34
            }
35
            $result = $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...
36
            $this->assertSame(get_object_vars($result), $value);
37
        }
38
39
40
        $this->expectExceptionMessage("Remote calls (remote.call) are disabled for tests");
41
        $this->dispatch('remote.call');
42
    }
43
}
44