Ejemplo n.º 1
0
 public function testTableWriteReadCollection()
 {
     $w = new AMQPBufferWriter();
     $w->write_table(new AMQPTable(array('long' => 12345, 'long_neg' => -12345, 'longlong' => 3000000000, 'longlong_neg' => -3000000000, 'float_low' => 9.2233720368548, 'float_high' => (double) 9.2233720368548E+18, 'bool_true' => true, 'bool_false' => false, 'array' => array(1, 2, 3, 'foo', array('bar' => 'baz'), array('boo', false, 5), true), 'array_empty' => array(), 'table' => array('foo' => 'bar', 'baz' => 'boo', 'bool' => true, 'tbl' => array('bar' => 'baz'), 'arr' => array('boo', false, 5)), 'table_num' => array(1 => 5, 3 => 'foo', 786 => 674), 'array_nested' => array(1, array(2, array(3, array(4)))), 'table_nested' => array('i' => 1, 'n' => array('i' => 2, 'n' => array('i' => 3, 'n' => array('i' => 4)))))));
     $r = new AMQPBufferReader($w->getvalue());
     //type casting - thanks to ancient phpunit on travis
     $this->assertEquals(array('long' => 12345, 'long_neg' => -12345, 'longlong' => (string) 3000000000, 'longlong_neg' => (string) -3000000000, 'float_low' => (string) (double) 9.2233720368548, 'float_high' => (string) (double) 9.2233720368548E+18, 'bool_true' => true, 'bool_false' => false, 'array' => array(1, 2, 3, 'foo', array('bar' => 'baz'), array('boo', false, 5), true), 'array_empty' => array(), 'table' => array('foo' => 'bar', 'baz' => 'boo', 'bool' => true, 'tbl' => array('bar' => 'baz'), 'arr' => array('boo', false, 5)), 'table_num' => array(1 => 5, 3 => 'foo', 786 => 674), 'array_nested' => array(1, array(2, array(3, array(4)))), 'table_nested' => array('i' => 1, 'n' => array('i' => 2, 'n' => array('i' => 3, 'n' => array('i' => 4))))), $r->read_table(true)->getNativeData());
 }
Ejemplo n.º 2
0
 /**
  * Generate login_response value for start_ok
  *
  * @param string $user
  * @param string $password
  * @return string
  */
 protected function getLoginResponse(string $user, string $password)
 {
     if ($user && $password) {
         $login_response = new AMQPBufferWriter();
         $login_response->write_table(array('LOGIN' => array('S', $user), 'PASSWORD' => array('S', $password)));
         // Skip the length
         $responseValue = $login_response->getvalue();
         $login_response = substr($responseValue, 4, strlen($responseValue) - 4);
     } else {
         $login_response = null;
     }
     return $login_response;
 }
Ejemplo n.º 3
0
 /**
  * @return array
  */
 public function basicConsume($reserved1 = 0, $queue = '', $consumer_tag = '', $no_local = false, $no_ack = false, $exclusive = false, $nowait = false, $arguments = array())
 {
     $args = new AMQPBufferWriter();
     $args->write_short($reserved1);
     $args->write_shortstr($queue);
     $args->write_shortstr($consumer_tag);
     $args->write_bits(array($no_local, $no_ack, $exclusive, $nowait));
     $args->write_table(empty($arguments) ? array() : $arguments);
     return [ClassTypes::BASIC, BasicMethods::CONSUME, $args->getvalue()];
 }