Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2020-02-11 10:56:21 +0300
committerGitHub <noreply@github.com>2020-02-11 10:56:21 +0300
commit4f2292b7eb500ddaf1dd0440220647f645b3d289 (patch)
tree170aec95ec9602563c474a6ffadfa99b0f94afbc
parenta4d4e15c55197f71f4f38325c71ce41219cefb4b (diff)
Trigger exception when idgoal does not exist (#15551)
* trigger exception when idgoal does not exist * add test
-rw-r--r--core/Tracker/GoalManager.php3
-rw-r--r--tests/PHPUnit/System/TrackerResponseTest.php9
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');