diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php | 32 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/CronArchive/SegmentArchivingTest.php | 30 |
2 files changed, 45 insertions, 17 deletions
diff --git a/tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php b/tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php index 677498b18e..7e2dedc857 100644 --- a/tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php +++ b/tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php @@ -12,6 +12,7 @@ namespace Piwik\Tests\Integration\CronArchive; use Piwik\ArchiveProcessor\Rules; use Piwik\CliMulti\RequestParser; use Piwik\Common; +use Piwik\Plugins\CustomDimensions; use Piwik\Container\StaticContainer; use Piwik\CronArchive; use Piwik\CronArchive\FixedSiteIds; @@ -38,8 +39,10 @@ class QueueConsumerTest extends IntegrationTestCase Fixture::createWebsite('2020-04-06'); Fixture::createWebsite('2010-04-06'); + CustomDimensions\API::getInstance()->configureNewCustomDimension(1, 'custom 1', 'visit', true); + Rules::setBrowserTriggerArchiving(false); - API::getInstance()->add('testegment', 'browserCode==IE', false, true); + API::getInstance()->add('testegment', 'browserCode==IE;dimension1==val', 1, true); API::getInstance()->add('testegment2', 'browserCode==ff', false); Rules::setBrowserTriggerArchiving(true); @@ -66,7 +69,7 @@ class QueueConsumerTest extends IntegrationTestCase $archiveFilter ); - $segmentHash = (new Segment('browserCode==IE', [1]))->getHash(); + $segmentHash = (new Segment('browserCode==IE;dimension1==val', [1]))->getHash(); $segmentHash2 = (new Segment('browserCode==ff', [1]))->getHash(); $invalidations = [ @@ -92,6 +95,7 @@ class QueueConsumerTest extends IntegrationTestCase ['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => 1, 'report' => null], ['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => 3, 'report' => null], ['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => 2, 'report' => null], + ['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 2, 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => 2, 'report' => null], ['idarchive' => 1, 'name' => 'done' . $segmentHash2, 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => 2, 'report' => null], // invalid plugin @@ -177,10 +181,10 @@ class QueueConsumerTest extends IntegrationTestCase 'date1' => '2018-03-08', 'date2' => '2018-03-08', 'period' => '1', - 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', + 'name' => 'donec3afbf588c35606b9cd9ecd1ac781428', 'report' => NULL, 'plugin' => NULL, - 'segment' => 'browserCode==IE', + 'segment' => 'browserCode==IE;dimension1==val', ), array ( 'idarchive' => '1', @@ -188,10 +192,10 @@ class QueueConsumerTest extends IntegrationTestCase 'date1' => '2018-03-07', 'date2' => '2018-03-07', 'period' => '1', - 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', + 'name' => 'donec3afbf588c35606b9cd9ecd1ac781428', 'report' => NULL, 'plugin' => NULL, - 'segment' => 'browserCode==IE', + 'segment' => 'browserCode==IE;dimension1==val', ), array ( 'idarchive' => '1', @@ -212,10 +216,10 @@ class QueueConsumerTest extends IntegrationTestCase 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => '1', - 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', + 'name' => 'donec3afbf588c35606b9cd9ecd1ac781428', 'report' => NULL, 'plugin' => NULL, - 'segment' => 'browserCode==IE', + 'segment' => 'browserCode==IE;dimension1==val', ), array ( 'idarchive' => '1', @@ -236,10 +240,10 @@ class QueueConsumerTest extends IntegrationTestCase 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => '1', - 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', + 'name' => 'donec3afbf588c35606b9cd9ecd1ac781428', 'report' => NULL, 'plugin' => NULL, - 'segment' => 'browserCode==IE', + 'segment' => 'browserCode==IE;dimension1==val', ), ), array ( @@ -275,10 +279,10 @@ class QueueConsumerTest extends IntegrationTestCase 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => '2', - 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', + 'name' => 'donec3afbf588c35606b9cd9ecd1ac781428', 'report' => NULL, 'plugin' => NULL, - 'segment' => 'browserCode==IE', + 'segment' => 'browserCode==IE;dimension1==val', ), ), array ( @@ -314,10 +318,10 @@ class QueueConsumerTest extends IntegrationTestCase 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => '3', - 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', + 'name' => 'donec3afbf588c35606b9cd9ecd1ac781428', 'report' => NULL, 'plugin' => NULL, - 'segment' => 'browserCode==IE', + 'segment' => 'browserCode==IE;dimension1==val', ), ), array ( // end of idsite=1 diff --git a/tests/PHPUnit/Integration/CronArchive/SegmentArchivingTest.php b/tests/PHPUnit/Integration/CronArchive/SegmentArchivingTest.php index 0e579caa90..2eb1790980 100644 --- a/tests/PHPUnit/Integration/CronArchive/SegmentArchivingTest.php +++ b/tests/PHPUnit/Integration/CronArchive/SegmentArchivingTest.php @@ -6,7 +6,7 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -namespace Piwik\Tests\Unit\CronArchive; +namespace Piwik\Tests\Integration\CronArchive; use Piwik\Config; use Piwik\CronArchive; @@ -14,6 +14,7 @@ use Piwik\Date; use Piwik\CronArchive\SegmentArchiving; use Piwik\Option; use Piwik\Site; +use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; /** @@ -80,6 +81,14 @@ class SegmentArchivingTest extends IntegrationTestCase ), array( + 'ts_created' => '2012-01-01', + 'definition' => 'countryCode==br', + 'enable_only_idsite' => 2, + 'ts_last_edit' => '2011-01-01', + 'auto_archive' => 1, + ), + + array( 'ts_created' => '2011-01-01', 'definition' => 'countryCode==ca', 'enable_only_idsite' => 0, @@ -201,6 +210,21 @@ class SegmentArchivingTest extends IntegrationTestCase ], ], ], + + [ + 'segment_last_edit_time', + 2, + [ + [ + 'date' => '2014-01-01 00:00:00', + 'segment' => 'countryCode==ca', + ], + [ + 'date' => '2012-01-01 00:00:00', + 'segment' => 'countryCode==br', + ], + ], + ], ]; } @@ -274,10 +298,10 @@ class SegmentArchivingTest extends IntegrationTestCase $this->assertEquals($expected, $segments); } - private function createUrlProviderToTest($processNewSegmentsFrom) + private function createUrlProviderToTest($processNewSegmentsFrom, $mockData = null) { $mockSegmentEditorModel = $this->createPartialMock('Piwik\Plugins\SegmentEditor\Model', array('getAllSegmentsAndIgnoreVisibility')); - $mockSegmentEditorModel->expects($this->any())->method('getAllSegmentsAndIgnoreVisibility')->will($this->returnValue($this->mockSegmentEntries)); + $mockSegmentEditorModel->expects($this->any())->method('getAllSegmentsAndIgnoreVisibility')->will($this->returnValue($mockData ?: $this->mockSegmentEntries)); return new SegmentArchiving($processNewSegmentsFrom, $beginningOfTimeLastN = 7, $mockSegmentEditorModel, null, Date::factory(self::TEST_NOW)); } |