diff --git a/app/Models/Validation/Validators/CityValidatorByName.php b/app/Models/Validation/Validators/CityValidatorByName.php new file mode 100644 index 0000000..45b4180 --- /dev/null +++ b/app/Models/Validation/Validators/CityValidatorByName.php @@ -0,0 +1,16 @@ +getName())->count(); + + return $count != 0; + } +} diff --git a/tests/Feature/Validation/Validators/CityValidatorByNameTest.php b/tests/Feature/Validation/Validators/CityValidatorByNameTest.php new file mode 100644 index 0000000..b9d8aab --- /dev/null +++ b/tests/Feature/Validation/Validators/CityValidatorByNameTest.php @@ -0,0 +1,43 @@ + [ + 'name' => '', + 'isValid' => false, + ], + 'Not Found Case' => [ + 'name' => '404 City', + 'isValid' => false, + ], + 'Found Case' => [ + 'name' => 'testCity', + 'isValid' => true, + ] + ]; + } + + public function setUpValidator(string $name): CityValidatorByName + { + return new CityValidatorByName($name, new OkValidator()); + } + + /** + * @dataProvider dataProvider + */ + public function testGetMessage(string $name, bool $isValid): void + { + $validator = $this->setUpValidator($name); + + $this->assertEquals($validator->isValid(), $isValid); + } +}