| Conditions | 2 |
| Paths | 2 |
| Total Lines | 18 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | protected function handleCommandAndAssertTraced( |
||
| 21 | MessageBus $commandBus, |
||
| 22 | PersistentMessage $command, |
||
| 23 | PersistentCommandRepository $commandRepository |
||
| 24 | ) { |
||
| 25 | $commandBus->handle($command); |
||
| 26 | |||
| 27 | $this->assertInstanceOf(Identity::class, $command->getId()); |
||
|
|
|||
| 28 | |||
| 29 | $foundCommand = $commandRepository->get($command->getId()); |
||
| 30 | $this->assertSame($command, $foundCommand); |
||
| 31 | |||
| 32 | if (!$command instanceof TraceableCommand) { |
||
| 33 | $this->fail(sprintf('The message %s is not Traceable', get_class($command))); |
||
| 34 | } |
||
| 35 | $this->assertInstanceOf(Trace::class, $trace = $command->getTrace()); |
||
| 36 | $this->assertInstanceOf(Context::class, $trace->getContext()); |
||
| 37 | } |
||
| 38 | } |
||
| 39 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.