From 959dc2a9b06946594ed5da2c1ac66921c47a56a6 Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Mon, 13 Jan 2020 17:29:41 -0600 Subject: [PATCH] Refactor tests for GenericValidator --- tests/Validator/GenericValidatorTest.php | 74 ++++++++++++++++++++++ tests/Validator/ValidatorTest.php | 81 ------------------------ 2 files changed, 74 insertions(+), 81 deletions(-) create mode 100644 tests/Validator/GenericValidatorTest.php delete mode 100644 tests/Validator/ValidatorTest.php diff --git a/tests/Validator/GenericValidatorTest.php b/tests/Validator/GenericValidatorTest.php new file mode 100644 index 0000000..38e7b8f --- /dev/null +++ b/tests/Validator/GenericValidatorTest.php @@ -0,0 +1,74 @@ +assertSame($expected, $validator->validate($value)); + } + + /** + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification + */ + public function provideValuesForValidation(): array + { + return [ + 'good version 1' => [ + 'value' => 'ff6f8cb0-c57d-11e1-9b21-0800200c9a66', + 'expected' => true, + ], + 'good version 2' => [ + 'value' => 'ff6f8cb0-c57d-21e1-9b21-0800200c9a66', + 'expected' => true, + ], + 'good version 3' => [ + 'value' => 'ff6f8cb0-c57d-31e1-9b21-0800200c9a66', + 'expected' => true, + ], + 'good version 4' => [ + 'value' => 'ff6f8cb0-c57d-41e1-9b21-0800200c9a66', + 'expected' => true, + ], + 'good version 5' => [ + 'value' => 'ff6f8cb0-c57d-51e1-9b21-0800200c9a66', + 'expected' => true, + ], + 'good upper case' => [ + 'value' => 'FF6F8CB0-C57D-11E1-9B21-0800200C9A66', + 'expected' => true, + ], + 'bad hex' => [ + 'value' => 'zf6f8cb0-c57d-11e1-9b21-0800200c9a66', + 'expected' => false, + ], + 'too short 1' => [ + 'value' => '3f6f8cb0-c57d-11e1-9b21-0800200c9a6', + 'expected' => false, + ], + 'too short 2' => [ + 'value' => 'af6f8cb-c57d-11e1-9b21-0800200c9a66', + 'expected' => false, + ], + 'no dashes' => [ + 'value' => 'af6f8cb0c57d11e19b210800200c9a66', + 'expected' => false, + ], + 'too long' => [ + 'value' => 'ff6f8cb0-c57da-51e1-9b21-0800200c9a66', + 'expected' => false, + ], + ]; + } +} diff --git a/tests/Validator/ValidatorTest.php b/tests/Validator/ValidatorTest.php deleted file mode 100644 index 53030b9..0000000 --- a/tests/Validator/ValidatorTest.php +++ /dev/null @@ -1,81 +0,0 @@ -validator = $this->getMockBuilder(GenericValidator::class) - ->disableOriginalConstructor() - ->onlyMethods([]) - ->getMock(); - } - - public function testValidateGoodVersion1(): void - { - $this->assertTrue($this->validator->validate('ff6f8cb0-c57d-11e1-9b21-0800200c9a66')); - } - - public function testValidateGoodVersion2(): void - { - $this->assertTrue($this->validator->validate('ff6f8cb0-c57d-21e1-9b21-0800200c9a66')); - } - - public function testValidateGoodVersion3(): void - { - $this->assertTrue($this->validator->validate('ff6f8cb0-c57d-31e1-9b21-0800200c9a66')); - } - - public function testValidateGoodVersion4(): void - { - $this->assertTrue($this->validator->validate('ff6f8cb0-c57d-41e1-9b21-0800200c9a66')); - } - - public function testValidateGoodVersion5(): void - { - $this->assertTrue($this->validator->validate('ff6f8cb0-c57d-51e1-9b21-0800200c9a66')); - } - - public function testValidateGoodUpperCase(): void - { - $this->assertTrue($this->validator->validate('FF6F8CB0-C57D-11E1-9B21-0800200C9A66')); - } - - public function testValidateBadHex(): void - { - $this->assertFalse($this->validator->validate('zf6f8cb0-c57d-11e1-9b21-0800200c9a66')); - } - - public function testValidateTooShort1(): void - { - $this->assertFalse($this->validator->validate('3f6f8cb0-c57d-11e1-9b21-0800200c9a6')); - } - - public function testValidateTooShort2(): void - { - $this->assertFalse($this->validator->validate('af6f8cb-c57d-11e1-9b21-0800200c9a66')); - } - - public function testValidateNoDashes(): void - { - $this->assertFalse($this->validator->validate('af6f8cb0c57d11e19b210800200c9a66')); - } - - public function testValidateTooLong(): void - { - $this->assertFalse($this->validator->validate('ff6f8cb0-c57da-51e1-9b21-0800200c9a66')); - } -}