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-10-02 03:20:20 +0300
committerGitHub <noreply@github.com>2020-10-02 03:20:20 +0300
commit2807e94baaa9b545f27a55a7dd071ba187799491 (patch)
tree9fa5722fe414e7f1e664d4226b2620d215fd1987 /tests/PHPUnit/Unit
parent06d43857c48ada2fa7f1ad18a8309e8826c0e413 (diff)
JS Offline tracking (#15970)
* JS Offline tracking * minor tweaks * add some tests * add some tests * apply review feedback
Diffstat (limited to 'tests/PHPUnit/Unit')
-rw-r--r--tests/PHPUnit/Unit/Tracker/RequestTest.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/PHPUnit/Unit/Tracker/RequestTest.php b/tests/PHPUnit/Unit/Tracker/RequestTest.php
index c934565a28..4a0aeaaed4 100644
--- a/tests/PHPUnit/Unit/Tracker/RequestTest.php
+++ b/tests/PHPUnit/Unit/Tracker/RequestTest.php
@@ -48,6 +48,44 @@ class RequestTest extends UnitTestCase
$this->assertSame($this->time, $request->getCurrentTimestamp());
}
+ public function test_getCurrentTimestamp_ShouldReturnTheCurrentTimestamp_IfRelativeOffsetIsUsed()
+ {
+ $request = $this->buildRequest(array('cdo' => '10'));
+ $this->assertSame($this->time - 10, $request->getCurrentTimestamp());
+ }
+
+ public function test_getCurrentTimestamp_ShouldReturnTheCurrentTimestamp_IfRelativeOffsetIsUsedIsTooMuchInPastShouldReturnFalseWhenNotAuthenticated()
+ {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Custom timestamp is 99990 seconds old, requires &token_auth');
+ $request = $this->buildRequest(array('cdo' => '99990'));
+ $this->assertSame($this->time - 10, $request->getCurrentTimestamp());
+ }
+
+ public function test_getCurrentTimestamp_CanUseRelativeOffsetAndCustomTimestamp()
+ {
+ $time = time() - 20;
+ $request = $this->buildRequest(array('cdo' => '10', 'cdt' => $time));
+ $request->setCurrentTimestamp(time());
+ $this->assertSame($time - 10, $request->getCurrentTimestamp());
+ }
+
+ public function test_getCurrentTimestamp_CanUseNegativeRelativeOffsetAndCustomTimestamp()
+ {
+ $time = time() - 20;
+ $request = $this->buildRequest(array('cdo' => '-10', 'cdt' => $time));
+ $request->setCurrentTimestamp(time());
+ $this->assertSame($time - 10, $request->getCurrentTimestamp());
+ }
+
+ public function test_getCurrentTimestamp_WithCustomTimestamp()
+ {
+ $time = time() - 20;
+ $request = $this->buildRequest(array('cdt' => $time));
+ $request->setCurrentTimestamp(time());
+ $this->assertEquals($time, $request->getCurrentTimestamp());
+ }
+
public function test_isEmptyRequest_ShouldReturnTrue_InCaseNoParamsSet()
{
$request = $this->buildRequest(array());