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 | 5 | protected function setUpEventStore() |
|
74 | |||
75 | /** |
||
76 | * @after |
||
77 | */ |
||
78 | 5 | protected function assertScenario() |
|
91 | |||
92 | abstract protected function aggregateRootClassName(): string; |
||
93 | |||
94 | abstract protected function commandHandler(AggregateRootRepository $repository, Clock $clock): CommandHandler; |
||
95 | |||
96 | 5 | protected function aggregateRootId(): AggregateRootId |
|
100 | |||
101 | /** |
||
102 | * @return $this |
||
103 | */ |
||
104 | 1 | protected function given(Event ... $events) |
|
111 | |||
112 | /** |
||
113 | * @return $this |
||
114 | */ |
||
115 | 5 | protected function when(Command $command) |
|
125 | |||
126 | /** |
||
127 | * @return $this |
||
128 | */ |
||
129 | 2 | protected function then(Event ... $events) |
|
135 | |||
136 | /** |
||
137 | * @return $this |
||
138 | */ |
||
139 | 1 | public function thenWeAreSorry(Exception $expectedException) |
|
145 | |||
146 | /** |
||
147 | * @return $this |
||
148 | */ |
||
149 | 1 | protected function thenNothingShouldHaveHappened() |
|
155 | |||
156 | 5 | protected function assertLastCommitEqualsEvents(Event ... $events) |
|
160 | |||
161 | 5 | private function assertExpectedException(Exception $expectedException = null, Exception $caughtException = null) |
|
176 | |||
177 | 2 | protected function pointInTime(): PointInTime |
|
181 | |||
182 | 5 | protected function messageDispatcher(): MessageDispatcher |
|
186 | |||
187 | 5 | protected function consumers(): array |
|
191 | } |