mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-17 17:55:42 +00:00
test: update test suite
This commit is contained in:
parent
ddee6df4bd
commit
00469cad6b
@ -84,7 +84,7 @@ class Domain
|
|||||||
* @var Collection<int, DomainEntity>
|
* @var Collection<int, DomainEntity>
|
||||||
*/
|
*/
|
||||||
#[ORM\OneToMany(targetEntity: DomainEntity::class, mappedBy: 'domain', cascade: ['persist'], orphanRemoval: true)]
|
#[ORM\OneToMany(targetEntity: DomainEntity::class, mappedBy: 'domain', cascade: ['persist'], orphanRemoval: true)]
|
||||||
#[Groups(['domain:item'])]
|
#[Groups(['domain:item', 'watchlist:item'])]
|
||||||
#[SerializedName('entities')]
|
#[SerializedName('entities')]
|
||||||
private Collection $domainEntities;
|
private Collection $domainEntities;
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ class Domain
|
|||||||
joinColumns: [new ORM\JoinColumn(name: 'domain_ldh_name', referencedColumnName: 'ldh_name')],
|
joinColumns: [new ORM\JoinColumn(name: 'domain_ldh_name', referencedColumnName: 'ldh_name')],
|
||||||
inverseJoinColumns: [new ORM\JoinColumn(name: 'nameserver_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;
|
private Collection $nameservers;
|
||||||
|
|
||||||
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
||||||
|
|||||||
@ -48,11 +48,11 @@ class Entity
|
|||||||
|
|
||||||
#[ORM\ManyToOne(targetEntity: Tld::class, inversedBy: 'entities')]
|
#[ORM\ManyToOne(targetEntity: Tld::class, inversedBy: 'entities')]
|
||||||
#[ORM\JoinColumn(referencedColumnName: 'tld', nullable: false)]
|
#[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;
|
private ?Tld $tld = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255)]
|
||||||
#[Groups(['entity:list', 'entity:item', 'domain:item'])]
|
#[Groups(['entity:list', 'entity:item', 'domain:item', 'watchlist:item'])]
|
||||||
private ?string $handle = null;
|
private ?string $handle = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,11 +85,11 @@ class Entity
|
|||||||
'items' => ['type' => 'array'],
|
'items' => ['type' => 'array'],
|
||||||
]
|
]
|
||||||
)]
|
)]
|
||||||
#[Groups(['entity:item', 'domain:item'])]
|
#[Groups(['entity:item', 'domain:item', 'watchlist:item'])]
|
||||||
private array $jCard = [];
|
private array $jCard = [];
|
||||||
|
|
||||||
#[ORM\Column(nullable: true)]
|
#[ORM\Column(nullable: true)]
|
||||||
#[Groups(['entity:item', 'domain:item'])]
|
#[Groups(['entity:item', 'domain:item', 'watchlist:item'])]
|
||||||
private ?array $remarks = null;
|
private ?array $remarks = null;
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'entities')]
|
#[ORM\ManyToOne(inversedBy: 'entities')]
|
||||||
|
|||||||
@ -52,7 +52,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
normalizationContext: [
|
normalizationContext: [
|
||||||
'groups' => [
|
'groups' => [
|
||||||
'watchlist:item',
|
'watchlist:item',
|
||||||
'domain:item',
|
'domain:list',
|
||||||
'event:list',
|
'event:list',
|
||||||
'domain-entity:entity',
|
'domain-entity:entity',
|
||||||
'nameserver-entity:nameserver',
|
'nameserver-entity:nameserver',
|
||||||
@ -90,7 +90,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
processor: WatchListUpdateProcessor::class,
|
processor: WatchListUpdateProcessor::class,
|
||||||
),
|
),
|
||||||
new Put(
|
new Put(
|
||||||
normalizationContext: ['groups' => 'watchlist:item'],
|
normalizationContext: ['groups' => 'watchlist:list'],
|
||||||
denormalizationContext: ['groups' => ['watchlist:update']],
|
denormalizationContext: ['groups' => ['watchlist:update']],
|
||||||
security: 'object.user == user',
|
security: 'object.user == user',
|
||||||
processor: WatchListUpdateProcessor::class,
|
processor: WatchListUpdateProcessor::class,
|
||||||
|
|||||||
@ -33,7 +33,7 @@ final class WatchlistControllerTest extends ApiTestCase
|
|||||||
#[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')]
|
#[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')]
|
||||||
public function testGetTrackedDomains()
|
public function testGetTrackedDomains()
|
||||||
{
|
{
|
||||||
$client = WatchListUpdateProcessorTest::createUserAndWatchlist();
|
$client = WatchListUpdateProcessorTest::createUserAndWatchlist(null, ['/api/domains/example.org']);
|
||||||
$response = $client->request('GET', '/api/tracked');
|
$response = $client->request('GET', '/api/tracked');
|
||||||
|
|
||||||
$this->assertResponseIsSuccessful();
|
$this->assertResponseIsSuccessful();
|
||||||
|
|||||||
@ -53,11 +53,11 @@ final class WatchListUpdateProcessorTest extends ApiTestCase
|
|||||||
$this->assertCount(1, $data['trackedEvents']);
|
$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 = $client ?? self::createClientWithCredentials(self::getToken(UserFactory::createOne()));
|
||||||
$client->request('POST', '/api/watchlists', ['json' => [
|
$client->request('POST', '/api/watchlists', ['json' => [
|
||||||
'domains' => ['/api/domains/example.com'],
|
'domains' => $domains,
|
||||||
'name' => 'My Watchlist',
|
'name' => 'My Watchlist',
|
||||||
'trackedEvents' => ['last changed', 'transfer', 'expiration', 'deletion'],
|
'trackedEvents' => ['last changed', 'transfer', 'expiration', 'deletion'],
|
||||||
]]);
|
]]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user