示例#1
0
 /**
  * Serializes the data
  *
  * @param array &$data data to be serialized
  *
  * @return int length of generated string
  */
 public function serialize(&$data)
 {
     $data[0] = Helper::uuidToBin($data[0]);
     $data[1] = Helper::uuidToBin($data[1]);
     $data = msgpack_pack($data);
     return mb_strlen($data, 'ISO-8859-1');
 }
示例#2
0
 /**
  * Testing UUID
  *
  * @return void
  */
 public function testCreateUuid()
 {
     $uuid1 = Helper::createUuid();
     $this->assertTRUE(mb_strlen($uuid1, 'ISO-8859-1') == 36, 'The generated UUID is not the correct length ');
     $this->assertTRUE(count(str_split($uuid1, 1)) == 36, 'The generated UUID is not the correct length');
     $uuid = Helper::uuidToBin($uuid1);
     $this->assertTRUE(mb_strlen($uuid, 'ISO-8859-1') == 16, 'The conversion to bin of the UUID is not the correct length (16 bytes)');
     $this->assertTRUE(count(str_split($uuid, 1)) == 16, 'The conversion to bin of the UUID is not the correct length (16 bytes)');
     //test that the bin format is correct for rexPro
     $this->assertEquals(bin2hex($uuid), str_replace('-', '', trim($uuid1)), 'The conversion to bin of the UUID is incorrect');
     $uuid = Helper::binToUuid($uuid);
     $this->assertTRUE(mb_strlen($uuid, 'ISO-8859-1') == 36, 'The conversion of bin UUID to UUID is not the correct length');
     $this->assertTRUE(count(str_split($uuid, 1)) == 36, 'The conversion of bin UUID to UUID is not the correct length');
     $this->assertEquals($uuid, $uuid1, 'UUID before and after convertion do not match');
 }