/** * @uses HUID::generate * @uses HUID::validateNS * @uses HUID::setNS * @uses HUID::generate * @uses HUID::get */ public function testInvalidPairFail() { $HUID = new HUID(); $this->assertEquals(false, $HUID->setNS('555', '666')); $this->assertEquals(false, $HUID->generate()); $this->assertEquals(false, $HUID->get('str')); }
/** * @covers HUID::getNS * @uses HUID::__construct * @uses HUID::validateNS * @uses HUID::setNS * @uses HUID::getNS */ public function testValidPair() { $HUID = new HUID(); $this->assertEquals(true, $HUID->setNS('5555', '6666')); $this->assertEquals('5555', $HUID->getNS('primary')); $this->assertEquals('6666', $HUID->getNS('secondary')); $this->assertEquals('5555-6666', $HUID->getNS('both')); }
/** * @uses HUID::generate * @uses HUID::validateNS * @uses HUID::setNS * @uses HUID::generate * @uses HUID::get */ public function testGetObj() { $HUID = new HUID(); $this->assertEquals(true, $HUID->setNS('5555', '6666')); $this->assertEquals(true, $HUID->generate()); $HUIDValue = $HUID->get('obj'); $this->assertEquals('stdClass', get_class($HUIDValue)); $this->assertEquals(1, preg_match('/[0-9a-f]{14}-[0-9a-f]{5}-5{4}-6{4}-[0-9a-f]{5}/', $HUIDValue->str)); $this->assertEquals($HUIDValue->hex, strtolower($HUIDValue->hex)); $this->assertEquals(32, strlen($HUIDValue->hex)); $this->assertEquals(true, ctype_xdigit($HUIDValue->hex)); $this->assertEquals(16, strlen($HUIDValue->bin)); $this->assertEquals(true, '0x' . bin2hex($HUIDValue->bin) <= 3.402823669209385E+38); }
/** * @covers HUID::strToBin * @uses HUID::validateNS * @uses HUID::setNS * @uses HUID::strToBin * @uses HUID::isStr */ public function testFailure() { $HUID = new HUID(); $this->assertEquals(false, $HUID->strToBin('3333333333333-4444-555-666-7777')); }
/** * @covers HUID::hexToBin * @uses HUID::validateNS * @uses HUID::setNS * @uses HUID::hexToBin * @uses HUID::isHex */ public function testFailure() { $HUID = new HUID(); $this->assertEquals(false, $HUID->hexToBin('333333333333344445556667777')); }
/** * @covers HUID::__construct * @uses HUID::__construct * @uses HUID::validateNS * @uses HUID::setNS * @uses HUID::generate * @uses HUID::get */ public function testGeneratesHUIDWithValidParams() { $HUID = new HUID('5555', '6666'); $this->assertEquals(1, preg_match('/[0-9a-f]{14}-[0-9a-f]{5}-5{4}-6{4}-[0-9a-f]{5}/', $HUID->get('str'))); }
/** * @covers HUID::binToHex * @uses HUID::validateNS * @uses HUID::setNS * @uses HUID::validateHUID * @uses HUID::isBin */ public function testInvalidBin() { $HUID = new HUID(); $testHUID = '333333DDUfw'; $this->assertEquals(false, $HUID->validateHUID($testHUID)); $this->assertEquals(false, $HUID->validateHUID($testHUID, '5555')); $this->assertEquals(false, $HUID->validateHUID($testHUID, null, '6666')); $this->assertEquals(false, $HUID->validateHUID($testHUID, '5555', '6666')); $this->assertEquals(false, $HUID->validateHUID($testHUID, 'aaaa')); $this->assertEquals(false, $HUID->validateHUID($testHUID, null, 'bbbb')); $this->assertEquals(false, $HUID->validateHUID($testHUID, 'aaaa', 'bbbb')); $this->assertEquals(false, $HUID->validateHUID($testHUID, '555')); $this->assertEquals(false, $HUID->validateHUID($testHUID, null, '666')); $this->assertEquals(false, $HUID->validateHUID($testHUID, '555', '6666')); $this->assertEquals(false, $HUID->validateHUID($testHUID, '5555', '666')); $this->assertEquals(false, $HUID->validateHUID($testHUID, '555', '666')); }
/** * @covers HUID::binToStr * @uses HUID::validateNS * @uses HUID::setNS * @uses HUID::binToStr * @uses HUID::isBin */ public function testFailure() { $HUID = new HUID(); $this->assertEquals(false, $HUID->binToStr('333333DDUfw')); }
/** * @covers HUID::isBin * @uses HUID::__construct * @uses HUID::validateNS * @uses HUID::testProtected * @uses HUID::isBin */ public function test_isBin() { $HUID = new HUID(); $this->assertEquals(true, $HUID->testProtected('isBin')); }
/** * @covers HUID::setNS * @uses HUID::__construct * @uses HUID::validateNS * @uses HUID::setNS * @uses HUID::getNS */ public function testReplaceSecondaryOnInvalidWithValidPrimary() { $HUID = new HUID(); $this->assertEquals(true, $HUID->setNS('5555', '6666')); $this->assertEquals('5555', $HUID->getNS('primary')); $this->assertEquals('6666', $HUID->getNS('secondary')); $this->assertEquals('5555-6666', $HUID->getNS('both')); $this->assertEquals(true, $HUID->setNS('5555', '666')); $this->assertEquals('5555', $HUID->getNS('primary')); $this->assertEquals(false, $HUID->getNS('secondary')); $this->assertEquals(false, $HUID->getNS('both')); }