diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php deleted file mode 100644 index 8364a84..0000000 --- a/tests/Feature/ExampleTest.php +++ /dev/null @@ -1,19 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} diff --git a/tests/Feature/Validation/CompanyValidationByNameTest.php b/tests/Feature/Validation/CompanyValidationByNameTest.php index 87034c8..61c3be2 100644 --- a/tests/Feature/Validation/CompanyValidationByNameTest.php +++ b/tests/Feature/Validation/CompanyValidationByNameTest.php @@ -8,39 +8,38 @@ use App\Models\Validation\CompanyValidationByName; class CompanyValidationByNameTest extends TestCase { - public function testCompanyWithEmptyName(): void - { - $name = ''; - - $validator = new CompanyValidationByName($name); - $json = $validator->getMessageMap(); - $isValid = $validator->isValid(); - - $this->assertEquals($json['error'], 'The company name is empty, please, write the name!!!'); - $this->assertFalse($isValid); + public function dataProvider() { + return [ + 'Invalid Case' => [ + 'name' => '', + 'key' => 'error', + 'message' => 'The company name is empty, please, write the name!!!', + 'isValid' => false, + ], + 'Not Found Case' => [ + 'name' => '404 Company', + 'key' => 'error', + 'message' => 'A company with the name does not exist!!!', + 'isValid' => false, + ], + 'Found Case' => [ + 'name' => 'testCompany', + 'key' => 'ok', + 'message' => 'A company with the name is valid.', + 'isValid' => true, + ] + ]; } - public function testNotExistingCompanyWithName(): void + /** + * @dataProvider dataProvider + */ + public function testCompanyValidationWithName(string $name, string $key, string $message, bool $isValid): void { - $name = '404 Company'; - - $validator = new CompanyValidationByName($name); - $json = $validator->getMessageMap(); - $isValid = $validator->isValid(); - - $this->assertEquals($json['error'], 'A company with the name does not exist!!!'); - $this->assertFalse($isValid); - } - - public function testValidCompanyWithName(): void - { - $name = 'testCompany'; - $validator = new CompanyValidationByName($name); $json = $validator->getMessageMap(); - $isValid = $validator->isValid(); - $this->assertEquals($json['ok'], 'A company with the name is valid.'); - $this->assertTrue($isValid); + $this->assertEquals($json[$key], $message); + $this->assertEquals($validator->isValid(), $isValid); } } diff --git a/tests/Feature/Validation/ItemValidationByNameTest.php b/tests/Feature/Validation/ItemValidationByNameTest.php index 91c86a9..a89f776 100644 --- a/tests/Feature/Validation/ItemValidationByNameTest.php +++ b/tests/Feature/Validation/ItemValidationByNameTest.php @@ -34,7 +34,7 @@ class ItemValidationByNameTest extends TestCase /** * @dataProvider dataProvider */ - public function testCityValidationWithName(string $name, string $key, string $message, bool $isValid): void + public function testItemValidationWithName(string $name, string $key, string $message, bool $isValid): void { $validator = new ItemValidationByName($name); $json = $validator->getMessageMap(); diff --git a/tests/Feature/Validation/UserValidationTest.php b/tests/Feature/Validation/UserValidationTest.php index db7a302..5cc7931 100644 --- a/tests/Feature/Validation/UserValidationTest.php +++ b/tests/Feature/Validation/UserValidationTest.php @@ -34,7 +34,7 @@ class UserValidationTest extends TestCase /** * @dataProvider dataProvider */ - public function testCityValidationWithName(string $name, string $key, string $message, bool $isValid): void + public function testUserValidationWithName(string $name, string $key, string $message, bool $isValid): void { $validator = new UserValidationByMatrixUsername($name); $json = $validator->getMessageMap(); diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php deleted file mode 100644 index 5773b0c..0000000 --- a/tests/Unit/ExampleTest.php +++ /dev/null @@ -1,16 +0,0 @@ -assertTrue(true); - } -}