示例#1
0
 /**
  * @dataProvider generateSet
  */
 public function testPing(Ping $ping)
 {
     $this->assertInternalType('string', $ping->getNonce());
     $this->assertEquals('ping', $ping->getNetworkCommand());
     $math = new Math();
     $this->assertEquals(str_pad($math->decHex($ping->getNonce()), 16, '0', STR_PAD_LEFT), $ping->getHex());
 }
示例#2
0
 /**
  * @dataProvider generateSet
  */
 public function testPong(Ping $ping)
 {
     $pong = new Pong($ping->getNonce());
     $this->assertEquals('pong', $pong->getNetworkCommand());
     $this->assertTrue($ping->getNonce() == $pong->getNonce());
     $math = new Math();
     $this->assertEquals(str_pad($math->decHex($ping->getNonce()), 16, '0', STR_PAD_LEFT), $pong->getHex());
 }
示例#3
0
 /**
  * @param Ping $ping
  * @return Pong
  */
 public function pong(Ping $ping)
 {
     return new Pong($ping->getNonce());
 }
 /**
  * @param Ping $ping
  * @return \BitWasp\Buffertools\Buffer
  */
 public function serialize(Ping $ping)
 {
     return $this->getTemplate()->write([$ping->getNonce()]);
 }