mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-24 05:05:39 +00:00
test: add test for PATCH a watchlist
This commit is contained in:
parent
24e3bc19ff
commit
76da56dd83
@ -46,7 +46,7 @@ final class WatchlistUpdateProcessorTest extends ApiTestCase
|
|||||||
'name' => 'My modified Watchlist',
|
'name' => 'My modified Watchlist',
|
||||||
'trackedEvents' => ['last changed'],
|
'trackedEvents' => ['last changed'],
|
||||||
'trackedEppStatus' => [],
|
'trackedEppStatus' => [],
|
||||||
'enabled' => true
|
'enabled' => true,
|
||||||
]]);
|
]]);
|
||||||
$this->assertResponseIsSuccessful();
|
$this->assertResponseIsSuccessful();
|
||||||
$this->assertMatchesResourceItemJsonSchema(Watchlist::class);
|
$this->assertMatchesResourceItemJsonSchema(Watchlist::class);
|
||||||
@ -55,6 +55,25 @@ final class WatchlistUpdateProcessorTest extends ApiTestCase
|
|||||||
$this->assertCount(1, $data['trackedEvents']);
|
$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
|
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()));
|
$client = $client ?? self::createClientWithCredentials(self::getToken(UserFactory::createOne()));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user