Refactor the User validator.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
41acdd861b
commit
6db3465407
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class UserValidationTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testEmptyUsernameWithMatrixUsername(): void
|
||||||
|
{
|
||||||
|
$json = User::validateWithMatrixUsername('');
|
||||||
|
|
||||||
|
$this->assertEquals($json['error'], 'The username is empty, please, write username!!!');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testValidUserWithMatrixUsername(): void
|
||||||
|
{
|
||||||
|
$matrixUsername = '@test:test.com';
|
||||||
|
|
||||||
|
$json = User::validateWithMatrixUsername($matrixUsername);
|
||||||
|
|
||||||
|
$this->assertEquals($json['ok'], 'A user with the username is valid.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNotExistingUserWithMatrixUsername(): void
|
||||||
|
{
|
||||||
|
$matrixUsername = '@kostia:test.com';
|
||||||
|
|
||||||
|
$json = User::validateWithMatrixUsername($matrixUsername);
|
||||||
|
|
||||||
|
$this->assertEquals($json['error'], 'A user with the username does not exist!!!');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue