/** * 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 $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'); }
/** * Retrieve the current session UUID * * @return string current UUID */ public function getSession() { if (!isset($this->_sessionUuid)) { $this->_sessionUuid = Helper::createUuid(); } return $this->_sessionUuid; }