diff --git a/src/Entity/Domain.php b/src/Entity/Domain.php index a6c5d0b..cfe4ad8 100644 --- a/src/Entity/Domain.php +++ b/src/Entity/Domain.php @@ -84,7 +84,7 @@ class Domain * @var Collection */ #[ORM\OneToMany(targetEntity: DomainEntity::class, mappedBy: 'domain', cascade: ['persist'], orphanRemoval: true)] - #[Groups(['domain:item'])] + #[Groups(['domain:item', 'watchlist:item'])] #[SerializedName('entities')] private Collection $domainEntities; @@ -106,7 +106,7 @@ class Domain joinColumns: [new ORM\JoinColumn(name: 'domain_ldh_name', referencedColumnName: 'ldh_name')], inverseJoinColumns: [new ORM\JoinColumn(name: 'nameserver_ldh_name', referencedColumnName: 'ldh_name')] )] - #[Groups(['domain:item'])] + #[Groups(['domain:item', 'watchlist:item'])] private Collection $nameservers; #[ORM\Column(type: Types::DATE_IMMUTABLE)] diff --git a/src/Entity/Entity.php b/src/Entity/Entity.php index 847d478..79be619 100644 --- a/src/Entity/Entity.php +++ b/src/Entity/Entity.php @@ -48,11 +48,11 @@ class Entity #[ORM\ManyToOne(targetEntity: Tld::class, inversedBy: 'entities')] #[ORM\JoinColumn(referencedColumnName: 'tld', nullable: false)] - #[Groups(['entity:list', 'entity:item', 'domain:item'])] + #[Groups(['entity:list', 'entity:item', 'domain:item', 'watchlist:item'])] private ?Tld $tld = null; #[ORM\Column(length: 255)] - #[Groups(['entity:list', 'entity:item', 'domain:item'])] + #[Groups(['entity:list', 'entity:item', 'domain:item', 'watchlist:item'])] private ?string $handle = null; /** @@ -85,11 +85,11 @@ class Entity 'items' => ['type' => 'array'], ] )] - #[Groups(['entity:item', 'domain:item'])] + #[Groups(['entity:item', 'domain:item', 'watchlist:item'])] private array $jCard = []; #[ORM\Column(nullable: true)] - #[Groups(['entity:item', 'domain:item'])] + #[Groups(['entity:item', 'domain:item', 'watchlist:item'])] private ?array $remarks = null; #[ORM\ManyToOne(inversedBy: 'entities')] diff --git a/src/Entity/WatchList.php b/src/Entity/WatchList.php index 46698f7..d19739b 100644 --- a/src/Entity/WatchList.php +++ b/src/Entity/WatchList.php @@ -52,7 +52,7 @@ use Symfony\Component\Validator\Constraints as Assert; normalizationContext: [ 'groups' => [ 'watchlist:item', - 'domain:item', + 'domain:list', 'event:list', 'domain-entity:entity', 'nameserver-entity:nameserver', @@ -90,7 +90,7 @@ use Symfony\Component\Validator\Constraints as Assert; processor: WatchListUpdateProcessor::class, ), new Put( - normalizationContext: ['groups' => 'watchlist:item'], + normalizationContext: ['groups' => 'watchlist:list'], denormalizationContext: ['groups' => ['watchlist:update']], security: 'object.user == user', processor: WatchListUpdateProcessor::class, diff --git a/tests/Controller/WatchlistControllerTest.php b/tests/Controller/WatchlistControllerTest.php index 816f5d5..d75f802 100644 --- a/tests/Controller/WatchlistControllerTest.php +++ b/tests/Controller/WatchlistControllerTest.php @@ -33,7 +33,7 @@ final class WatchlistControllerTest extends ApiTestCase #[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')] public function testGetTrackedDomains() { - $client = WatchListUpdateProcessorTest::createUserAndWatchlist(); + $client = WatchListUpdateProcessorTest::createUserAndWatchlist(null, ['/api/domains/example.org']); $response = $client->request('GET', '/api/tracked'); $this->assertResponseIsSuccessful(); diff --git a/tests/State/WatchListUpdateProcessorTest.php b/tests/State/WatchListUpdateProcessorTest.php index c155fe4..88fdc76 100644 --- a/tests/State/WatchListUpdateProcessorTest.php +++ b/tests/State/WatchListUpdateProcessorTest.php @@ -53,11 +53,11 @@ final class WatchListUpdateProcessorTest extends ApiTestCase $this->assertCount(1, $data['trackedEvents']); } - public static function createUserAndWatchlist(?Client $client = null): Client + public static function createUserAndWatchlist(?Client $client = null, array $domains = ['/api/domains/example.com']): Client { $client = $client ?? self::createClientWithCredentials(self::getToken(UserFactory::createOne())); $client->request('POST', '/api/watchlists', ['json' => [ - 'domains' => ['/api/domains/example.com'], + 'domains' => $domains, 'name' => 'My Watchlist', 'trackedEvents' => ['last changed', 'transfer', 'expiration', 'deletion'], ]]);