Fixed existing tests and coding styles

This commit is contained in:
Alejandro Celaya 2019-12-16 15:16:18 +01:00
parent d7ffcd903d
commit 99fd5f937e
5 changed files with 18 additions and 13 deletions

View File

@ -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));

View File

@ -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

View File

@ -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);
}

View File

@ -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);
}

View File

@ -49,7 +49,8 @@ class ListShortUrlsActionTest extends TestCase
$expectedPage,
$expectedSearchTerm,
$expectedTags,
$expectedOrderBy
$expectedOrderBy,
null
)->willReturn(new Paginator(new ArrayAdapter()));
/** @var JsonResponse $response */