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>2019-09-04 02:26:13 +0300
committerGitHub <noreply@github.com>2019-09-04 02:26:13 +0300
commitdf3e73a54336e6435f757a55bf8e0840ee4bc94e (patch)
tree62b18a52bc42f2c632d4ed4386a5c3faa767439b /tests/PHPUnit/Integration
parente84f89fd7207fbb5eac7782e0e1affa0a48b3462 (diff)
fix build failing tracker request test (#14850)
Diffstat (limited to 'tests/PHPUnit/Integration')
-rw-r--r--tests/PHPUnit/Integration/Tracker/RequestTest.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/PHPUnit/Integration/Tracker/RequestTest.php b/tests/PHPUnit/Integration/Tracker/RequestTest.php
index ca7167ea92..b8cef753a6 100644
--- a/tests/PHPUnit/Integration/Tracker/RequestTest.php
+++ b/tests/PHPUnit/Integration/Tracker/RequestTest.php
@@ -32,6 +32,8 @@ class RequestTest extends IntegrationTestCase
*/
private $request;
+ private $time;
+
public function setUp()
{
parent::setUp();
@@ -45,6 +47,50 @@ class RequestTest extends IntegrationTestCase
Cache::deleteTrackerCache();
$this->request = $this->buildRequest(array('idsite' => '1'));
+ $this->time = 1416795617;
+ }
+
+ /**
+ * @expectedException \Exception
+ * @expectedExceptionMessage Custom timestamp is 86500 seconds old
+ */
+ public function test_cdt_ShouldNotTrackTheRequest_IfNotAuthenticatedAndTimestampIsNotRecent()
+ {
+ $request = $this->buildRequest(array('cdt' => '' . $this->time - 86500));
+ $request->setCurrentTimestamp($this->time);
+ $this->assertSame($this->time, $request->getCurrentTimestamp());
+ }
+
+ public function test_cdt_ShouldReturnTheCustomTimestamp_IfNotAuthenticatedButTimestampIsRecent()
+ {
+ $request = $this->buildRequest(array('cdt' => '' . ($this->time - 5)));
+ $request->setCurrentTimestamp($this->time);
+
+ $this->assertSame('' . ($this->time - 5), $request->getCurrentTimestamp());
+ }
+
+ public function test_cdt_ShouldReturnTheCustomTimestamp_IfAuthenticatedAndValid()
+ {
+ $request = $this->buildRequest(array('cdt' => '' . ($this->time - 86500)));
+ $request->setCurrentTimestamp($this->time);
+ $request->setIsAuthenticated();
+ $this->assertSame('' . ($this->time - 86500), $request->getCurrentTimestamp());
+ }
+
+ public function test_cdt_ShouldReturnTheCustomTimestamp_IfTimestampIsInFuture()
+ {
+ $request = $this->buildRequest(array('cdt' => '' . ($this->time + 30800)));
+ $request->setCurrentTimestamp($this->time);
+ $this->assertSame($this->time, $request->getCurrentTimestamp());
+ }
+
+ public function test_cdt_ShouldReturnTheCustomTimestamp_ShouldUseStrToTime_IfItIsNotATime()
+ {
+ $request = $this->buildRequest(array('cdt' => '5 years ago'));
+ $request->setCurrentTimestamp($this->time);
+ $request->setIsAuthenticated();
+ $this->assertNotSame($this->time, $request->getCurrentTimestamp());
+ $this->assertNotEmpty($request->getCurrentTimestamp());
}
public function test_getIdSite()