Fixed API tests

This commit is contained in:
Alejandro Celaya
2021-02-26 20:24:57 +01:00
parent 1498b72966
commit e093480a5b
9 changed files with 17 additions and 14 deletions

View File

@@ -6,7 +6,6 @@ namespace Shlinkio\Shlink\Core\Repository;
use Happyr\DoctrineSpecification\Repository\EntitySpecificationRepository;
use Happyr\DoctrineSpecification\Spec;
use Happyr\DoctrineSpecification\Specification\Specification;
use Shlinkio\Shlink\Core\Entity\Tag;
use Shlinkio\Shlink\Core\Tag\Model\TagInfo;
use Shlinkio\Shlink\Core\Tag\Spec\CountTagsWithName;
@@ -33,7 +32,7 @@ class TagRepository extends EntitySpecificationRepository implements TagReposito
/**
* @return TagInfo[]
*/
public function findTagsWithInfo(?Specification $spec = null): array
public function findTagsWithInfo(?ApiKey $apiKey = null): array
{
$qb = $this->createQueryBuilder('t');
$qb->select('t AS tag', 'COUNT(DISTINCT s.id) AS shortUrlsCount', 'COUNT(DISTINCT v.id) AS visitsCount')
@@ -42,7 +41,9 @@ class TagRepository extends EntitySpecificationRepository implements TagReposito
->groupBy('t')
->orderBy('t.name', 'ASC');
$this->applySpecification($qb, $spec, 't');
if ($apiKey !== null) {
$this->applySpecification($qb, $apiKey->spec(false, 'shortUrls'), 't');
}
$query = $qb->getQuery();

View File

@@ -17,7 +17,7 @@ interface TagRepositoryInterface extends ObjectRepository, EntitySpecificationRe
/**
* @return TagInfo[]
*/
public function findTagsWithInfo(?Specification $spec = null): array;
public function findTagsWithInfo(?ApiKey $apiKey = null): array;
public function tagExists(string $tag, ?ApiKey $apiKey = null): bool;
}