示例#1
0
 /** @test */
 public function disconnectThenConnectShouldReturnNewPromise()
 {
     $input = $this->createInputStreamMock();
     $connectFrame = new Frame('CONNECT', array('accept-version' => '1.1', 'host' => 'localhost'));
     $output = $this->getMock('React\\Stomp\\Io\\OutputStreamInterface');
     $output->expects($this->at(0))->method('sendFrame')->with($this->frameIsEqual($connectFrame));
     $output->expects($this->at(2))->method('sendFrame')->with($this->frameIsEqual($connectFrame));
     $client = new Client($input, $output, array('vhost' => 'localhost'));
     $promise1 = $client->connect();
     $client->disconnect();
     $promise2 = $client->connect();
     $this->assertInstanceOf('React\\Promise\\PromiseInterface', $promise1);
     $this->assertInstanceOf('React\\Promise\\PromiseInterface', $promise2);
     $this->assertNotSame($promise1, $promise2);
 }
示例#2
0
 /** @test */
 public function itShouldNotBeConnectedAfterDisconnection()
 {
     $input = $this->createInputStreamMock();
     $output = $this->getMock('React\\Stomp\\Io\\OutputStreamInterface');
     $client = new Client($this->createLoopMockWithConnectionTimer(), $input, $output, array('vhost' => 'localhost'));
     $client->connect();
     $frame = new Frame('CONNECTED', array('session' => '1234', 'server' => 'React/alpha'));
     $input->emit('frame', array($frame));
     $client->disconnect();
     $this->assertFalse($client->isConnected());
 }