Refactor to use InformativeValidators instead of ModelValidation.
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-09-08 14:01:36 +03:00
parent 5c40bc6bf3
commit 91e3b3234f
11 changed files with 3 additions and 303 deletions
@@ -1,45 +0,0 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
use App\Models\Validation\CityValidationByName;
class CityValidationByNameTest extends TestCase
{
public function dataProvider() {
return [
'Invalid Case' => [
'name' => '',
'key' => 'error',
'message' => 'The city name is empty, please, write the name!!!',
'isValid' => false,
],
'Not Found Case' => [
'name' => '404 City',
'key' => 'error',
'message' => 'A city with the name does not exist!!!',
'isValid' => false,
],
'Found Case' => [
'name' => 'testCity',
'key' => 'ok',
'message' => 'A city with the name is valid.',
'isValid' => true,
]
];
}
/**
* @dataProvider dataProvider
*/
public function testCityValidationWithName(string $name, string $key, string $message, bool $isValid): void
{
$validator = new CityValidationByName($name);
$json = $validator->getMessageMap();
$this->assertEquals($json[$key], $message);
$this->assertEquals($validator->isValid(), $isValid);
}
}