| Conditions | 1 |
| Paths | 1 |
| Total Lines | 40 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | public function testHandle() |
||
| 11 | { |
||
| 12 | $client = $this->getMockBuilder('PamiModule\\Service\\Client') |
||
| 13 | ->disableOriginalConstructor() |
||
| 14 | ->getMock(); |
||
| 15 | |||
| 16 | $pamiEvent = $this->getMockBuilder('PAMI\\Message\\Event\\EventMessage') |
||
| 17 | ->disableOriginalConstructor() |
||
| 18 | ->setMethods(['getName']) |
||
| 19 | ->getMock(); |
||
| 20 | |||
| 21 | $pamiEvent->expects(static::any()) |
||
| 22 | ->method('getName') |
||
| 23 | ->willReturn('Foo'); |
||
| 24 | |||
| 25 | $eventManager = $this->getMockBuilder('Zend\\EventManager\\EventManager') |
||
| 26 | ->setMethods(['triggerEvent']) |
||
| 27 | ->getMock(); |
||
| 28 | |||
| 29 | $eventManager->expects(static::once()) |
||
| 30 | ->method('triggerEvent') |
||
| 31 | ->with(static::callback(function (PamiEvent $e) use ($client, $pamiEvent) { |
||
| 32 | static::assertSame($client, $e->getTarget()); |
||
| 33 | static::assertSame($pamiEvent, $e->getEvent()); |
||
| 34 | static::assertEquals('event.Foo', $e->getName()); |
||
| 35 | |||
| 36 | return true; |
||
| 37 | })); |
||
| 38 | |||
| 39 | $client->expects(static::any()) |
||
| 40 | ->method('getEventManager') |
||
| 41 | ->willReturn($eventManager); |
||
| 42 | |||
| 43 | /* @var \PamiModule\Service\Client $client */ |
||
| 44 | /* @var \PAMI\Message\Event\EventMessage $pamiEvent */ |
||
| 45 | |||
| 46 | $eventForwarder = new EventForwarder($client); |
||
| 47 | |||
| 48 | $eventForwarder->handle($pamiEvent); |
||
| 49 | } |
||
| 50 | } |
||
| 51 |