1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace EventSauce\EventSourcing\TestUtilities; |
||
6 | |||
7 | use EventSauce\EventSourcing\Consumer; |
||
8 | use EventSauce\EventSourcing\Message; |
||
9 | use EventSauce\EventSourcing\Serialization\ConstructingMessageSerializer; |
||
10 | use EventSauce\EventSourcing\Serialization\MessageSerializer; |
||
11 | use function iterator_to_array; |
||
12 | use PHPUnit\Framework\TestCase; |
||
13 | |||
14 | class ConsumerThatSerializesMessages implements Consumer |
||
15 | { |
||
16 | /** |
||
17 | * @var MessageSerializer |
||
18 | */ |
||
19 | private $serializer; |
||
20 | |||
21 | 10 | public function __construct(MessageSerializer $serializer = null) |
|
22 | { |
||
23 | 10 | $this->serializer = $serializer ?: new ConstructingMessageSerializer(); |
|
24 | 10 | } |
|
25 | |||
26 | 4 | public function handle(Message $message) |
|
27 | { |
||
28 | 4 | $payload = $this->serializer->serializeMessage($message); |
|
29 | 4 | $deserializedMessage = iterator_to_array($this->serializer->unserializePayload($payload))[0] ?? null; |
|
30 | 4 | TestCase::assertEquals($message->event(), $deserializedMessage->event()); |
|
0 ignored issues
–
show
|
|||
31 | 4 | } |
|
32 | } |
||
33 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.