Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Commit

Permalink
III-1991: Add languages url parameter to offer search endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
bertramakers committed Mar 21, 2017
1 parent e198d8e commit b64fd61
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/OfferSearchController.php
Expand Up @@ -96,6 +96,11 @@ public function search(Request $request)
$parameters = $parameters->withTextLanguages(...$textLanguages);
}

$languages = $this->getLanguagesFromQuery($request, 'languages');
if (!empty($languages)) {
$parameters = $parameters->withLanguages(...$languages);
}

if (!empty($request->query->get('regionId'))) {
$parameters = $parameters->withRegion(
new RegionId($request->query->get('regionId')),
Expand Down
10 changes: 9 additions & 1 deletion tests/OfferSearchControllerTest.php
Expand Up @@ -73,6 +73,7 @@ public function it_returns_a_paged_collection_of_search_results_based_on_request
'locationLabels' => ['lorem'],
'organizerLabels' => ['ipsum'],
'textLanguages' => ['nl', 'en'],
'languages' => ['nl', 'en', 'fr'],
]
);

Expand All @@ -89,6 +90,11 @@ public function it_returns_a_paged_collection_of_search_results_based_on_request
new Language('nl'),
new Language('en')
)
->withLanguages(
new Language('nl'),
new Language('en'),
new Language('fr')
)
->withLabels(
new LabelName('foo'),
new LabelName('bar')
Expand Down Expand Up @@ -260,6 +266,7 @@ public function it_can_handle_a_single_string_value_for_parameters_that_are_norm
'organizerLabels' => 'bar',
'locationLabels' => 'baz',
'textLanguages' => 'nl',
'languages' => 'nl',
]
);

Expand All @@ -269,7 +276,8 @@ public function it_can_handle_a_single_string_value_for_parameters_that_are_norm
->withLabels(new LabelName('foo'))
->withOrganizerLabels(new LabelName('bar'))
->withLocationLabels(new LabelName('baz'))
->withTextLanguages(new Language('nl'));
->withTextLanguages(new Language('nl'))
->withLanguages(new Language('nl'));

$expectedResultSet = new PagedResultSet(new Natural(30), new Natural(0), []);

Expand Down

0 comments on commit b64fd61

Please sign in to comment.