Add ItemInformativeValidatorByNameFactory.
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-08-28 14:17:17 +03:00
parent e057d2de27
commit 9a83b398c0
3 changed files with 103 additions and 0 deletions
@@ -0,0 +1,46 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
use App\Models\Validation\Messages\Factories\ItemInformativeValidatorByNameFactory;
class ItemValidatorByNameFactoryTest 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->okStatus(), [$key => $message]);
$this->assertEquals($validator->isValid(), $isValid);
}
}