diff --git a/core/tests/Drupal/Tests/Component/Uuid/UuidTest.php b/core/tests/Drupal/Tests/Component/Uuid/UuidTest.php index 3c2f379..17349e1 100644 --- a/core/tests/Drupal/Tests/Component/Uuid/UuidTest.php +++ b/core/tests/Drupal/Tests/Component/Uuid/UuidTest.php @@ -50,27 +50,6 @@ public function testUuidIsUnique(UuidInterface $instance) { } /** - * Tests UUID validation against known UUIDs. - */ - public function testUuidValidation() { - // These valid UUIDs. - $uuid_fqdn = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; - $uuid_min = '00000000-0000-0000-0000-000000000000'; - $uuid_max = 'ffffffff-ffff-ffff-ffff-ffffffffffff'; - - $this->assertTrue(Uuid::isValid($uuid_fqdn), $uuid_fqdn . ' is a valid UUID.'); - $this->assertTrue(Uuid::isValid($uuid_min), $uuid_min . ' is a valid UUID.'); - $this->assertTrue(Uuid::isValid($uuid_max), $uuid_max . ' is a valid UUID.'); - - // These are invalid UUIDs. - $invalid_format = '0ab26e6b-f074-4e44-9da-601205fa0e976'; - $invalid_length = '0ab26e6b-f074-4e44-9daf-1205fa0e9761f'; - - $this->assertFalse(Uuid::isValid($invalid_format), $invalid_format . ' is not a valid UUID.'); - $this->assertFalse(Uuid::isValid($invalid_length), $invalid_length . ' is not a valid UUID.'); - } - - /** * Dataprovider for UUID instance tests. * * @return array @@ -93,4 +72,40 @@ public function providerUuidInstances() { return $instances; } + /** + * Tests UUID validation. + * + * @param string $uuid + * The uuid to check against. + * @param bool $is_valid + * Whether the uuid is valid or not. + * @param string $message + * The message to display on failure. + * + * @dataProvider providerTestValidation + */ + public function testValidation($uuid, $is_valid, $message) { + $this->assertSame($is_valid, Uuid::isValid($uuid), $message); + } + + /** + * Dataprovider for UUID instance tests. + * + * @return array + * An array of arrays containing + * - The Uuid to check against. + * - (bool) Whether or not the Uuid is valid. + * - Failure message. + */ + public function providerTestValidation() { + return array( + // These valid UUIDs. + array('6ba7b810-9dad-11d1-80b4-00c04fd430c8', TRUE, 'Basic FQDN UUID did not validate'), + array('00000000-0000-0000-0000-000000000000', TRUE, 'Minimum UUID did not validate'), + array('ffffffff-ffff-ffff-ffff-ffffffffffff', TRUE, 'Maximum UUID did not validate'), + // These are invalid UUIDs. + array('0ab26e6b-f074-4e44-9da-601205fa0e976', FALSE, 'Invalid format was validated'), + array('0ab26e6b-f074-4e44-9daf-1205fa0e9761f', FALSE, 'Invalid length was validated'), + ); + } }