Conditions | 3 |
Paths | 1 |
Total Lines | 30 |
Code Lines | 19 |
Lines | 10 |
Ratio | 33.33 % |
Changes | 0 |
1 | <?php |
||
13 | public function testDispatchingEventFromConsoleCommandTriggersPushEvent() |
||
14 | { |
||
15 | $pushServerMock = $this->getMockForAbstractClass(PushServerInterface::class); |
||
16 | |||
17 | $app = new App\AppRestApi([ |
||
18 | 'debug' => true, |
||
19 | 'sandstone.push' => function () use ($pushServerMock) { |
||
20 | return $pushServerMock; |
||
21 | }, |
||
22 | ]); |
||
23 | |||
24 | $pushServerMock |
||
25 | ->expects($this->once()) |
||
26 | ->method('send') |
||
27 | View Code Duplication | ->with($this->callback(function ($message) { |
|
|
|||
28 | $decodedMessage = unserialize($message); |
||
29 | $serializedEvent = '{"propagation_stopped":false,"id":42,"title":"Unicorns spotted in Alaska","url":"http:\/\/unicorn.com\/articles\/unicorns-spotted-alaska"}'; |
||
30 | |||
31 | return |
||
32 | ArticleCreatedEvent::ARTICLE_CREATED_EVENT === $decodedMessage['name'] && |
||
33 | ArticleCreatedEvent::class === $decodedMessage['class'] && |
||
34 | $serializedEvent === $decodedMessage['event'] |
||
35 | ; |
||
36 | })) |
||
37 | ; |
||
38 | |||
39 | $console = new App\Console($app); |
||
40 | $input = new ArrayInput(['sandstone:test:push']); |
||
41 | $console->find('sandstone:test:push')->run($input, new NullOutput()); |
||
42 | } |
||
43 | } |
||
44 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.