1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Basis\Job\Job\Info; |
4
|
|
|
use Basis\Runner; |
5
|
|
|
use Job\Hello; |
6
|
|
|
|
7
|
|
|
class RunnerTest extends TestSuite |
|
|
|
|
8
|
|
|
{ |
9
|
|
|
public function test() |
10
|
|
|
{ |
11
|
|
|
$result = $this->app->dispatch('example.hello'); |
|
|
|
|
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
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.