* @package tao */ class MessagingServiceTest extends TestCase { /** * * @param Transport $transport * @return MessagingService */ protected function getMessagingService($transport) { $messagingService = MessagingService::singleton(); $refObject = new ReflectionObject($messagingService); $refProperty = $refObject->getProperty('transport'); $refProperty->setAccessible(true); $refProperty->setValue($messagingService, $transport); return $messagingService; } public function testSend() { $message = new Message(); $transportProphecy = $this->prophesize('oat\tao\model\messaging\Transport'); $transportProphecy->send($message)->willReturn(true); $transportProphecy->send($message)->should(new CallTimesPrediction(1)); $messagingService = $this->getMessagingService($transportProphecy->reveal()); $result = $messagingService->send($message); $transportProphecy->checkProphecyMethodsPredictions(); $this->assertTrue($result); } public function testIsAvailable() { $transportMock = $this->getMockBuilder('oat\tao\model\messaging\Transport'); $messagingService = $this->getMessagingService($transportMock); $this->assertTrue($messagingService->isAvailable()); } }