public function testWithInvalidUlid() { $this->
expectException(\InvalidArgumentException::
class);
$this->
expectExceptionMessage('Invalid ULID: "this is not a ulid".'
);
new Ulid('this is not a ulid'
);
} public function testBinary() { $ulid =
new Ulid('00000000000000000000000000'
);
$this->
assertSame("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
$ulid->
toBinary());
$ulid =
new Ulid('3zzzzzzzzzzzzzzzzzzzzzzzzz'
);
$this->
assertSame('7fffffffffffffffffffffffffffffff',
bin2hex($ulid->
toBinary()));
$this->
assertTrue($ulid->
equals(Ulid::
fromString(hex2bin('7fffffffffffffffffffffffffffffff'
))));
} public function toHex() { $ulid = Ulid::
fromString('1BVXue8CnY8ogucrHX3TeF'
);
$this->
assertSame('0x0177058f4dacd0b2a990a49af02bc008',
$ulid->
toHex());
}