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:
authordiosmosis <diosmosis@users.noreply.github.com>2020-11-04 10:19:48 +0300
committerGitHub <noreply@github.com>2020-11-04 10:19:48 +0300
commit375dd9f6933dcf7eeb37df9d2d9f44d16f35a277 (patch)
tree135baa9b8f9f2b2758ab9adf899d4026b8a91218 /plugins/SegmentEditor/tests
parent6b12f37eb630d25dffa13e315b894abda80ed5af (diff)
several changes to emphasize setup and use of auto-archiving rather than real-time processing (#16603)
* several changes to emphasize setup and use of auto-archiving rather than real-time processing * apply some pr feedback * Applying more pr feedback. * apply review fixes * ignore ability to archive segments in real time * another tweak * update tests * fix another test * fix ui tests * update test * fix evolution icon bug * Update TreemapVisualization and update expected screenshots * update screenshots
Diffstat (limited to 'plugins/SegmentEditor/tests')
-rw-r--r--plugins/SegmentEditor/tests/Integration/ApiTest.php3
-rw-r--r--plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php24
-rw-r--r--plugins/SegmentEditor/tests/Integration/SegmentQueryDecoratorTest.php5
-rw-r--r--plugins/SegmentEditor/tests/System/UnprocessedSegmentsTest.php26
4 files changed, 36 insertions, 22 deletions
diff --git a/plugins/SegmentEditor/tests/Integration/ApiTest.php b/plugins/SegmentEditor/tests/Integration/ApiTest.php
index 88bef59bad..13e0fd3357 100644
--- a/plugins/SegmentEditor/tests/Integration/ApiTest.php
+++ b/plugins/SegmentEditor/tests/Integration/ApiTest.php
@@ -8,6 +8,7 @@
namespace Piwik\Plugins\SegmentEditor\tests\Integration;
+use Piwik\ArchiveProcessor\Rules;
use Piwik\Plugins\SegmentEditor\API;
use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\Mock\FakeAccess;
@@ -152,6 +153,7 @@ class ApiTest extends IntegrationTestCase
*/
protected function createSegments()
{
+ Rules::setBrowserTriggerArchiving(false);
$this->setAdminUser();
$this->api->add('segment 1', 'visitCount<2', $idSite = 1, $autoArchive = true, $enableAllUsers = false);
$this->api->add('segment 2', 'countryCode==fr', $idSite = 2, $autoArchive = false, $enableAllUsers = false);
@@ -170,6 +172,7 @@ class ApiTest extends IntegrationTestCase
$this->setAnotherSuperUser();
$this->api->add('segment 9', 'countryCode!=fr', $idSite = false, $autoArchive = false, $enableAllUsers = true);
+ Rules::setBrowserTriggerArchiving(true);
}
diff --git a/plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php b/plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php
index 07e2152739..95ed3c12bb 100644
--- a/plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php
+++ b/plugins/SegmentEditor/tests/Integration/SegmentEditorTest.php
@@ -8,6 +8,7 @@
namespace Piwik\Plugins\SegmentEditor\tests\Integration;
+use Piwik\ArchiveProcessor\Rules;
use Piwik\Date;
use Piwik\Piwik;
use Piwik\Plugins\SegmentEditor\API;
@@ -47,16 +48,13 @@ class SegmentEditorTest extends IntegrationTestCase
*/
public function testAddInvalidSegment_ShouldThrow()
{
- try {
- API::getInstance()->add('name', 'test==test2');
- $this->fail("Exception not raised.");
- } catch (Exception $expected) {
- }
- try {
- API::getInstance()->add('name', 'test');
- $this->fail("Exception not raised.");
- } catch (Exception $expected) {
- }
+ $this->expectException(\Exception::class);
+
+ API::getInstance()->add('name', 'test==test2');
+ $this->fail("Exception not raised.");
+
+ API::getInstance()->add('name', 'test');
+ $this->fail("Exception not raised.");
}
/**
@@ -90,6 +88,8 @@ class SegmentEditorTest extends IntegrationTestCase
*/
public function test_AddAndGet_AnotherSegment()
{
+ Rules::setBrowserTriggerArchiving(false);
+
$name = 'name';
$definition = 'searches>1,visitIp!=127.0.0.1';
$idSegment = API::getInstance()->add($name, $definition, $idSite = 1, $autoArchive = 1, $enabledAllUsers = 1);
@@ -135,6 +135,8 @@ class SegmentEditorTest extends IntegrationTestCase
*/
public function test_UpdateSegment()
{
+ Rules::setBrowserTriggerArchiving(false);
+
$name = 'name"';
$definition = 'searches>1,visitIp!=127.0.0.1';
$nameSegment1 = 'hello';
@@ -179,6 +181,8 @@ class SegmentEditorTest extends IntegrationTestCase
*/
public function test_deleteSegment()
{
+ Rules::setBrowserTriggerArchiving(false);
+
$idSegment1 = API::getInstance()->add('name 1', 'searches==0', $idSite = 1, $autoArchive = 1, $enabledAllUsers = 1);
$idSegment2 = API::getInstance()->add('name 2', 'searches>1,visitIp!=127.0.0.1', $idSite = 1, $autoArchive = 1, $enabledAllUsers = 1);
diff --git a/plugins/SegmentEditor/tests/Integration/SegmentQueryDecoratorTest.php b/plugins/SegmentEditor/tests/Integration/SegmentQueryDecoratorTest.php
index e9d18a63fd..7cf0c46de3 100644
--- a/plugins/SegmentEditor/tests/Integration/SegmentQueryDecoratorTest.php
+++ b/plugins/SegmentEditor/tests/Integration/SegmentQueryDecoratorTest.php
@@ -8,6 +8,7 @@
namespace Piwik\Plugins\SegmentEditor\tests\Integration;
+use Piwik\ArchiveProcessor\Rules;
use Piwik\Plugins\SegmentEditor\API;
use Piwik\Plugins\SegmentEditor\SegmentQueryDecorator;
use Piwik\Segment;
@@ -36,6 +37,8 @@ class SegmentQueryDecoratorTest extends IntegrationTestCase
$this->segmentQueryDecorator = self::$fixture->piwikEnvironment->getContainer()->get(
'Piwik\Plugins\SegmentEditor\SegmentQueryDecorator');
+ Rules::setBrowserTriggerArchiving(false);
+
/** @var API $segmentEditorApi */
$segmentEditorApi = self::$fixture->piwikEnvironment->getContainer()->get(
'Piwik\Plugins\SegmentEditor\API');
@@ -47,6 +50,8 @@ class SegmentQueryDecoratorTest extends IntegrationTestCase
// test that segments w/ auto archive == false are included
$segmentEditorApi->add('segment 5', 'visitCount<2', 3, $autoArchive = false);
$segmentEditorApi->add('segment 6', 'countryCode!=fr', 3, $autoArchive = false);
+
+ Rules::setBrowserTriggerArchiving(true);
}
/**
diff --git a/plugins/SegmentEditor/tests/System/UnprocessedSegmentsTest.php b/plugins/SegmentEditor/tests/System/UnprocessedSegmentsTest.php
index ebb5656e5f..0d0f78c3c4 100644
--- a/plugins/SegmentEditor/tests/System/UnprocessedSegmentsTest.php
+++ b/plugins/SegmentEditor/tests/System/UnprocessedSegmentsTest.php
@@ -69,13 +69,13 @@ class UnprocessedSegmentsTest extends IntegrationTestCase
public function test_apiOutput_whenUnprocessedAutoArchiveSegmentUsed_WithBrowserArchivingDisabled()
{
+ Rules::setBrowserTriggerArchiving(false);
+
$idSegment = API::getInstance()->add('testsegment', self::TEST_SEGMENT, self::$fixture->idSite, $autoArchive = true);
$storedSegment = API::getInstance()->get($idSegment);
$this->assertNotEmpty($storedSegment);
- Rules::setBrowserTriggerArchiving(false);
-
$segments = Rules::getSegmentsToProcess([self::$fixture->idSite]);
self::assertTrue(in_array(self::TEST_SEGMENT, $segments));
@@ -89,13 +89,13 @@ class UnprocessedSegmentsTest extends IntegrationTestCase
public function test_apiOutput_whenUnprocessedAutoArchiveSegmentUsed_WithBrowserArchivingDisabled_AndEncodedSegment()
{
+ Rules::setBrowserTriggerArchiving(false);
+
$idSegment = API::getInstance()->add('testsegment', self::TEST_SEGMENT, self::$fixture->idSite, $autoArchive = true);
$storedSegment = API::getInstance()->get($idSegment);
$this->assertNotEmpty($storedSegment);
- Rules::setBrowserTriggerArchiving(false);
-
$segments = Rules::getSegmentsToProcess([self::$fixture->idSite]);
self::assertTrue(in_array(self::TEST_SEGMENT, $segments));
@@ -109,14 +109,16 @@ class UnprocessedSegmentsTest extends IntegrationTestCase
public function test_apiOutput_whenPreprocessedSegmentUsed_WithBrowserArchivingDisabled()
{
+ Rules::setBrowserTriggerArchiving(false);
+
$idSegment = API::getInstance()->add('testsegment', self::TEST_SEGMENT, self::$fixture->idSite, $autoArchive = true);
$storedSegment = API::getInstance()->get($idSegment);
$this->assertNotEmpty($storedSegment);
+ Rules::setBrowserTriggerArchiving(true);
VisitsSummary\API::getInstance()->get(self::$fixture->idSite, 'week',
- Date::factory(self::$fixture->dateTime)->toString(), self::TEST_SEGMENT); // archive
-
+ Date::factory(self::$fixture->dateTime)->toString(), self::TEST_SEGMENT); // archive (make sure there's data for actual test)
Rules::setBrowserTriggerArchiving(false);
$segments = Rules::getSegmentsToProcess([self::$fixture->idSite]);
@@ -152,6 +154,8 @@ class UnprocessedSegmentsTest extends IntegrationTestCase
{
$this->clearLogData();
+ Rules::setBrowserTriggerArchiving(false);
+
$idSegment = API::getInstance()->add('testsegment', self::TEST_SEGMENT, self::$fixture->idSite, $autoArchive = true);
$storedSegment = API::getInstance()->get($idSegment);
@@ -160,8 +164,6 @@ class UnprocessedSegmentsTest extends IntegrationTestCase
VisitsSummary\API::getInstance()->get(self::$fixture->idSite, 'week',
Date::factory(self::$fixture->dateTime)->toString(), self::TEST_SEGMENT); // archive
- Rules::setBrowserTriggerArchiving(false);
-
$segments = Rules::getSegmentsToProcess([self::$fixture->idSite]);
self::assertTrue(in_array(self::TEST_SEGMENT, $segments));
@@ -177,13 +179,13 @@ class UnprocessedSegmentsTest extends IntegrationTestCase
{
$this->clearLogData();
+ Rules::setBrowserTriggerArchiving(false);
+
$idSegment = API::getInstance()->add('testsegment', self::TEST_SEGMENT, self::$fixture->idSite, $autoArchive = true);
$storedSegment = API::getInstance()->get($idSegment);
$this->assertNotEmpty($storedSegment);
- Rules::setBrowserTriggerArchiving(false);
-
$segments = Rules::getSegmentsToProcess([self::$fixture->idSite]);
self::assertTrue(in_array(self::TEST_SEGMENT, $segments));
@@ -197,13 +199,13 @@ class UnprocessedSegmentsTest extends IntegrationTestCase
public function test_apiOutput_whenMultipleSitesRequested_OneWithDataOneNot_AndBrowserArchivingDisabled()
{
+ Rules::setBrowserTriggerArchiving(false);
+
$idSegment = API::getInstance()->add('testsegment', self::TEST_SEGMENT, $idSite = false, $autoArchive = true);
$storedSegment = API::getInstance()->get($idSegment);
$this->assertNotEmpty($storedSegment);
- Rules::setBrowserTriggerArchiving(false);
-
$segments = Rules::getSegmentsToProcess([self::$fixture->idSite]);
self::assertTrue(in_array(self::TEST_SEGMENT, $segments));