From c522879c6478d1565b5dfad1cfd1793bb6b6a110 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 23 Oct 2017 11:29:37 +0200 Subject: [PATCH] Updated composer check to ru functional tests too --- .travis.yml | 2 +- composer.json | 7 ++++--- .../Core/src/Repository/VisitRepository.php | 21 ++++++++++++------- .../Repository/VisitRepositoryInterface.php | 4 ++-- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index f9e19b89..e0490c63 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,6 @@ script: after_script: - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover build/clover.xml + - php ocular.phar code-coverage:upload --format=php-clover build/unit-clover.xml sudo: false diff --git a/composer.json b/composer.json index 2443e2ff..f0ee6e27 100644 --- a/composer.json +++ b/composer.json @@ -82,14 +82,15 @@ "scripts": { "check": [ "@cs", - "@test" + "@test", + "@func-test" ], "cs": "phpcs", "cs-fix": "phpcbf", "serve": "php -S 0.0.0.0:8000 -t public/", - "test": "phpunit --coverage-clover build/clover.xml", + "test": "phpunit --coverage-clover build/unit-clover.xml", "pretty-test": "phpunit --coverage-html build/coverage", - "func-test": "phpunit -c phpunit-func.xml" + "func-test": "phpunit -c phpunit-func.xml --coverage-clover build/func-clover.xml" }, "config": { "process-timeout": 0, diff --git a/module/Core/src/Repository/VisitRepository.php b/module/Core/src/Repository/VisitRepository.php index 2e034406..e77d5a43 100644 --- a/module/Core/src/Repository/VisitRepository.php +++ b/module/Core/src/Repository/VisitRepository.php @@ -13,7 +13,7 @@ class VisitRepository extends EntityRepository implements VisitRepositoryInterfa /** * @return Visit[] */ - public function findUnlocatedVisits() + public function findUnlocatedVisits(): array { $qb = $this->createQueryBuilder('v'); $qb->where($qb->expr()->isNull('v.visitLocation')); @@ -22,15 +22,20 @@ class VisitRepository extends EntityRepository implements VisitRepositoryInterfa } /** - * @param ShortUrl|int $shortUrl + * @param ShortUrl|int $shortUrlOrId * @param DateRange|null $dateRange * @return Visit[] */ - public function findVisitsByShortUrl($shortUrl, DateRange $dateRange = null) + public function findVisitsByShortUrl($shortUrlOrId, DateRange $dateRange = null): array { - $shortUrl = $shortUrl instanceof ShortUrl - ? $shortUrl - : $this->getEntityManager()->find(ShortUrl::class, $shortUrl); + /** @var ShortUrl|null $shortUrl */ + $shortUrl = $shortUrlOrId instanceof ShortUrl + ? $shortUrlOrId + : $this->getEntityManager()->find(ShortUrl::class, $shortUrlOrId); + + if ($shortUrl === null) { + return []; + } $qb = $this->createQueryBuilder('v'); $qb->where($qb->expr()->eq('v.shortUrl', ':shortUrl')) @@ -38,11 +43,11 @@ class VisitRepository extends EntityRepository implements VisitRepositoryInterfa ->orderBy('v.date', 'DESC') ; // Apply date range filtering - if (! empty($dateRange->getStartDate())) { + if ($dateRange !== null && $dateRange->getStartDate() !== null) { $qb->andWhere($qb->expr()->gte('v.date', ':startDate')) ->setParameter('startDate', $dateRange->getStartDate()); } - if (! empty($dateRange->getEndDate())) { + if ($dateRange !== null && $dateRange->getEndDate() !== null) { $qb->andWhere($qb->expr()->lte('v.date', ':endDate')) ->setParameter('endDate', $dateRange->getEndDate()); } diff --git a/module/Core/src/Repository/VisitRepositoryInterface.php b/module/Core/src/Repository/VisitRepositoryInterface.php index 4b562d1d..4ee3ebde 100644 --- a/module/Core/src/Repository/VisitRepositoryInterface.php +++ b/module/Core/src/Repository/VisitRepositoryInterface.php @@ -13,12 +13,12 @@ interface VisitRepositoryInterface extends ObjectRepository /** * @return Visit[] */ - public function findUnlocatedVisits(); + public function findUnlocatedVisits(): array; /** * @param ShortUrl|int $shortUrl * @param DateRange|null $dateRange * @return Visit[] */ - public function findVisitsByShortUrl($shortUrl, DateRange $dateRange = null); + public function findVisitsByShortUrl($shortUrl, DateRange $dateRange = null): array; }