Skip to content

Commit

Permalink
fixed #27 - Limit parameter by default value
Browse files Browse the repository at this point in the history
  • Loading branch information
pekral committed Mar 5, 2020
1 parent 24feae8 commit 4f51210
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/Http/UrlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ private function buildPathForOnlyEvidence(): Path
*/
private function createQueryParams(array $parameters): void
{
$parameters = \array_merge(['limit' => '0'], $parameters);
$this->setQuery(new Query(\http_build_query($parameters)));
}

Expand Down
17 changes: 11 additions & 6 deletions tests/Http/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,27 @@ public function setUp(): void

public function testCreateUriByCodeOnly(): void
{
Assert::assertEquals('https://demo.flexibee.eu/c/demo/adresar/(kod%20eq%20\'CODE:TEST\').json', $this->urlBuilder->createUriByCodeOnly('CODE:TEST', []));
Assert::assertEquals('https://demo.flexibee.eu/c/demo/adresar/(kod%20eq%20\'CODE:TEST\').json?test=1', $this->urlBuilder->createUriByCodeOnly('CODE:TEST', ['test' => true]));
Assert::assertEquals('https://demo.flexibee.eu/c/demo/adresar/(kod%20eq%20\'CODE:TEST\').json?limit=0', $this->urlBuilder->createUriByCodeOnly('CODE:TEST', []));
Assert::assertEquals('https://demo.flexibee.eu/c/demo/adresar/(kod%20eq%20\'CODE:TEST\').json?limit=0&test=1', $this->urlBuilder->createUriByCodeOnly('CODE:TEST', ['test' => true]));
}

public function testCreateUriByEvidenceOnly(): void
{
Assert::assertEquals('https://demo.flexibee.eu/c/demo/adresar.json', $this->urlBuilder->createUriByEvidenceOnly([]));
Assert::assertEquals('https://demo.flexibee.eu/c/demo/adresar.json?limit=0', $this->urlBuilder->createUriByEvidenceOnly([]));
}

public function testCreateUriByCustomId(): void
{
Assert::assertEquals('https://demo.flexibee.eu/c/demo/adresar/code:TEST.json', $this->urlBuilder->createFilterQuery('code:TEST', []));
Assert::assertEquals('https://demo.flexibee.eu/c/demo/adresar/code:TEST.json?limit=0', $this->urlBuilder->createFilterQuery('code:TEST', []));
}

public function testCreateUriPdf(): void
{
Assert::assertEquals('https://demo.flexibee.eu/c/demo/adresar/11.pdf', $this->urlBuilder->createPdfUrl(11, []));
Assert::assertEquals('https://demo.flexibee.eu/c/demo/adresar/11.pdf?limit=0', $this->urlBuilder->createPdfUrl(11, []));
$queryParams = [];
$queryParams['report-name'] = 'test';
$queryParams['report-lang'] = 'en';
Assert::assertEquals('https://demo.flexibee.eu/c/demo/adresar/11.pdf?report-name=test&report-lang=en', $this->urlBuilder->createPdfUrl(11, $queryParams));
Assert::assertEquals('https://demo.flexibee.eu/c/demo/adresar/11.pdf?limit=0&report-name=test&report-lang=en', $this->urlBuilder->createPdfUrl(11, $queryParams));
}

public function testCreateUriByEvidenceForSearchQuery(): void
Expand All @@ -63,4 +63,9 @@ public function testCreateUriByEvidenceForSearchQuery(): void
Assert::assertEquals('https://demo.flexibee.eu/c/demo/adresar/1.json?limit=10000&start=0', $this->urlBuilder->createFilterQuery('1', ['limit' => 10000, 'start' => 0]));
}

public function testCreateUriByEvidenceForSearchQueryWithouLimitParameter(): void
{
Assert::assertEquals('https://demo.flexibee.eu/c/demo/adresar/1.json?limit=0', $this->urlBuilder->createFilterQuery('1', []));
}

}

0 comments on commit 4f51210

Please sign in to comment.