1 | <?php |
||
11 | abstract class AggregateRootTestCase extends TestCase |
||
12 | { |
||
13 | /** |
||
14 | * @var InMemoryMessageRepository |
||
15 | */ |
||
16 | private $messageRepository; |
||
17 | |||
18 | /** |
||
19 | * @var AggregateRootRepository |
||
20 | */ |
||
21 | private $repository; |
||
22 | |||
23 | /** |
||
24 | * @var CommandHandler |
||
25 | */ |
||
26 | private $commandHandler; |
||
27 | |||
28 | /** |
||
29 | * @var Exception|null |
||
30 | */ |
||
31 | private $caughtException; |
||
32 | |||
33 | /** |
||
34 | * @var Event[] |
||
35 | */ |
||
36 | private $expectedEvents = []; |
||
37 | |||
38 | /** |
||
39 | * @var Exception|null |
||
40 | */ |
||
41 | private $theExpectedException; |
||
42 | |||
43 | /** |
||
44 | * @var TestClock |
||
45 | */ |
||
46 | private $clock; |
||
47 | |||
48 | /** |
||
49 | * @var bool |
||
50 | */ |
||
51 | private $assertedScenario = false; |
||
52 | |||
53 | /** |
||
54 | * @var AggregateRootId |
||
55 | */ |
||
56 | private $aggregateRootId; |
||
57 | |||
58 | /** |
||
59 | * @before |
||
60 | */ |
||
61 | 6 | protected function setUpEventStore() |
|
74 | |||
75 | /** |
||
76 | * @after |
||
77 | */ |
||
78 | 6 | protected function assertScenario() |
|
96 | |||
97 | abstract protected function aggregateRootClassName(): string; |
||
98 | |||
99 | abstract protected function commandHandler(AggregateRootRepository $repository, Clock $clock): CommandHandler; |
||
100 | |||
101 | 6 | protected function aggregateRootId(): AggregateRootId |
|
105 | |||
106 | /** |
||
107 | * @return $this |
||
108 | */ |
||
109 | 1 | protected function given(Event ... $events) |
|
116 | |||
117 | /** |
||
118 | * @return $this |
||
119 | */ |
||
120 | 6 | protected function when(Command $command) |
|
130 | |||
131 | /** |
||
132 | * @return $this |
||
133 | */ |
||
134 | 2 | protected function then(Event ... $events) |
|
140 | |||
141 | /** |
||
142 | * @return $this |
||
143 | */ |
||
144 | 2 | public function thenWeAreSorry(Exception $expectedException) |
|
150 | |||
151 | /** |
||
152 | * @return $this |
||
153 | */ |
||
154 | 1 | protected function thenNothingShouldHaveHappened() |
|
160 | |||
161 | 4 | protected function assertLastCommitEqualsEvents(Event ... $events) |
|
165 | |||
166 | 6 | private function assertExpectedException(Exception $expectedException = null, Exception $caughtException = null) |
|
178 | |||
179 | 2 | protected function pointInTime(): PointInTime |
|
183 | |||
184 | 6 | protected function messageDispatcher(): MessageDispatcher |
|
188 | |||
189 | /** |
||
190 | * @return Consumer[] |
||
191 | */ |
||
192 | 6 | protected function consumers(): array |
|
196 | } |