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
path: root/tests
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2020-12-24 02:22:08 +0300
committerGitHub <noreply@github.com>2020-12-24 02:22:08 +0300
commitc9ce54d30ef1abd915bf6c069d577e4052575bd3 (patch)
tree9ed0c8e13426e2ae19c5dca94bc2d92b16a29966 /tests
parent1c2502b38aeeac68bce6fc411e683b2fd8e61a92 (diff)
Force new visit after 10K actions (#17014)
* Force new visit after 10K actions * add test * wording * fix ui test
Diffstat (limited to 'tests')
-rw-r--r--tests/PHPUnit/Integration/Tracker/VisitorRecognizerTest.php54
-rw-r--r--tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png4
2 files changed, 51 insertions, 7 deletions
diff --git a/tests/PHPUnit/Integration/Tracker/VisitorRecognizerTest.php b/tests/PHPUnit/Integration/Tracker/VisitorRecognizerTest.php
index 42ab0c07a4..20a45a1a4d 100644
--- a/tests/PHPUnit/Integration/Tracker/VisitorRecognizerTest.php
+++ b/tests/PHPUnit/Integration/Tracker/VisitorRecognizerTest.php
@@ -8,10 +8,15 @@
namespace Piwik\Tests\Integration\Tracker;
+use Matomo\Network\IP;
use Piwik\Common;
+use Piwik\Config;
+use Piwik\Date;
use Piwik\EventDispatcher;
+use Piwik\Tests\Framework\Fixture;
use Piwik\Tracker\Model;
use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
+use Piwik\Tracker\Request;
use Piwik\Tracker\Visit\VisitProperties;
use Piwik\Tracker\VisitorRecognizer;
@@ -30,15 +35,54 @@ class VisitorRecognizerTest extends IntegrationTestCase
parent::setUp();
$this->recognizer = new VisitorRecognizer(true, 1800, 24000,
new Model(), EventDispatcher::getInstance());
+
+ Fixture::createWebsite('2020-01-01 02:03:04');
}
- private function getVisitProperties()
+ public function test_findKnownVisitor_whenNotExceededMaxActionsLimitFindsVisitor()
{
- $visit = new VisitProperties();
- $visit->setProperty('idvisit', '321');
- $visit->setProperty('idvisitor', Common::hex2bin('1234567890234567'));
+ $this->assertNull($this->recognizer->getLastKnownVisit());
+
+ $configId = $this->createVisit(9999);
+ $visitor = $this->findKnownVisitor($configId);
+ $this->assertTrue($visitor);
+ $this->assertNotEmpty($this->recognizer->getLastKnownVisit());
+ }
+
+ private function findKnownVisitor($configId)
+ {
+ $visitProperties = new VisitProperties();
+ $request = new Request(['idsite' => 1, 'cid' => $configId, 'uid' => $configId]);
+
+ return $this->recognizer->findKnownVisitor($configId, $visitProperties, $request);
+ }
- return $visit;
+ private function createVisit($maxTotalActions)
+ {
+ $configId = '1234567812345678';
+ $request = new Request(['idsite' => 1, 'uid' => $configId]);
+ $model = new Model();
+ $model->createVisit(array(
+ 'config_id' => Common::hex2bin($configId),
+ 'idsite' => 1,
+ 'user_id' => $configId,
+ 'visit_total_time' => 1,
+ 'visit_total_actions' => $maxTotalActions,
+ 'visit_last_action_time' => Date::now()->getDatetime(),
+ 'visit_first_action_time' => Date::now()->getDatetime(),
+ 'idvisitor' => $request->getVisitorId(),
+ 'location_ip' => IP::fromStringIP('1.1.1.1')->toBinary()
+ ));
+
+ return $configId;
+ }
+
+ public function test_findKnownVisitor_whenExceededMaxActionsLimitFindsNotVisitor()
+ {
+ $configId = $this->createVisit(10000);
+ $visitor = $this->findKnownVisitor($configId);
+ $this->assertFalse($visitor);
+ $this->assertFalse($this->recognizer->getLastKnownVisit());
}
public function test_removeUnchangedValues_newVisit_shouldNotChangeAnything()
diff --git a/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png b/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png
index 38eadbd20d..00bd8d8879 100644
--- a/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png
+++ b/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:7880424f69eb61c03a65392301e90718a153ceab553957323bb5a2a2f24be153
-size 4571815
+oid sha256:02e058bca47f243c5eba0f4f57ff7848ba8b4c02123569918fa6e9c21c9231f0
+size 4598472