From eb1d8894b943eb0f07747d1dab203217860b6930 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sun, 29 Mar 2015 18:17:52 +0200 Subject: [PATCH] correctly handle comma-only exclude_place_ids --- lib/Geocode.php | 7 +++++-- tests/features/api/search_simple.feature | 7 +++++++ tests/steps/api_result.py | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/Geocode.php b/lib/Geocode.php index dfb3af2a..a7adb2b9 100644 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@ -222,9 +222,12 @@ foreach(explode(',',$aParams['exclude_place_ids']) as $iExcludedPlaceID) { $iExcludedPlaceID = (int)$iExcludedPlaceID; - if ($iExcludedPlaceID) $aExcludePlaceIDs[$iExcludedPlaceID] = $iExcludedPlaceID; + if ($iExcludedPlaceID) + $aExcludePlaceIDs[$iExcludedPlaceID] = $iExcludedPlaceID; } - $this->aExcludePlaceIDs = $aExcludePlaceIDs; + + if (isset($aExcludePlaceIDs)) + $this->aExcludePlaceIDs = $aExcludePlaceIDs; } // Only certain ranks of feature diff --git a/tests/features/api/search_simple.feature b/tests/features/api/search_simple.feature index 9c796e99..3e6b6e35 100644 --- a/tests/features/api/search_simple.feature +++ b/tests/features/api/search_simple.feature @@ -166,6 +166,13 @@ Feature: Simple Tests | attr | value | exclude_place_ids | 123,76,342565 + Scenario: Empty XML search with bad exluded place ids + Given the request parameters + | exclude_place_ids + | , + When sending xml search query "jghrleoxsbwjer" + Then result header has no attribute exclude_place_ids + Scenario Outline: Wrapping of legal jsonp search requests Given the request parameters | json_callback diff --git a/tests/steps/api_result.py b/tests/steps/api_result.py index d83aa83d..369127d8 100644 --- a/tests/steps/api_result.py +++ b/tests/steps/api_result.py @@ -143,6 +143,11 @@ def api_result_header_contains(step): assert_in(line['attr'], world.result_header) m = re.match("%s$" % (line['value'],), world.result_header[line['attr']]) +@step(u'result header has no attribute (.*)') +def api_result_header_contains_not(step, attr): + step.given('the result is valid') + assert_not_in(attr, world.result_header) + @step(u'results contain$') def api_result_contains(step): step.given('at least 1 result is returned') -- 2.45.2