Added db test for VisitRepository::countVisits

This commit is contained in:
Alejandro Celaya
2021-01-09 17:54:04 +01:00
parent 01dceca9ef
commit 14eeb91c58
7 changed files with 87 additions and 38 deletions

View File

@@ -24,19 +24,25 @@ class ApiKey extends AbstractEntity
private Collection $roles;
/**
* @param RoleDefinition[] $roleDefinitions
* @throws Exception
*/
public function __construct(?Chronos $expirationDate = null, array $roleDefinitions = [])
public function __construct(?Chronos $expirationDate = null)
{
$this->key = Uuid::uuid4()->toString();
$this->expirationDate = $expirationDate;
$this->enabled = true;
$this->roles = new ArrayCollection();
}
public static function withRoles(RoleDefinition ...$roleDefinitions): self
{
$apiKey = new self();
foreach ($roleDefinitions as $roleDefinition) {
$this->registerRole($roleDefinition);
$apiKey->registerRole($roleDefinition);
}
return $apiKey;
}
public function getExpirationDate(): ?Chronos