diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2020-02-11 10:56:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-11 10:56:21 +0300 |
commit | 4f2292b7eb500ddaf1dd0440220647f645b3d289 (patch) | |
tree | 170aec95ec9602563c474a6ffadfa99b0f94afbc | |
parent | a4d4e15c55197f71f4f38325c71ce41219cefb4b (diff) |
Trigger exception when idgoal does not exist (#15551)
* trigger exception when idgoal does not exist
* add test
-rw-r--r-- | core/Tracker/GoalManager.php | 3 | ||||
-rw-r--r-- | tests/PHPUnit/System/TrackerResponseTest.php | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/core/Tracker/GoalManager.php b/core/Tracker/GoalManager.php index d04344e55a..b0c230d8a8 100644 --- a/core/Tracker/GoalManager.php +++ b/core/Tracker/GoalManager.php @@ -18,6 +18,7 @@ use Piwik\Plugin\Dimension\ConversionDimension; use Piwik\Plugin\Dimension\VisitDimension; use Piwik\Plugins\CustomVariables\CustomVariables; use Piwik\Plugins\Events\Actions\ActionEvent; +use Piwik\Tracker; use Piwik\Tracker\Visit\VisitProperties; /** @@ -253,7 +254,7 @@ class GoalManager $goals = $this->getGoalDefinitions($idSite); if (!isset($goals[$idGoal])) { - return null; + throw new InvalidRequestParameterException('idGoal ' . $idGoal . ' does not exist'); } $goal = $goals[$idGoal]; diff --git a/tests/PHPUnit/System/TrackerResponseTest.php b/tests/PHPUnit/System/TrackerResponseTest.php index 35813e870c..629278bec0 100644 --- a/tests/PHPUnit/System/TrackerResponseTest.php +++ b/tests/PHPUnit/System/TrackerResponseTest.php @@ -85,6 +85,15 @@ class TrackerResponseTest extends SystemTestCase $this->assertEquals(400, $response['status']); } + public function test_response_ShouldSend400ResponseCode_IfIdGoalIsInvalid() + { + $url = $this->tracker->getUrlTrackPageView('Test'); + $url .= '&idgoal=9999'; + + $response = $this->sendHttpRequest($url); + $this->assertEquals(400, $response['status']); + } + public function test_response_ShouldSend400ResponseCode_IfSiteIdIsNegative() { $url = $this->tracker->getUrlTrackPageView('Test'); |