2025-10-14 17:40:48 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Tests\Controller;
|
|
|
|
|
|
2025-10-14 18:48:40 +02:00
|
|
|
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
|
2025-10-14 17:40:48 +02:00
|
|
|
use App\Entity\WatchList;
|
2025-10-14 18:48:40 +02:00
|
|
|
use App\Tests\AuthenticatedUserTrait;
|
2025-10-14 17:40:48 +02:00
|
|
|
use App\Tests\Service\RDAPServiceTest;
|
2025-10-15 18:55:39 +02:00
|
|
|
use App\Tests\State\WatchListUpdateProcessorTest;
|
2025-10-14 17:40:48 +02:00
|
|
|
use PHPUnit\Framework\Attributes\DependsExternal;
|
|
|
|
|
use Zenstruck\Foundry\Test\Factories;
|
|
|
|
|
|
2025-10-14 18:48:40 +02:00
|
|
|
final class WatchlistControllerTest extends ApiTestCase
|
2025-10-14 17:40:48 +02:00
|
|
|
{
|
|
|
|
|
use Factories;
|
2025-10-14 18:48:40 +02:00
|
|
|
use AuthenticatedUserTrait;
|
2025-10-14 17:40:48 +02:00
|
|
|
|
2025-10-14 23:34:17 +02:00
|
|
|
#[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')]
|
2025-10-14 17:40:48 +02:00
|
|
|
public function testGetWatchlistCollection(): void
|
|
|
|
|
{
|
2025-10-15 18:55:39 +02:00
|
|
|
$client = WatchListUpdateProcessorTest::createUserAndWatchlist();
|
2025-10-14 17:40:48 +02:00
|
|
|
|
|
|
|
|
$response = $client->request('GET', '/api/watchlists');
|
|
|
|
|
|
|
|
|
|
$this->assertResponseIsSuccessful();
|
|
|
|
|
$this->assertMatchesResourceCollectionJsonSchema(WatchList::class);
|
|
|
|
|
|
|
|
|
|
$data = $response->toArray();
|
|
|
|
|
$this->assertArrayHasKey('hydra:member', $data);
|
|
|
|
|
$this->assertCount(1, $data['hydra:member']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')]
|
|
|
|
|
public function testGetTrackedDomains()
|
|
|
|
|
{
|
2025-10-15 18:55:39 +02:00
|
|
|
$client = WatchListUpdateProcessorTest::createUserAndWatchlist();
|
2025-10-14 17:40:48 +02:00
|
|
|
$response = $client->request('GET', '/api/tracked');
|
2025-10-15 21:24:48 +02:00
|
|
|
|
2025-10-14 17:40:48 +02:00
|
|
|
$this->assertResponseIsSuccessful();
|
|
|
|
|
|
|
|
|
|
$data = $response->toArray();
|
|
|
|
|
$this->assertArrayHasKey('hydra:member', $data);
|
|
|
|
|
$this->assertCount(1, $data['hydra:member']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')]
|
|
|
|
|
public function testGetWatchlistFeeds()
|
|
|
|
|
{
|
2025-10-15 18:55:39 +02:00
|
|
|
$client = WatchListUpdateProcessorTest::createUserAndWatchlist();
|
2025-10-14 17:40:48 +02:00
|
|
|
|
|
|
|
|
$response = $client->request('GET', '/api/watchlists');
|
|
|
|
|
$token = $response->toArray()['hydra:member'][0]['token'];
|
|
|
|
|
|
|
|
|
|
$client->request('GET', '/api/watchlists/'.$token.'/calendar');
|
|
|
|
|
$this->assertResponseIsSuccessful();
|
|
|
|
|
$this->assertResponseHeaderSame('content-type', 'text/calendar; charset=utf-8');
|
|
|
|
|
|
|
|
|
|
$client->request('GET', '/api/watchlists/'.$token.'/rss/events');
|
|
|
|
|
$this->assertResponseIsSuccessful();
|
|
|
|
|
$this->assertResponseHeaderSame('content-type', 'application/atom+xml; charset=utf-8');
|
|
|
|
|
|
|
|
|
|
$client->request('GET', '/api/watchlists/'.$token.'/rss/status');
|
|
|
|
|
$this->assertResponseIsSuccessful();
|
|
|
|
|
$this->assertResponseHeaderSame('content-type', 'application/atom+xml; charset=utf-8');
|
|
|
|
|
}
|
|
|
|
|
}
|