test: update test suite

This commit is contained in:
Maël Gangloff 2025-10-14 11:15:56 +02:00
parent 6154759507
commit 39262814ce
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
2 changed files with 18 additions and 10 deletions

View File

@ -6,7 +6,7 @@ use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use ApiPlatform\Symfony\Bundle\Test\Client; use ApiPlatform\Symfony\Bundle\Test\Client;
use App\Entity\User; use App\Entity\User;
abstract class AbstractTest extends ApiTestCase class AbstractTest extends ApiTestCase
{ {
private ?string $token = null; private ?string $token = null;

View File

@ -3,6 +3,7 @@
namespace App\Tests\Service; namespace App\Tests\Service;
use App\Entity\RdapServer; use App\Entity\RdapServer;
use App\Entity\Tld;
use App\Exception\DomainNotFoundException; use App\Exception\DomainNotFoundException;
use App\Exception\TldNotSupportedException; use App\Exception\TldNotSupportedException;
use App\Exception\UnknownRdapServerException; use App\Exception\UnknownRdapServerException;
@ -34,24 +35,24 @@ class RDAPServiceTest extends KernelTestCase
$updateRdapServersHandler = self::$container->get(UpdateRdapServersHandler::class); $updateRdapServersHandler = self::$container->get(UpdateRdapServersHandler::class);
$message = new UpdateRdapServers(); $message = new UpdateRdapServers();
$updateRdapServersHandler($message); $updateRdapServersHandler($message);
self::$entityManager->flush();
$rdapServerRepository = self::$entityManager->getRepository(RdapServer::class); $rdapServerRepository = self::$entityManager->getRepository(RdapServer::class);
$this->assertNotEmpty($rdapServerRepository->findAll()); $this->assertNotEmpty($rdapServerRepository->findAll());
} }
#[Depends('testUpdateRdapServers')] #[Depends('testUpdateRdapServers')]
public function testRegisterDomain(): void public function testRegisterDomainByTld(): void
{ {
$rdapServerRepository = self::$entityManager->getRepository(RdapServer::class); self::$RDAPService->registerDomains(['arpa']);
$testedTldList = ['com', 'net', 'org', 'fr', 'de', 'ch', 'ca', 'leclerc', 'uz']; $rdapServerRepository = static::$entityManager->getRepository(RdapServer::class);
$rdapServerList = $rdapServerRepository->findBy(['tld' => array_map(
fn (string $tld) => static::$entityManager->getReference(Tld::class, $tld),
['com', 'net', 'fr', 'de', 'ch', 'ca', 'uz', 'google', 'ovh']
),
]);
/** @var RdapServer $rdapServer */ foreach ($rdapServerList as $rdapServer) {
foreach ($rdapServerRepository->findAll() as $rdapServer) {
if (!in_array($rdapServer->getTld()->getTld(), $testedTldList)) {
continue;
}
try { try {
self::$RDAPService->registerDomain('nic.'.$rdapServer->getTld()->getTld()); self::$RDAPService->registerDomain('nic.'.$rdapServer->getTld()->getTld());
} catch (DomainNotFoundException|ClientException|TransportException) { } catch (DomainNotFoundException|ClientException|TransportException) {
@ -73,4 +74,11 @@ class RDAPServiceTest extends KernelTestCase
$this->expectException(TldNotSupportedException::class); $this->expectException(TldNotSupportedException::class);
self::$RDAPService->registerDomain('nic.noexist'); self::$RDAPService->registerDomain('nic.noexist');
} }
#[Depends('testUpdateRdapServers')]
public function testDomainNotFound()
{
$this->expectException(DomainNotFoundException::class);
self::$RDAPService->registerDomain('dd5c3e77-c824-4792-95fc-ddde03a08881.com');
}
} }