Completed
Push — master ( ea3156...ec95d0 )
by Dmitry
03:39
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
use Basis\Job\Job\Info;
4
use Basis\Runner;
5
use Job\Hello;
6
7
class RunnerTest extends TestSuite
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
    public function test()
10
    {
11
        $result = $this->app->dispatch('example.hello');
0 ignored issues
show
Bug introduced by
The property app does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
12
        $this->assertSame($result, ['message' => 'hello world!']);
13
14
        $result = $this->app->dispatch('example.hello', ['name' => 'nekufa']);
15
        $this->assertSame($result, ['message' => 'hello nekufa!']);
16
17
        $result = $this->app->dispatch('hello');
18
        $this->assertSame($result, ['message' => 'hello world!']);
19
20
        $result = $this->app->dispatch('hello', ['name' => 'nekufa']);
21
        $this->assertSame($result, ['message' => 'hello nekufa!']);
22
23
        $jobs = $this->app->get(Runner::class)->getMapping();
24
        $this->assertNotNull($jobs);
25
        $this->assertContains('example.hello', array_keys($jobs));
26
        $this->assertSame($jobs['example.hello'], Hello::class);
27
28
        $jobs = $this->app->dispatch('module.meta')['jobs'];
29
        $this->assertNotNull($jobs);
30
        $this->assertCount(1, $jobs);
31
        $this->assertContains('hello', $jobs);
32
    }
33
34
    public function testArgumentCasting()
35
    {
36
        $result = $this->app->dispatch('example.hello', ['nekufa']);
37
        $this->assertSame($result, ['message' => 'hello nekufa!']);
38
39
        $result = $this->app->dispatch('example.hello', ['dmitry', 'krokhin']);
40
        $this->assertSame($result, ['message' => 'hello dmitry krokhin!']);
41
    }
42
}
43