1 | <?php |
||
20 | abstract class AggregateRootTestCase extends TestCase |
||
21 | { |
||
22 | /** |
||
23 | * @var InMemoryMessageRepository |
||
24 | */ |
||
25 | protected $messageRepository; |
||
26 | |||
27 | /** |
||
28 | * @var AggregateRootRepository |
||
29 | */ |
||
30 | protected $repository; |
||
31 | |||
32 | /** |
||
33 | * @var Exception|null |
||
34 | */ |
||
35 | private $caughtException; |
||
36 | |||
37 | /** |
||
38 | * @var Event[] |
||
39 | */ |
||
40 | private $expectedEvents = []; |
||
41 | |||
42 | /** |
||
43 | * @var Exception|null |
||
44 | */ |
||
45 | private $theExpectedException; |
||
46 | |||
47 | /** |
||
48 | * @var TestClock |
||
49 | */ |
||
50 | private $clock; |
||
51 | |||
52 | /** |
||
53 | * @var bool |
||
54 | */ |
||
55 | private $assertedScenario = false; |
||
56 | |||
57 | /** |
||
58 | * @var AggregateRootId |
||
59 | */ |
||
60 | protected $aggregateRootId; |
||
61 | |||
62 | /** |
||
63 | * @before |
||
64 | */ |
||
65 | 10 | protected function setUpEventSauce() |
|
84 | |||
85 | /** |
||
86 | * @after |
||
87 | */ |
||
88 | 10 | protected function assertScenario() |
|
106 | |||
107 | 9 | protected function aggregateRootId(): AggregateRootId |
|
111 | |||
112 | abstract protected function newAggregateRootId(): AggregateRootId; |
||
113 | |||
114 | abstract protected function aggregateRootClassName(): string; |
||
115 | |||
116 | /** |
||
117 | * @return $this |
||
118 | */ |
||
119 | 2 | protected function given(Event ...$events) |
|
126 | |||
127 | 1 | public function on(AggregateRootId $id) |
|
131 | |||
132 | /** |
||
133 | * @return $this |
||
134 | */ |
||
135 | 9 | protected function when(...$arguments) |
|
149 | |||
150 | /** |
||
151 | * @return $this |
||
152 | */ |
||
153 | 4 | protected function then(Event ...$events) |
|
159 | |||
160 | /** |
||
161 | * @return $this |
||
162 | */ |
||
163 | 2 | public function expectToFail(Exception $expectedException) |
|
169 | |||
170 | /** |
||
171 | * @return $this |
||
172 | */ |
||
173 | 1 | protected function thenNothingShouldHaveHappened() |
|
179 | |||
180 | 7 | protected function assertLastCommitEqualsEvents(Event ...$events) |
|
184 | |||
185 | 10 | private function assertExpectedException(Exception $expectedException = null, Exception $caughtException = null) |
|
197 | |||
198 | 1 | protected function pointInTime(): PointInTime |
|
202 | |||
203 | 8 | protected function clock(): Clock |
|
207 | |||
208 | 10 | protected function messageDispatcher(): MessageDispatcher |
|
215 | |||
216 | /** |
||
217 | * @return Consumer[] |
||
218 | */ |
||
219 | 10 | protected function consumers(): array |
|
223 | |||
224 | 10 | private function messageDecorator(): MessageDecorator |
|
228 | } |
||
229 |