public function testMissingRequestReturnNull() { $this->socket->expects($this->once())->method('send')->with(TaskManager::MESSAGE_PROCESS_UPDATE); $this->socket->expects($this->once())->method('recv')->will($this->returnValue(json_encode(['request' => TaskManager::MESSAGE_PROCESS_UPDATE]))); $this->setExpectedException(RuntimeException::class, 'Invalid task manager response : missing fields.'); $this->sut->notify(Notifier::MESSAGE_CREATE); }
/** * @test should accept only REQ sockets */ public function testShouldAcceptOnlyREQSockets() { $this->socket = $this->getMockBuilder('\\ZMQSocket')->disableOriginalConstructor()->getMock(); $this->socket->expects($this->any())->method('getSocketType')->will($this->returnValue(\ZMQ::SOCKET_PUSH)); $this->setExpectedException('\\InvalidArgumentException', 'Invalid socket type'); new ZeroMQClientTransport($this->socket); }
public function testZeroMQExceptionsThrownDuringReceivingRequestShouldBeConvertedToTransportException() { $exception = new \ZMQSocketException('Cannot receive data'); $this->socket->expects($this->once())->method('recvMulti')->will($this->throwException($exception)); $this->setExpectedException('Wookieb\\ZorroRPC\\Exception\\TransportException', 'Unable to receive request'); try { $this->object->receiveRequest(); } catch (TransportException $e) { $this->assertSame($exception, $e->getPrevious()); throw $e; } }