mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
test: use Response:: enum for HTTP status code
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Service\RDAPService;
|
||||
use App\Tests\AuthenticatedUserTrait;
|
||||
use App\Tests\Service\RDAPServiceTest;
|
||||
use PHPUnit\Framework\Attributes\DependsExternal;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Zenstruck\Foundry\Test\Factories;
|
||||
|
||||
final class AutoRegisterDomainProviderTest extends ApiTestCase
|
||||
@@ -33,7 +34,7 @@ final class AutoRegisterDomainProviderTest extends ApiTestCase
|
||||
$client = $this->createClient();
|
||||
$client->request('GET', '/api/domains/example.com');
|
||||
|
||||
$this->assertResponseStatusCodeSame(401);
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_UNAUTHORIZED);
|
||||
}
|
||||
|
||||
#[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')]
|
||||
|
||||
@@ -6,6 +6,7 @@ use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
|
||||
use App\Factory\UserFactory;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Zenstruck\Foundry\Test\Factories;
|
||||
|
||||
final class RegisterUserProcessorTest extends ApiTestCase
|
||||
@@ -35,7 +36,7 @@ final class RegisterUserProcessorTest extends ApiTestCase
|
||||
],
|
||||
]);
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertResponseStatusCodeSame(201);
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function testRegisterEmptyEmail(): void
|
||||
@@ -47,7 +48,7 @@ final class RegisterUserProcessorTest extends ApiTestCase
|
||||
'password' => 'MySuperPassword123',
|
||||
],
|
||||
]);
|
||||
$this->assertResponseStatusCodeSame(422);
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
public function testRegisterEmptyPassword(): void
|
||||
@@ -59,7 +60,7 @@ final class RegisterUserProcessorTest extends ApiTestCase
|
||||
'password' => '',
|
||||
],
|
||||
]);
|
||||
$this->assertResponseStatusCodeSame(422);
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
public function testRegisterWeakPassword(): void
|
||||
@@ -71,6 +72,6 @@ final class RegisterUserProcessorTest extends ApiTestCase
|
||||
'password' => '123',
|
||||
],
|
||||
]);
|
||||
$this->assertResponseStatusCodeSame(422);
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Factory\UserFactory;
|
||||
use App\Tests\AuthenticatedUserTrait;
|
||||
use App\Tests\Service\RDAPServiceTest;
|
||||
use PHPUnit\Framework\Attributes\DependsExternal;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Zenstruck\Foundry\Test\Factories;
|
||||
|
||||
final class WatchlistUpdateProcessorTest extends ApiTestCase
|
||||
@@ -21,7 +22,7 @@ final class WatchlistUpdateProcessorTest extends ApiTestCase
|
||||
{
|
||||
self::createUserAndWatchlist();
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertResponseStatusCodeSame(201);
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_CREATED);
|
||||
$this->assertMatchesResourceItemJsonSchema(Watchlist::class);
|
||||
}
|
||||
|
||||
@@ -31,7 +32,7 @@ final class WatchlistUpdateProcessorTest extends ApiTestCase
|
||||
$client = self::createClientWithCredentials(self::getToken(UserFactory::createOne()));
|
||||
self::createUserAndWatchlist($client);
|
||||
self::createUserAndWatchlist($client);
|
||||
$this->assertResponseStatusCodeSame(403);
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_FORBIDDEN);
|
||||
}
|
||||
|
||||
#[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')]
|
||||
|
||||
Reference in New Issue
Block a user