This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
use App\Models\City;
|
||||
|
||||
class CityTest extends TestCase
|
||||
{
|
||||
/* City validation */
|
||||
|
||||
public function test_city_with_empty_name(): void
|
||||
{
|
||||
$json = City::validate_with_name('');
|
||||
|
||||
$this->assertEquals($json['error'], 'The city name is empty, please, write the name!!!');
|
||||
}
|
||||
|
||||
public function test_not_existing_city_with_name(): void
|
||||
{
|
||||
$name = '404 City';
|
||||
|
||||
$json = City::validate_with_name($name);
|
||||
|
||||
$this->assertEquals($json['error'], 'A city with the name does not exist!!!');
|
||||
}
|
||||
|
||||
public function test_valid_city_with_name(): void
|
||||
{
|
||||
$name = 'testCity';
|
||||
|
||||
$json = City::validate_with_name($name);
|
||||
|
||||
$this->assertEquals($json['ok'], 'A city with the name is valid.');
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,13 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Http\Controllers\API\v2\UserController;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class UserTest extends TestCase
|
||||
@@ -87,4 +90,31 @@ class UserTest extends TestCase
|
||||
'username' => $this->username
|
||||
]);
|
||||
}
|
||||
|
||||
/* User validation */
|
||||
|
||||
public function test_empty_username_with_matrix_username(): void
|
||||
{
|
||||
$json = User::validate_with_matrix_username('');
|
||||
|
||||
$this->assertEquals($json['error'], 'The username is empty, please, write username!!!');
|
||||
}
|
||||
|
||||
public function test_not_existing_user_with_matrix_username(): void
|
||||
{
|
||||
$matrix_username = '@kostia:test.com';
|
||||
|
||||
$json = User::validate_with_matrix_username($matrix_username);
|
||||
|
||||
$this->assertEquals($json['error'], 'A user with the username does not exist!!!');
|
||||
}
|
||||
|
||||
public function test_valid_user_with_matrix_username(): void
|
||||
{
|
||||
$matrix_username = '@test:test.com';
|
||||
|
||||
$json = User::validate_with_matrix_username($matrix_username);
|
||||
|
||||
$this->assertEquals($json['ok'], 'A user with the username is valid.');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user