You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.4 KiB

<?php
namespace Tests\Feature;
use Tests\TestCase;
use App\Models\Validation\Messages\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);
}
}