diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PHPUnit/Integration/Tracker/ActionTest.php | 15 | ||||
-rw-r--r-- | tests/PHPUnit/Unit/UrlHelperTest.php | 60 |
2 files changed, 75 insertions, 0 deletions
diff --git a/tests/PHPUnit/Integration/Tracker/ActionTest.php b/tests/PHPUnit/Integration/Tracker/ActionTest.php index 5eab999b66..724fe963a0 100644 --- a/tests/PHPUnit/Integration/Tracker/ActionTest.php +++ b/tests/PHPUnit/Integration/Tracker/ActionTest.php @@ -174,6 +174,21 @@ class ActionTest extends IntegrationTestCase } /** + * Testing with some website specific parameters excluded using regular expressions + * @dataProvider getTestUrls + */ + public function testExcludeQueryParametersRegExSiteExcluded($url, $filteredUrl) + { + $excludedQueryParameters = '/p[4|2]/, /^var.*/'; + $this->setUpRootAccess(); + $idSite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0, + $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, + $excludedIps = '', $excludedQueryParameters, $timezone = null, $currency = null, + $group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1); + $this->assertEquals($filteredUrl[1], PageUrl::excludeQueryParametersFromUrl($url, $idSite)); + } + + /** * Testing with some website specific and some global excluded query parameters * @dataProvider getTestUrls */ diff --git a/tests/PHPUnit/Unit/UrlHelperTest.php b/tests/PHPUnit/Unit/UrlHelperTest.php index 09aab2c2f3..369cfb3a34 100644 --- a/tests/PHPUnit/Unit/UrlHelperTest.php +++ b/tests/PHPUnit/Unit/UrlHelperTest.php @@ -234,4 +234,64 @@ class UrlHelperTest extends \PHPUnit_Framework_TestCase $this->assertEquals('add=foo', UrlHelper::getQueryFromUrl('/', array('add' => 'foo'))); $this->assertEquals('add[]=foo&add[]=test', UrlHelper::getQueryFromUrl('/', array('add' => array('foo', 'test')))); } + + + /** + * Dataprovider for testGetQueryStringWithExcludedParameters + */ + public function getQueryParameters() + { + return array( + array( + 'p1=v1&p2=v2', //expected + array('p1'=>'v1', 'p2'=>'v2'), //queryParameters + array() //parametersToExclude + ), + array( + 'p2=v2', + array('p1'=>'v1', 'p2'=>'v2'), + array('p1') + ), + array( + 'p1=v1&p2=v2', + array('p1'=>'v1', 'p2'=>'v2', 'sessionId'=>'HHSJHERTG'), + array('sessionId') + ), + array( + 'p1=v1&p2=v2', + array('p1'=>'v1', 'p2'=>'v2', 'sessionId'=>'HHSJHERTG'), + array('/session/') + ), + array( + 'p1=v1&p2=v2', + array('p1'=>'v1', 'sessionId'=>'HHSJHERTG', 'p2'=>'v2', 'token'=>'RYUN36HSAO'), + array('/[session|token]/') + ), + array( + '', + array('p1'=>'v1', 'p2'=>'v2', 'sessionId'=>'HHSJHERTG', 'token'=>'RYUN36HSAO'), + array('/.*/') + ), + array( + 'p2=v2&p4=v4', + array('p1'=>'v1', 'p2'=>'v2', 'p3'=>'v3', 'p4'=>'v4'), + array('/p[1|3]/') + ), + array( + 'p2=v2&p4=v4', + array('p1'=>'v1', 'p2'=>'v2', 'p3'=>'v3', 'p4'=>'v4', 'utm_source'=>'gekko', 'utm_medium'=>'email', 'utm_campaign'=>'daily'), + array('/p[1|3]/', '/utm_/') + ) + ); + } + + /** + * @dataProvider getQueryParameters + * @group Core + */ + public function testGetQueryStringWithExcludedParameters($expected, $queryParameters, $parametersToExclude) + { + $this->assertEquals($expected, UrlHelper::getQueryStringWithExcludedParameters($queryParameters, $parametersToExclude)); + } + } |