mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-17 09:45:29 +00:00
test: use Response:: enum for HTTP status code
This commit is contained in:
parent
0de6c7a132
commit
8a3ba9eb52
@ -9,6 +9,7 @@ use App\Message\ValidateConnectorCredentials;
|
||||
use App\MessageHandler\ValidateConnectorCredentialsHandler;
|
||||
use App\Tests\AuthenticatedUserTrait;
|
||||
use PHPUnit\Framework\Attributes\Depends;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Zenstruck\Foundry\Test\Factories;
|
||||
|
||||
final class ConnectorControllerTest extends ApiTestCase
|
||||
@ -39,7 +40,7 @@ final class ConnectorControllerTest extends ApiTestCase
|
||||
],
|
||||
'provider' => 'gandi',
|
||||
]]);
|
||||
$this->assertResponseStatusCodeSame(400);
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
public function testCreateConnectorInvalidConsent(): void
|
||||
@ -54,7 +55,7 @@ final class ConnectorControllerTest extends ApiTestCase
|
||||
],
|
||||
'provider' => 'gandi',
|
||||
]]);
|
||||
$this->assertResponseStatusCodeSame(451);
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_UNAVAILABLE_FOR_LEGAL_REASONS);
|
||||
}
|
||||
|
||||
public function testCreateConnectorInvalidAuthDataAdditionalKey(): void
|
||||
@ -70,7 +71,7 @@ final class ConnectorControllerTest extends ApiTestCase
|
||||
],
|
||||
'provider' => 'gandi',
|
||||
]]);
|
||||
$this->assertResponseStatusCodeSame(400);
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
public function testCreateConnectorValidAuthData(): void
|
||||
@ -89,7 +90,7 @@ final class ConnectorControllerTest extends ApiTestCase
|
||||
],
|
||||
'provider' => 'gandi',
|
||||
]]);
|
||||
$this->assertResponseStatusCodeSame(201);
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
#[Depends('testCreateConnectorValidAuthData')]
|
||||
@ -118,10 +119,10 @@ final class ConnectorControllerTest extends ApiTestCase
|
||||
],
|
||||
'provider' => 'gandi',
|
||||
]]);
|
||||
$this->assertResponseStatusCodeSame(201);
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_CREATED);
|
||||
|
||||
$client->request('DELETE', '/api/connectors/'.$response->toArray()['id']);
|
||||
|
||||
$this->assertResponseStatusCodeSame(204);
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class HomeControllerTest extends WebTestCase
|
||||
{
|
||||
@ -11,6 +12,6 @@ class HomeControllerTest extends WebTestCase
|
||||
$client = static::createClient();
|
||||
$client->request('GET', '/login/oauth');
|
||||
|
||||
$this->assertResponseStatusCodeSame(404);
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ use App\Tests\State\WatchlistUpdateProcessorTest;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\Attributes\DependsExternal;
|
||||
use Symfony\Component\HttpClient\Exception\ServerException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Uid\UuidV4;
|
||||
|
||||
class AbstractProviderTest extends ApiTestCase
|
||||
@ -83,7 +84,7 @@ class AbstractProviderTest extends ApiTestCase
|
||||
'authData' => $authData,
|
||||
'provider' => $connectorProvider->value,
|
||||
]]);
|
||||
$this->assertResponseStatusCodeSame(201);
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_CREATED);
|
||||
|
||||
/** @var EntityManagerInterface $entityManager */
|
||||
$entityManager = self::getContainer()->get(EntityManagerInterface::class);
|
||||
@ -112,7 +113,7 @@ class AbstractProviderTest extends ApiTestCase
|
||||
$message = new OrderDomain($watchlist->getToken(), $domain->getLdhName(), $domain->getUpdatedAt());
|
||||
$orderDomainHandler($message);
|
||||
|
||||
$this->assertResponseStatusCodeSame(200);
|
||||
$this->assertResponseStatusCodeSame(Response::HTTP_OK);
|
||||
} catch (ServerException $e) {
|
||||
$this->markTestSkipped('Provider '.$connectorProvider->value.' is not ready. Response HTTP '.$e->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
@ -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')]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user