mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
test: add some KernelTestCase
This commit is contained in:
30
tests/UserTest.php
Normal file
30
tests/UserTest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Factory\UserFactory;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Zenstruck\Foundry\Test\Factories;
|
||||
use Zenstruck\Foundry\Test\ResetDatabase;
|
||||
|
||||
final class UserTest extends AbstractTest
|
||||
{
|
||||
use ResetDatabase;
|
||||
use Factories;
|
||||
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
*/
|
||||
public function testGetMyProfile(): void
|
||||
{
|
||||
$testUser = UserFactory::createOne();
|
||||
$client = UserTest::createClientWithCredentials(UserTest::getToken($testUser));
|
||||
|
||||
$client->loginUser($testUser);
|
||||
$client->request('GET', '/api/me');
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertMatchesResourceItemJsonSchema(User::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user