From 99fd5f937ed3d4b75abf33662b8a0288d83060c8 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 16 Dec 2019 15:16:18 +0100 Subject: [PATCH] Fixed existing tests and coding styles --- module/Core/src/Service/ShortUrlService.php | 12 +++++++----- module/Core/src/Service/ShortUrlServiceInterface.php | 12 +++++++----- .../Adapter/ShortUrlRepositoryAdapterTest.php | 2 +- .../Rest/src/Action/ShortUrl/ListShortUrlsAction.php | 2 +- .../test/Action/ShortUrl/ListShortUrlsActionTest.php | 3 ++- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/module/Core/src/Service/ShortUrlService.php b/module/Core/src/Service/ShortUrlService.php index e82b3741..15a3b432 100644 --- a/module/Core/src/Service/ShortUrlService.php +++ b/module/Core/src/Service/ShortUrlService.php @@ -29,16 +29,18 @@ class ShortUrlService implements ShortUrlServiceInterface } /** - * @param int $page - * @param string|null $searchQuery * @param string[] $tags * @param array|string|null $orderBy - * @param DateRange|null $dateRange * * @return ShortUrl[]|Paginator */ - public function listShortUrls(int $page = 1, ?string $searchQuery = null, array $tags = [], $orderBy = null, ?DateRange $dateRange = null) - { + public function listShortUrls( + int $page = 1, + ?string $searchQuery = null, + array $tags = [], + $orderBy = null, + ?DateRange $dateRange = null + ) { /** @var ShortUrlRepository $repo */ $repo = $this->em->getRepository(ShortUrl::class); $paginator = new Paginator(new ShortUrlRepositoryAdapter($repo, $searchQuery, $tags, $orderBy, $dateRange)); diff --git a/module/Core/src/Service/ShortUrlServiceInterface.php b/module/Core/src/Service/ShortUrlServiceInterface.php index 7c105c59..6e3fe199 100644 --- a/module/Core/src/Service/ShortUrlServiceInterface.php +++ b/module/Core/src/Service/ShortUrlServiceInterface.php @@ -13,16 +13,18 @@ use Zend\Paginator\Paginator; interface ShortUrlServiceInterface { /** - * @param int $page - * @param string|null $searchQuery * @param string[] $tags * @param array|string|null $orderBy - * @return ShortUrl[]|Paginator - * @param DateRange|null $dateRange * * @return ShortUrl[]|Paginator */ - public function listShortUrls(int $page = 1, ?string $searchQuery = null, array $tags = [], $orderBy = null, ?DateRange $dateRange = null); + public function listShortUrls( + int $page = 1, + ?string $searchQuery = null, + array $tags = [], + $orderBy = null, + ?DateRange $dateRange = null + ); /** * @param string[] $tags diff --git a/module/Core/test/Paginator/Adapter/ShortUrlRepositoryAdapterTest.php b/module/Core/test/Paginator/Adapter/ShortUrlRepositoryAdapterTest.php index a7229147..391fdad6 100644 --- a/module/Core/test/Paginator/Adapter/ShortUrlRepositoryAdapterTest.php +++ b/module/Core/test/Paginator/Adapter/ShortUrlRepositoryAdapterTest.php @@ -25,7 +25,7 @@ class ShortUrlRepositoryAdapterTest extends TestCase /** @test */ public function getItemsFallbacksToFindList(): void { - $this->repo->findList(10, 5, 'search', ['foo', 'bar'], 'order')->shouldBeCalledOnce(); + $this->repo->findList(10, 5, 'search', ['foo', 'bar'], 'order', null)->shouldBeCalledOnce(); $this->adapter->getItems(5, 10); } diff --git a/module/Rest/src/Action/ShortUrl/ListShortUrlsAction.php b/module/Rest/src/Action/ShortUrl/ListShortUrlsAction.php index 5cb8aa90..24c44628 100644 --- a/module/Rest/src/Action/ShortUrl/ListShortUrlsAction.php +++ b/module/Rest/src/Action/ShortUrl/ListShortUrlsAction.php @@ -61,7 +61,7 @@ class ListShortUrlsAction extends AbstractRestAction $dateRange = null; $startDate = isset($query['startDate']) ? Chronos::parse($query['startDate']) : null; $endDate = isset($query['endDate']) ? Chronos::parse($query['endDate']) : null; - if ($startDate != null || $endDate != null) { + if ($startDate !== null || $endDate !== null) { $dateRange = new DateRange($startDate, $endDate); } diff --git a/module/Rest/test/Action/ShortUrl/ListShortUrlsActionTest.php b/module/Rest/test/Action/ShortUrl/ListShortUrlsActionTest.php index 4197aba8..cfe9a683 100644 --- a/module/Rest/test/Action/ShortUrl/ListShortUrlsActionTest.php +++ b/module/Rest/test/Action/ShortUrl/ListShortUrlsActionTest.php @@ -49,7 +49,8 @@ class ListShortUrlsActionTest extends TestCase $expectedPage, $expectedSearchTerm, $expectedTags, - $expectedOrderBy + $expectedOrderBy, + null )->willReturn(new Paginator(new ArrayAdapter())); /** @var JsonResponse $response */