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>2018-12-06 08:44:01 +0300
committerdiosmosis <diosmosis@users.noreply.github.com>2018-12-06 08:44:01 +0300
commit7b6a14626960795b0acdf4a064cd3982d7704f2b (patch)
tree1f8b5fc7d7869c77e91a1f8dc2ab592b3f8de4ca /tests/PHPUnit/Unit
parent1fe8a6ee582c2f61dc209b7df856695378007c23 (diff)
Report tracking into wrong Site ID and missing token auth (#13493)
* log tracking failures * added page * tweak UI * use a db column instead of option table to simplify code * add system summary, notifiy super users by email, fixes, update, ... * more fixes, needs tests next * add widget for tracking failures * ensure to not log any failure when visit is excluded * some tests and fixes * added tests * added missing test * apply review feedback * fix tests * trying to fix test * fix tests * fix update names * fix tests * Fix another test.
Diffstat (limited to 'tests/PHPUnit/Unit')
-rw-r--r--tests/PHPUnit/Unit/Tracker/RequestSetTest.php26
-rw-r--r--tests/PHPUnit/Unit/Tracker/RequestTest.php78
2 files changed, 12 insertions, 92 deletions
diff --git a/tests/PHPUnit/Unit/Tracker/RequestSetTest.php b/tests/PHPUnit/Unit/Tracker/RequestSetTest.php
index 94e58a28d1..871582c915 100644
--- a/tests/PHPUnit/Unit/Tracker/RequestSetTest.php
+++ b/tests/PHPUnit/Unit/Tracker/RequestSetTest.php
@@ -398,32 +398,6 @@ class RequestSetTest extends \PHPUnit_Framework_TestCase
unset($_POST['redirecturl']);
}
- public function test_getAllSiteIdsWithinRequest_ShouldReturnEmptyArray_IfNoRequestsSet()
- {
- $this->assertEquals(array(), $this->requestSet->getAllSiteIdsWithinRequest());
- }
-
- public function test_getAllSiteIdsWithinRequest_ShouldReturnTheSiteIds_FromRequests()
- {
- $this->requestSet->setRequests($this->buildRequests(3));
-
- $this->assertEquals(array(1, 2, 3), $this->requestSet->getAllSiteIdsWithinRequest());
- }
-
- public function test_getAllSiteIdsWithinRequest_ShouldReturnUniqueSiteIds_Unordered()
- {
- $this->requestSet->setRequests(array(
- $this->buildRequest(1),
- $this->buildRequest(5),
- $this->buildRequest(1),
- $this->buildRequest(2),
- $this->buildRequest(2),
- $this->buildRequest(9),
- ));
-
- $this->assertEquals(array(1, 5, 2, 9), $this->requestSet->getAllSiteIdsWithinRequest());
- }
-
/**
* @param int $numRequests
* @return Request[]
diff --git a/tests/PHPUnit/Unit/Tracker/RequestTest.php b/tests/PHPUnit/Unit/Tracker/RequestTest.php
index be05e8a1bf..5b125559f1 100644
--- a/tests/PHPUnit/Unit/Tracker/RequestTest.php
+++ b/tests/PHPUnit/Unit/Tracker/RequestTest.php
@@ -38,18 +38,6 @@ class RequestTest extends UnitTestCase
$this->request = $this->buildRequest(array('idsite' => '1'));
}
- public function test_getCurrentTimestamp_ShouldReturnTheSetTimestamp_IfNoCustomValueGiven()
- {
- $this->assertSame($this->time, $this->request->getCurrentTimestamp());
- }
-
- public function test_getCurrentTimestamp_ShouldReturnTheCurrentTimestamp_IfTimestampIsInvalid()
- {
- $request = $this->buildRequest(array('cdt' => '' . 5));
- $request->setIsAuthenticated();
- $this->assertSame($this->time, $request->getCurrentTimestamp());
- }
-
/**
* @expectedException \Exception
* @expectedExceptionMessage Custom timestamp is 86500 seconds old
@@ -88,6 +76,18 @@ class RequestTest extends UnitTestCase
$this->assertNotEmpty($request->getCurrentTimestamp());
}
+ public function test_getCurrentTimestamp_ShouldReturnTheSetTimestamp_IfNoCustomValueGiven()
+ {
+ $this->assertSame($this->time, $this->request->getCurrentTimestamp());
+ }
+
+ public function test_getCurrentTimestamp_ShouldReturnTheCurrentTimestamp_IfTimestampIsInvalid()
+ {
+ $request = $this->buildRequest(array('cdt' => '' . 5));
+ $request->setIsAuthenticated();
+ $this->assertSame($this->time, $request->getCurrentTimestamp());
+ }
+
public function test_isEmptyRequest_ShouldReturnTrue_InCaseNoParamsSet()
{
$request = $this->buildRequest(array());
@@ -494,60 +494,6 @@ class RequestTest extends UnitTestCase
$this->assertSame('00:00:00', $request->getLocalTime());
}
- public function test_getIdSite()
- {
- $request = $this->buildRequest(array('idsite' => '14'));
- $this->assertSame(14, $request->getIdSite());
- }
-
- /**
- * @expectedException \Piwik\Exception\UnexpectedWebsiteFoundException
- * @expectedExceptionMessage Invalid idSite: '0'
- */
- public function test_getIdSite_shouldThrowException_IfValueIsZero()
- {
- $request = $this->buildRequest(array('idsite' => '0'));
- $request->getIdSite();
- }
-
- /**
- * @expectedException \Piwik\Exception\UnexpectedWebsiteFoundException
- * @expectedExceptionMessage Invalid idSite: '-1'
- */
- public function test_getIdSite_shouldThrowException_IfValueIsLowerThanZero()
- {
- $request = $this->buildRequest(array('idsite' => '-1'));
- $request->getIdSite();
- }
-
- public function test_getIpString_ShouldDefaultToServerAddress()
- {
- $this->assertEquals($_SERVER['REMOTE_ADDR'], $this->request->getIpString());
- }
-
- /**
- * @expectedException \Piwik\Exception\InvalidRequestParameterException
- * @expectedException requires valid token_auth
- */
- public function test_getIpString_ShouldDefaultToServerAddress_IfCustomIpIsSetButNotAuthenticated()
- {
- $request = $this->buildRequest(array('cip' => '192.192.192.192'));
- $this->assertEquals($_SERVER['REMOTE_ADDR'], $request->getIpString());
- }
-
- public function test_getIpString_ShouldReturnCustomIp_IfAuthenticated()
- {
- $request = $this->buildRequest(array('cip' => '192.192.192.192'));
- $request->setIsAuthenticated();
- $this->assertEquals('192.192.192.192', $request->getIpString());
- }
-
- public function test_getIp()
- {
- $ip = $_SERVER['REMOTE_ADDR'];
- $this->assertEquals(IPUtils::stringToBinaryIP($ip), $this->request->getIp());
- }
-
public function test_getCookieName_ShouldReturnConfigValue()
{
$this->assertEquals('_pk_uid', $this->request->getCookieName());