Completed
Push — master ( bff253...2705ab )
by Dmitry
05:49 queued 01:23
created

RunnerTest::test()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 8.9713
c 0
b 0
f 0
cc 1
eloc 17
nc 1
nop 0
1
<?php
2
3
namespace Test;
4
5
use Basis\Job\Job\Info;
6
use Basis\Runner;
7
use Job\Hello;
8
9
class RunnerTest extends TestSuite
10
{
11
    public function test()
12
    {
13
        $result = $this->app->dispatch('example.hello');
14
        $this->assertSame($result, ['message' => 'hello world!']);
15
16
        $result = $this->app->dispatch('example.hello', ['name' => 'nekufa']);
17
        $this->assertSame($result, ['message' => 'hello nekufa!']);
18
19
        $result = $this->app->dispatch('hello');
20
        $this->assertSame($result, ['message' => 'hello world!']);
21
22
        $result = $this->app->dispatch('hello', ['name' => 'nekufa']);
23
        $this->assertSame($result, ['message' => 'hello nekufa!']);
24
25
        $jobs = $this->app->get(Runner::class)->getMapping();
26
        $this->assertNotNull($jobs);
27
        $this->assertContains('example.hello', array_keys($jobs));
28
        $this->assertSame($jobs['example.hello'], Hello::class);
29
30
        $jobs = $this->app->dispatch('module.meta')['jobs'];
31
        $this->assertNotNull($jobs);
32
        $this->assertCount(1, $jobs);
33
        $this->assertContains('hello', $jobs);
34
    }
35
36
    public function testArgumentCasting()
37
    {
38
        $result = $this->app->dispatch('example.hello', ['nekufa']);
39
        $this->assertSame($result, ['message' => 'hello nekufa!']);
40
41
        $result = $this->app->dispatch('example.hello', ['dmitry', 'krokhin']);
42
        $this->assertSame($result, ['message' => 'hello dmitry krokhin!']);
43
    }
44
}
45