test: add test for PATCH a watchlist

This commit is contained in:
Maël Gangloff 2025-10-25 19:27:41 +02:00
parent 24e3bc19ff
commit 76da56dd83
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629

View File

@ -46,7 +46,7 @@ final class WatchlistUpdateProcessorTest extends ApiTestCase
'name' => 'My modified Watchlist',
'trackedEvents' => ['last changed'],
'trackedEppStatus' => [],
'enabled' => true
'enabled' => true,
]]);
$this->assertResponseIsSuccessful();
$this->assertMatchesResourceItemJsonSchema(Watchlist::class);
@ -55,6 +55,25 @@ final class WatchlistUpdateProcessorTest extends ApiTestCase
$this->assertCount(1, $data['trackedEvents']);
}
#[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')]
public function testPartialUpdateWatchlist(): void
{
$client = self::createUserAndWatchlist();
$response = $client->request('GET', '/api/watchlists');
$token = $response->toArray()['hydra:member'][0]['token'];
$response = $client->request('PATCH', '/api/watchlists/'.$token, [
'headers' => ['Content-Type' => 'application/merge-patch+json'],
'json' => [
'enabled' => false,
],
]);
$this->assertResponseIsSuccessful();
$this->assertMatchesResourceItemJsonSchema(Watchlist::class);
$data = $response->toArray();
$this->assertFalse($data['enabled']);
}
public static function createUserAndWatchlist(?Client $client = null, array $domains = ['/api/domains/example.com'], ?string $connectorId = null): Client
{
$client = $client ?? self::createClientWithCredentials(self::getToken(UserFactory::createOne()));