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

RunnerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B test() 0 24 1
A testArgumentCasting() 0 8 1
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