Refactor to use UserInformativeValidatorByMatrixUserNameFactory.
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-09-07 18:38:03 +03:00
parent 85bd79e59c
commit 5c40bc6bf3
6 changed files with 28 additions and 119 deletions
+2 -2
View File
@@ -303,7 +303,7 @@ class CartTest extends TestCase
$response->assertStatus(200);
$response->assertJson([
'error' => 'The username is empty, please, write username!!!'
'error' => 'The username is invalid, please, check that you are registered or signed in!!!'
]);
}
@@ -321,7 +321,7 @@ class CartTest extends TestCase
$response->assertStatus(200);
$response->assertJson([
'error' => 'The username is empty, please, write username!!!'
'error' => 'The username is invalid, please, check that you are registered or signed in!!!'
]);
}
}
@@ -1,45 +0,0 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
use App\Models\Validation\UserValidationByMatrixUsername;
class UserValidationTest extends TestCase
{
public function dataProvider() {
return [
'Invalid Case' => [
'name' => '',
'key' => 'error',
'message' => 'The username is empty, please, write username!!!',
'isValid' => false,
],
'Not Found Case' => [
'name' => '@kostia:test.com',
'key' => 'error',
'message' => 'A user with the username does not exist!!!',
'isValid' => false,
],
'Found Case' => [
'name' => '@test:test.com',
'key' => 'ok',
'message' => 'A user with the username is valid.',
'isValid' => true,
]
];
}
/**
* @dataProvider dataProvider
*/
public function testUserValidationWithName(string $name, string $key, string $message, bool $isValid): void
{
$validator = new UserValidationByMatrixUsername($name);
$json = $validator->getMessageMap();
$this->assertEquals($json[$key], $message);
$this->assertEquals($validator->isValid(), $isValid);
}
}