processCall() public méthode

Process call
public processCall ( Session $session, Call $call ) : boolean | Call
$session Session
$call Call
Résultat boolean | Call | Call
 public function testGetCallWithRequestIDAndGetRegistrationById()
 {
     $session = $this->getMockBuilder('\\Thruway\\Session')->disableOriginalConstructor()->getMock();
     $rogueSession = $this->getMockBuilder('\\Thruway\\Session')->disableOriginalConstructor()->getMock();
     $rogueSession->expects($this->exactly(1))->method("sendMessage")->withConsecutive([$this->isInstanceOf('\\Thruway\\Message\\ErrorMessage')]);
     //        $rregMsg = new \Thruway\Message\RegisterMessage(
     //            \Thruway\Common\Utils::getUniqueId(),
     //            ['thruway_multiregister' => true],
     //            'test_procedure'
     //        );
     //
     //        $this->_proc->processRegister($rogueSession, $rregMsg);
     /** @var \Thruway\Message\RegisteredMessage $registeredMsg */
     $registeredMsg = null;
     /** @var \Thruway\Message\InvocationMessage $invocationMsg */
     $invocationMsg = null;
     $session->expects($this->exactly(4))->method("sendMessage")->withConsecutive([$this->callback(function ($msg) use(&$registeredMsg) {
         // registered call
         $this->assertInstanceOf('\\Thruway\\Message\\RegisteredMessage', $msg);
         $registeredMsg = $msg;
         return true;
     })], [$this->callback(function ($msg) use(&$invocationMsg) {
         $this->assertInstanceOf('\\Thruway\\Message\\InvocationMessage', $msg);
         $invocationMsg = $msg;
         return true;
     })], [$this->callback(function ($msg) {
         $this->assertInstanceOf('\\Thruway\\Message\\ErrorMessage', $msg);
         $this->assertEquals('wamp.error.no_such_registration', $msg->getErrorUri());
         return true;
     })], [$this->isInstanceOf('\\Thruway\\Message\\UnregisteredMessage')]);
     $registerMsg = new \Thruway\Message\RegisterMessage(\Thruway\Common\Utils::getUniqueId(), [], 'test_procedure');
     $this->_proc->processRegister($session, $registerMsg);
     $this->assertInstanceOf('\\Thruway\\Message\\RegisteredMessage', $registeredMsg);
     $callMsg = new \Thruway\Message\CallMessage(\Thruway\Common\Utils::getUniqueId(), [], "test_procedure");
     $call = new \Thruway\Call($session, $callMsg, $this->_proc);
     $this->_proc->processCall($session, $call);
     $this->assertInstanceOf('\\Thruway\\Message\\InvocationMessage', $invocationMsg);
     $call = $this->_proc->getCallByRequestId($invocationMsg->getRequestId());
     $this->assertInstanceOf('\\Thruway\\Call', $call);
     $this->assertSame($session, $call->getCalleeSession());
     $registration = $this->_proc->getRegistrationById($registeredMsg->getRegistrationId());
     $this->assertInstanceOf('\\Thruway\\Registration', $registration);
     $this->assertEquals($registeredMsg->getRegistrationId(), $registration->getId());
     $unregisterMsg = new \Thruway\Message\UnregisterMessage(\Thruway\Common\Utils::getUniqueId(), $registration->getId());
     $this->assertEquals(1, count($this->_proc->getRegistrations()));
     // this does not get called on a mock
     $this->_proc->processUnregister($rogueSession, $unregisterMsg);
     $this->assertEquals(1, count($this->_proc->getRegistrations()));
     // try unregistering a non-existent registration
     $badUnregisterMsg = new \Thruway\Message\UnregisterMessage(\Thruway\Common\Utils::getUniqueId(), 0);
     $this->_proc->processUnregister($session, $badUnregisterMsg);
     $this->assertEquals(1, count($this->_proc->getRegistrations()));
     $this->_proc->processUnregister($session, $unregisterMsg);
     $this->assertEquals(0, count($this->_proc->getRegistrations()));
 }