diff --git a/core/tests/Drupal/Tests/Component/Uuid/UuidTest.php b/core/tests/Drupal/Tests/Component/Uuid/UuidTest.php index b7cf8dc..74ca353 100644 --- a/core/tests/Drupal/Tests/Component/Uuid/UuidTest.php +++ b/core/tests/Drupal/Tests/Component/Uuid/UuidTest.php @@ -52,41 +52,23 @@ public function testUuidIsUnique(UuidInterface $instance) { /** * Tests UUID validation. - * - * @param string $uuid - * The uuid to check against. - * @param bool $is_valid - * Whether the uuid is valid or not. - * - * @dataProvider providerTestValidation */ - public function testValidation($uuid, $is_valid) { - $this->assertEquals($is_valid, Uuid::isValid($uuid)); - } + 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'; - /** - * 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. - */ - public function providerTestValidation() { - return array( - // These valid UUIDs. - // FQDN. - array('6ba7b810-9dad-11d1-80b4-00c04fd430c8', TRUE), - // Minimum. - array('00000000-0000-0000-0000-000000000000', TRUE), - // Maximum. - array('ffffffff-ffff-ffff-ffff-ffffffffffff', TRUE), - // These are invalid UUIDs. - // Invalid format. - array('0ab26e6b-f074-4e44-9da-601205fa0e976', FALSE), - // Invalid length. - array('0ab26e6b-f074-4e44-9daf-1205fa0e9761f', FALSE), - ); + $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.'); } /** @@ -96,9 +78,8 @@ public function providerTestValidation() { */ public function providerUuidInstances() { - $instances = array( - array(new Php()), - ); + $instances = array(); + $instances[][] = new Php(); // If valid PECL extensions exists add to list. if (function_exists('uuid_create') && !function_exists('uuid_make')) {