Example #1
0
 public function testSendActionStopped()
 {
     $pami = $this->getMockBuilder('PAMI\\Client\\Impl\\ClientImpl')->disableOriginalConstructor()->setMethods([])->getMock();
     $eventManager = $this->getMockBuilder('Zend\\EventManager\\EventManager')->setMethods(['triggerEventUntil'])->getMock();
     $action = $this->getMockBuilder('PAMI\\Message\\OutgoingMessage')->disableOriginalConstructor()->getMock();
     $response = $this->getMockBuilder('PAMI\\Message\\Response\\ResponseMessage')->disableOriginalConstructor()->getMock();
     $eventResults = $this->getMockBuilder('Zend\\EventManager\\ResponseCollection')->disableOriginalConstructor()->setMethods(['stopped', 'last'])->getMock();
     $eventResults->expects(static::once())->method('stopped')->willReturn(true);
     $eventResults->expects(static::once())->method('last')->willReturn($response);
     /* @var \PAMI\Client\Impl\ClientImpl $pami */
     $client = new Client('host', $pami);
     $client->setEventManager($eventManager);
     $eventManager->expects(static::exactly(1))->method('triggerEventUntil')->with(static::callback(function ($callback) use($response) {
         static::assertFalse($callback(null));
         static::assertFalse($callback('string'));
         static::assertFalse($callback([]));
         static::assertTrue($callback($response));
         return true;
     }), static::isInstanceOf(Event::class))->willReturn($eventResults);
     $result = $client->sendAction($action);
     static::assertSame($response, $result);
 }