Refactor InformativeValidators to move the modules into Validators.
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-09-03 11:54:39 +03:00
parent 9244aa11bc
commit 4c1e0bec07
13 changed files with 34 additions and 34 deletions
@@ -0,0 +1,46 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
use App\Models\Validation\Validators\Informative\Factories\CompanyInformativeValidatorByNameFactory;
class CompanyInformativeValidatorByNameFactoryTest extends TestCase
{
public function dataProvider() {
return [
'Found Case' => [
'name' => 'testCompany',
'key' => 'ok',
'message' => 'A company with the name is valid.',
'isValid' => true,
],
'Not Found Case' => [
'name' => '404 Company',
'key' => 'error',
'message' => 'A company with the name does not exist!!!',
'isValid' => false,
],
'Invalid Case' => [
'name' => '',
'key' => 'error',
'message' => 'The company name is empty, please, write the name!!!',
'isValid' => false,
],
];
}
/**
* @dataProvider dataProvider
*/
public function testValidatorFactory(string $name, string $key, string $message, bool $isValid): void
{
$factory = new CompanyInformativeValidatorByNameFactory($name);
$validator = $factory->create();
$this->assertEquals($validator->getMessage(), $message);
$this->assertEquals($validator->getOkStatus(), [$key => $message]);
$this->assertEquals($validator->isValid(), $isValid);
}
}
@@ -0,0 +1,46 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
use App\Models\Validation\Validators\Informative\Factories\ItemInformativeValidatorByNameFactory;
class ItemInformativeValidatorByNameFactoryTest extends TestCase
{
public function dataProvider() {
return [
'Invalid Case' => [
'name' => '',
'key' => 'error',
'message' => 'The item name is empty, please, write the name!!!',
'isValid' => false,
],
'Not Found Case' => [
'name' => '404 Item',
'key' => 'error',
'message' => 'A item with the name does not exist!!!',
'isValid' => false,
],
'Found Case' => [
'name' => 'Pizza Polo',
'key' => 'ok',
'message' => 'A item with the name is valid.',
'isValid' => true,
]
];
}
/**
* @dataProvider dataProvider
*/
public function testValidatorFactory(string $name, string $key, string $message, bool $isValid): void
{
$factory = new ItemInformativeValidatorByNameFactory($name);
$validator = $factory->create();
$this->assertEquals($validator->getMessage(), $message);
$this->assertEquals($validator->getOkStatus(), [$key => $message]);
$this->assertEquals($validator->isValid(), $isValid);
}
}