mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
test: add test for FinDomainCollectionFromEntityProvider
This commit is contained in:
35
tests/State/FindDomainCollectionFromEntityProviderTest.php
Normal file
35
tests/State/FindDomainCollectionFromEntityProviderTest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\State;
|
||||
|
||||
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
|
||||
use App\Entity\Domain;
|
||||
use App\Factory\UserFactory;
|
||||
use App\Tests\AuthenticatedUserTrait;
|
||||
use App\Tests\Service\RDAPServiceTest;
|
||||
use PHPUnit\Framework\Attributes\DependsExternal;
|
||||
use Zenstruck\Foundry\Test\Factories;
|
||||
|
||||
final class FindDomainCollectionFromEntityProviderTest extends ApiTestCase
|
||||
{
|
||||
use Factories;
|
||||
use AuthenticatedUserTrait;
|
||||
|
||||
#[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')]
|
||||
public function testFilterDomainCollection(): void
|
||||
{
|
||||
$client = FindDomainCollectionFromEntityProviderTest::createClientWithCredentials(FindDomainCollectionFromEntityProviderTest::getToken(UserFactory::createOne()));
|
||||
$client->request('GET', '/api/domains/nic.fr')->toArray();
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
$response = $client->request('GET', '/api/domains', [
|
||||
'query' => ['registrant' => 'AFNIC'],
|
||||
]);
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertMatchesResourceCollectionJsonSchema(Domain::class);
|
||||
|
||||
$data = $response->toArray();
|
||||
$this->assertArrayHasKey('hydra:member', $data);
|
||||
$this->assertCount(1, $data['hydra:member']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user