1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Test; |
4
|
|
|
|
5
|
|
|
use Basis\Context; |
6
|
|
|
use Basis\Executor; |
7
|
|
|
use Basis\Test; |
8
|
|
|
|
9
|
|
|
class ExecutorTest extends Test |
10
|
|
|
{ |
11
|
|
|
public function testDispatcherProcessingTrigger() |
12
|
|
|
{ |
13
|
|
|
$note = $this->create('note', []); |
14
|
|
|
$result = $this->get(Executor::class)->dispatch('actor', ['note' => $note->id]); |
15
|
|
|
$this->assertNotNull($result); |
16
|
|
|
} |
17
|
|
|
public function testContext() |
18
|
|
|
{ |
19
|
|
|
$note = $this->create('note', []); |
20
|
|
|
$this->send('actor', ['note' => $note->id]); |
21
|
|
|
$this->get(Executor::class)->process(); |
22
|
|
|
$this->assertSame($note->message, ''); |
23
|
|
|
|
24
|
|
|
$this->actAs(1); |
25
|
|
|
$this->send('actor', ['note' => $note->id]); |
26
|
|
|
|
27
|
|
|
$this->actAs(2); |
28
|
|
|
$this->get(Executor::class)->process(); |
29
|
|
|
|
30
|
|
|
$this->assertSame($note->message, '1'); |
31
|
|
|
$this->assertSame($this->get(Context::class)->getPerson(), 2); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function testBasics() |
35
|
|
|
{ |
36
|
|
|
$note = $this->create('note', ['message' => 5]); |
37
|
|
|
$this->actAs(1); |
38
|
|
|
$this->send('increment', ['note' => $note->id]); |
39
|
|
|
$this->assertEquals($note->message, 5); |
40
|
|
|
|
41
|
|
|
$this->assertCount(1, $this->find('job_queue')); |
|
|
|
|
42
|
|
|
$request = $this->findOne('job_queue'); |
|
|
|
|
43
|
|
|
|
44
|
|
|
$this->get(Executor::class)->process(); |
45
|
|
|
|
46
|
|
|
$this->assertCount(0, $this->find('job_queue')); |
|
|
|
|
47
|
|
|
$this->assertCount(0, $this->find('job_result')); |
|
|
|
|
48
|
|
|
$this->assertEquals($note->message, 6); |
49
|
|
|
|
50
|
|
|
$request = $this->get(Executor::class)->request([ |
51
|
|
|
'job' => 'increment', |
52
|
|
|
'recipient' => 'test', |
53
|
|
|
'params' => [ |
54
|
|
|
'note' => $note->id, |
55
|
|
|
], |
56
|
|
|
]); |
57
|
|
|
|
58
|
|
|
$this->assertEquals($request->recipient, 'test'); |
59
|
|
|
$this->assertCount(1, $this->find('job_queue')); |
|
|
|
|
60
|
|
|
$this->assertCount(0, $this->find('job_result')); |
|
|
|
|
61
|
|
|
|
62
|
|
|
$this->get(Executor::class)->process(); |
63
|
|
|
$this->assertCount(0, $this->find('job_queue')); |
|
|
|
|
64
|
|
|
$this->assertCount(1, $this->find('job_result')); |
|
|
|
|
65
|
|
|
|
66
|
|
|
$result = $this->get(Executor::class)->result($request->hash); |
67
|
|
|
$this->assertEquals($result->note->message, 7); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: