diff --git a/tests/GUID/fromHexStringTest.php b/tests/GUID/fromHexStringTest.php index dc67c98..5c31c29 100644 --- a/tests/GUID/fromHexStringTest.php +++ b/tests/GUID/fromHexStringTest.php @@ -12,6 +12,24 @@ */ class fromHexStringTestTest extends TestCase { + /** + * @expectedException \Unicity\Errors\GUIDInvariantsViolationError + * @expectedExceptionMessage IDs must have at least 6 bytes of entropy + */ + public function test_too_small_expected_length() + { + GUID::fromHexString('abcd', 4); + } + + /** + * @expectedException \Unicity\Errors\UnserializationError + * @expectedExceptionMessage The passed string has an unexpected length {"expected":6,"given":4} + */ + public function test_unexpected_length() + { + GUID::fromHexString('abcdef01', 6); + } + /** * @param string $invalidHexStr * @@ -21,7 +39,7 @@ class fromHexStringTestTest extends TestCase */ public function test_invalid_hex_strings(string $invalidHexStr) { - GUID::fromHexString($invalidHexStr, \strlen($invalidHexStr)/2); + GUID::fromHexString($invalidHexStr, (int)(\strlen($invalidHexStr)/2)); } public function invalidHexStringsProvider() @@ -29,7 +47,8 @@ public function invalidHexStringsProvider() return [ ['xyxyxyxyxyxy'], ['abcdefABCDEF'], - ['0123456789a-'] + ['0123456789a-'], + ['0123456789abc'] ]; } }