From 5311faf590b7fed27a60a88c6e55b4a184b4cc73 Mon Sep 17 00:00:00 2001 From: sgiehl Date: Fri, 19 Jul 2024 10:59:11 +0200 Subject: [PATCH] use period constants --- .../CronArchive/QueueConsumerTest.php | 274 +++++++++--------- .../Integration/DataAccess/ModelTest.php | 211 +++++++------- 2 files changed, 247 insertions(+), 238 deletions(-) diff --git a/tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php b/tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php index 7193b4a8b869..8cb0719ca5b9 100644 --- a/tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php +++ b/tests/PHPUnit/Integration/CronArchive/QueueConsumerTest.php @@ -13,7 +13,11 @@ use Piwik\CliMulti\RequestParser; use Piwik\Common; use Piwik\Config; +use Piwik\Period\Day; use Piwik\Period\Factory; +use Piwik\Period\Month; +use Piwik\Period\Week; +use Piwik\Period\Year; use Piwik\Plugins\CustomDimensions; use Piwik\Container\StaticContainer; use Piwik\CronArchive; @@ -68,10 +72,10 @@ public function testConsumerIgnoresPeriodsThatHaveBeenDisabledInApi() ); $invalidations = [ - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => 1, 'report' => null], - ['idarchive' => 2, 'name' => 'done', 'idsite' => 2, 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => 2, 'report' => null], - ['idarchive' => 3, 'name' => 'done', 'idsite' => 3, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => 3, 'report' => null], - ['idarchive' => 4, 'name' => 'done', 'idsite' => 4, 'date1' => '2018-01-01', 'date2' => '2018-12-31', 'period' => 4, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 2, 'name' => 'done', 'idsite' => 2, 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => Week::PERIOD_ID, 'report' => null], + ['idarchive' => 3, 'name' => 'done', 'idsite' => 3, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => Month::PERIOD_ID, 'report' => null], + ['idarchive' => 4, 'name' => 'done', 'idsite' => 4, 'date1' => '2018-01-01', 'date2' => '2018-12-31', 'period' => Year::PERIOD_ID, 'report' => null], ]; $this->insertInvalidations($invalidations); @@ -176,51 +180,51 @@ public function testInvalidateConsumeOrder() $segmentHash2 = (new Segment('browserCode==ff', [1]))->getHash(); $invalidations = [ - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => 1, 'report' => null], - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-07', 'date2' => '2018-03-07', 'period' => 1, 'report' => null], - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-08', 'date2' => '2018-03-08', 'period' => 1, 'report' => null], - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => 1, 'report' => null], - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => 3, 'report' => null], // intersecting period - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => 2, 'report' => null], // intersecting period + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-07', 'date2' => '2018-03-07', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-08', 'date2' => '2018-03-08', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => Month::PERIOD_ID, 'report' => null], // intersecting period + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => Week::PERIOD_ID, 'report' => null], // intersecting period - ['idarchive' => 1, 'name' => 'done.Actions', 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => 1, 'report' => 'testReport'], // intersecting period - ['idarchive' => 1, 'name' => 'done.Actions', 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => 3, 'report' => 'testReport'], // intersecting period - ['idarchive' => 1, 'name' => 'done.Actions', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => 2, 'report' => 'testReport'], // intersecting period + ['idarchive' => 1, 'name' => 'done.Actions', 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => Day::PERIOD_ID, 'report' => 'testReport'], // intersecting period + ['idarchive' => 1, 'name' => 'done.Actions', 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => Month::PERIOD_ID, 'report' => 'testReport'], // intersecting period + ['idarchive' => 1, 'name' => 'done.Actions', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => Week::PERIOD_ID, 'report' => 'testReport'], // intersecting period // some or all subperiods before site was created - ['idarchive' => 1, 'name' => 'done', 'idsite' => 2, 'date1' => '2020-04-04', 'date2' => '2020-04-04', 'period' => 1, 'report' => 'testReport'], - ['idarchive' => 1, 'name' => 'done', 'idsite' => 2, 'date1' => '2020-03-30', 'date2' => '2020-04-05', 'period' => 2, 'report' => 'testReport'], // intersecting period + ['idarchive' => 1, 'name' => 'done', 'idsite' => 2, 'date1' => '2020-04-04', 'date2' => '2020-04-04', 'period' => Day::PERIOD_ID, 'report' => 'testReport'], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 2, 'date1' => '2020-03-30', 'date2' => '2020-04-05', 'period' => Week::PERIOD_ID, 'report' => 'testReport'], // intersecting period // segments are skipped due to insersecting period with all visits - ['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => 1, 'report' => null], - ['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2018-03-07', 'date2' => '2018-03-07', 'period' => 1, 'report' => null], - ['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2018-03-08', 'date2' => '2018-03-08', 'period' => 1, 'report' => null], - ['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' . $segmentHash, 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2018-03-07', 'date2' => '2018-03-07', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2018-03-08', 'date2' => '2018-03-08', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => Month::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => Week::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done' . $segmentHash, 'idsite' => 2, 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => Week::PERIOD_ID, 'report' => null], // removed as segment not configured to auto archive - ['idarchive' => 1, 'name' => 'done' . $segmentHash2, 'idsite' => 1, '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' => Week::PERIOD_ID, 'report' => null], // removed as invalid plugin - ['idarchive' => 1, 'name' => 'done.MyPlugin', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => 2, 'report' => 'testReport'], + ['idarchive' => 1, 'name' => 'done.MyPlugin', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-11', 'period' => Week::PERIOD_ID, 'report' => 'testReport'], // removed as duplicates - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => 1, 'report' => null], - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => 1, 'report' => null], - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => 1, 'report' => null], - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => 1, 'report' => null], - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => 1, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-06', 'date2' => '2018-03-06', 'period' => Day::PERIOD_ID, 'report' => null], // dupliactes not removed as skipped due to intersecting period - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => 3, 'report' => null], - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => 3, 'report' => null], - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => 3, 'report' => null], - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => 3, 'report' => null], - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => 3, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => Month::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => Month::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => Month::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => Month::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => Month::PERIOD_ID, 'report' => null], // high ts_invalidated, should not be selected - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-01-01', 'date2' => '2018-01-31', 'period' => 3, 'report' => null, 'ts_invalidated' => Date::factory(time() + 300)->getDatetime()], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-01-01', 'date2' => '2018-01-31', 'period' => Month::PERIOD_ID, 'report' => null, 'ts_invalidated' => Date::factory(time() + 300)->getDatetime()], ]; shuffle($invalidations); @@ -485,15 +489,15 @@ public function testPluginInvalidationDeletedIfUsableArchiveExists() Date::$now = strtotime('2018-03-04 01:00:00'); $invalidations = [ - ['idarchive' => 1, 'name' => "done.Actions", 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => 1, 'report' => null], - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => 3, 'report' => null], + ['idarchive' => 1, 'name' => "done.Actions", 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => Month::PERIOD_ID, 'report' => null], ]; shuffle($invalidations); $this->insertInvalidations($invalidations); - $usableArchive = ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => 1, 'ts_archived' => Date::now()->getDatetime(), 'value' => 3.0]; + $usableArchive = ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => Day::PERIOD_ID, 'ts_archived' => Date::now()->getDatetime(), 'value' => 3.0]; $this->insertArchive($usableArchive); $iteratedInvalidations = []; @@ -567,12 +571,12 @@ public function testSkipSegmentsToday() $segmentHash2 = (new Segment('browserCode==FF', [1]))->getHash(); $invalidations = [ - ['idarchive' => 1, 'name' => 'done' . $segmentHash1, 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => 1, 'report' => null], - ['idarchive' => 1, 'name' => 'done' . $segmentHash2, 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => 1, 'report' => null], - ['idarchive' => 1, 'name' => 'done' . $segmentHash1, 'idsite' => 1, 'date1' => '2018-03-03', 'date2' => '2018-03-03', 'period' => 1, 'report' => null], - ['idarchive' => 1, 'name' => 'done' . $segmentHash2 . '.ExamplePlugin', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => 1, 'report' => null], - ['idarchive' => 1, 'name' => 'done' . $segmentHash1, 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => 3, 'report' => null], - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => 1, 'report' => null], + ['idarchive' => 1, 'name' => 'done' . $segmentHash1, 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done' . $segmentHash2, 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done' . $segmentHash1, 'idsite' => 1, 'date1' => '2018-03-03', 'date2' => '2018-03-03', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done' . $segmentHash2 . '.ExamplePlugin', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done' . $segmentHash1, 'idsite' => 1, 'date1' => '2018-03-01', 'date2' => '2018-03-31', 'period' => Month::PERIOD_ID, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2018-03-04', 'date2' => '2018-03-04', 'period' => Day::PERIOD_ID, 'report' => null], ]; shuffle($invalidations); @@ -682,9 +686,9 @@ public function testMaxWebsitesToProcess() $this->assertEquals(1, $queueConsumer->setMaxSitesToProcess(1)); $invalidations = [ - ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2021-11-16', 'date2' => '2021-11-16', 'period' => 1, 'report' => null], - ['idarchive' => 2, 'name' => 'done', 'idsite' => 2, 'date1' => '2021-11-16', 'date2' => '2021-11-16', 'period' => 2, 'report' => null], - ['idarchive' => 3, 'name' => 'done', 'idsite' => 3, 'date1' => '2021-11-16', 'date2' => '2021-11-16', 'period' => 3, 'report' => null], + ['idarchive' => 1, 'name' => 'done', 'idsite' => 1, 'date1' => '2021-11-16', 'date2' => '2021-11-16', 'period' => Day::PERIOD_ID, 'report' => null], + ['idarchive' => 2, 'name' => 'done', 'idsite' => 2, 'date1' => '2021-11-16', 'date2' => '2021-11-16', 'period' => Week::PERIOD_ID, 'report' => null], + ['idarchive' => 3, 'name' => 'done', 'idsite' => 3, 'date1' => '2021-11-16', 'date2' => '2021-11-16', 'period' => Month::PERIOD_ID, 'report' => null], ]; $this->insertInvalidations($invalidations); @@ -824,7 +828,7 @@ public function testCanSkipArchiveBecauseNoPointReturnsTrueIfDateRangeHasNoVisit $invalidation = [ 'idsite' => 1, - 'period' => 1, + 'period' => Day::PERIOD_ID, 'date1' => '2020-04-05', 'date2' => '2020-04-05', 'name' => 'done', @@ -853,7 +857,7 @@ public function testCanSkipArchiveBecauseNoPointReturnsFalseIfDateRangeHasVisits $invalidation = [ 'idsite' => 1, - 'period' => 1, + 'period' => Day::PERIOD_ID, 'date1' => '2020-03-05', 'date2' => '2020-03-05', 'name' => 'done', @@ -882,7 +886,7 @@ public function testUsableArchiveExistsReturnsTrueIfDateRangeHasVisitsAndPeriodI $invalidation = [ 'idsite' => 1, - 'period' => 2, + 'period' => Week::PERIOD_ID, 'date1' => '2020-03-30', 'date2' => '2020-04-05', 'name' => 'done', @@ -920,7 +924,7 @@ public function testUsableArchiveExistsReturnsTrueIfDateRangeHasVisitsAndPeriodI $invalidation = [ 'idsite' => 1, - 'period' => 2, + 'period' => Week::PERIOD_ID, 'date1' => '2020-03-30', 'date2' => '2020-04-05', 'name' => 'done' . $segmentHash . '.ExamplePlugin', @@ -957,7 +961,7 @@ public function testCanSkipArchiveBecauseNoPointReturnsFalseIfDateRangeHasVisits $invalidation = [ 'idsite' => 1, - 'period' => 2, + 'period' => Week::PERIOD_ID, 'date1' => '2020-03-30', 'date2' => '2020-04-05', 'name' => 'done', @@ -995,7 +999,7 @@ public function testCanSkipArchiveBecauseNoPointReturnsTrueSegmentArchivingForPl $invalidation = [ 'idsite' => 1, - 'period' => 2, + 'period' => Week::PERIOD_ID, 'date1' => '2020-03-30', 'date2' => '2020-04-05', 'name' => 'done' . $segmentHash . '.ExamplePlugin', @@ -1045,53 +1049,53 @@ public function getTestDataForHasIntersectingPeriod() // no intersecting periods [ [ - ['period' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04'], - ['period' => 3, 'date1' => '2020-04-01', 'date2' => '2020-04-30'], - ['period' => 1, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==abc'], + ['period' => Day::PERIOD_ID, 'date1' => '2020-03-04', 'date2' => '2020-03-04'], + ['period' => Month::PERIOD_ID, 'date1' => '2020-04-01', 'date2' => '2020-04-30'], + ['period' => Day::PERIOD_ID, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==abc'], ], - ['period' => 1, 'date1' => '2020-03-05', 'date2' => '2020-03-05'], + ['period' => Day::PERIOD_ID, 'date1' => '2020-03-05', 'date2' => '2020-03-05'], false, ], // intersecting periods [ [ - ['period' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04'], - ['period' => 3, 'date1' => '2020-04-01', 'date2' => '2020-04-30'], - ['period' => 1, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==abc'], + ['period' => Day::PERIOD_ID, 'date1' => '2020-03-04', 'date2' => '2020-03-04'], + ['period' => Month::PERIOD_ID, 'date1' => '2020-04-01', 'date2' => '2020-04-30'], + ['period' => Day::PERIOD_ID, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==abc'], ], - ['period' => 2, 'date1' => '2020-03-02', 'date2' => '2020-03-08'], + ['period' => Week::PERIOD_ID, 'date1' => '2020-03-02', 'date2' => '2020-03-08'], true, ], // all same period, different segments [ [ - ['period' => 1, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==def'], - ['period' => 1, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==ghi'], - ['period' => 1, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==abc'], + ['period' => Day::PERIOD_ID, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==def'], + ['period' => Day::PERIOD_ID, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==ghi'], + ['period' => Day::PERIOD_ID, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==abc'], ], - ['period' => 1, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==lmn'], + ['period' => Day::PERIOD_ID, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==lmn'], false, ], // all same period, all visits in one [ [ - ['period' => 1, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => ''], + ['period' => Day::PERIOD_ID, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => ''], ], - ['period' => 1, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==lmn'], + ['period' => Day::PERIOD_ID, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==lmn'], true, ], // all same period, different segments, all visits in next [ [ - ['period' => 1, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==def'], - ['period' => 1, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==ghi'], - ['period' => 1, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==abc'], + ['period' => Day::PERIOD_ID, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==def'], + ['period' => Day::PERIOD_ID, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==ghi'], + ['period' => Day::PERIOD_ID, 'date1' => '2020-03-15', 'date2' => '2020-03-15', 'segment' => 'pageUrl==abc'], ], - ['period' => 1, 'date1' => '2020-03-15', 'date2' => '2020-03-15'], + ['period' => Day::PERIOD_ID, 'date1' => '2020-03-15', 'date2' => '2020-03-15'], true, ], ]; @@ -1127,258 +1131,258 @@ public function getTestDataForShouldSkipArchiveBecauseLowerPeriodOrSegmentIsInPr { yield 'different period and different idSite should not be detected as intersecting' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 3, 'date1' => '2022-03-04', 'date2' => '2022-03-04', 'period' => 1], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 3, 'date1' => '2022-03-04', 'date2' => '2022-03-04', 'period' => Day::PERIOD_ID], 'expected' => null ]; yield 'same period, but different idSite should not be detected as intersecting' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 3, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 3, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID], 'expected' => null ]; yield 'same day period should be detected as intersecting' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID], 'expected' => 'lower or same period in progress (period = day, date = 2020-03-04)' ]; yield 'week period should be detected as intersecting when day is processed' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => 2], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => Week::PERIOD_ID], 'expected' => 'lower or same period in progress (period = day, date = 2020-03-04)' ]; yield 'month period should be detected as intersecting when day is processed' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => 3], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => Month::PERIOD_ID], 'expected' => 'lower or same period in progress (period = day, date = 2020-03-04)' ]; yield 'year period should be detected as intersecting when day is processed' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-01-01', 'date2' => '2020-12-31', 'period' => 4], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-01-01', 'date2' => '2020-12-31', 'period' => Year::PERIOD_ID], 'expected' => 'lower or same period in progress (period = day, date = 2020-03-04)' ]; yield 'same week period should be detected as intersecting' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => 2, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => Week::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => 2], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => Week::PERIOD_ID], 'expected' => 'lower or same period in progress (period = week, date = 2020-03-02)' ]; yield 'day period should not be detected as intersecting when week is processed' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => 2, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => Week::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID], 'expected' => null ]; yield 'month period should be detected as intersecting when week is processed' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => 2, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => Week::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => 3], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => Month::PERIOD_ID], 'expected' => 'lower or same period in progress (period = week, date = 2020-03-02)' ]; yield 'year period should be detected as intersecting when week is processed' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => 2, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => Week::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-01-01', 'date2' => '2020-12-31', 'period' => 4], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-01-01', 'date2' => '2020-12-31', 'period' => Year::PERIOD_ID], 'expected' => 'lower or same period in progress (period = week, date = 2020-03-02)' ]; yield 'same month period should be detected as intersecting' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => 3, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => Month::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => 3], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => Month::PERIOD_ID], 'expected' => 'lower or same period in progress (period = month, date = 2020-03-01)' ]; yield 'day period should not be detected as intersecting when month is processed' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => 3, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => Month::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID], 'expected' => null ]; yield 'week period should not be detected as intersecting when month is processed' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => 3, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => Month::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => 2], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => Week::PERIOD_ID], 'expected' => null ]; yield 'year period should be detected as intersecting when month is processed' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => 3, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => Month::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-01-01', 'date2' => '2020-12-31', 'period' => 4], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-01-01', 'date2' => '2020-12-31', 'period' => Year::PERIOD_ID], 'expected' => 'lower or same period in progress (period = month, date = 2020-03-01)' ]; yield 'same year period should be detected as intersecting' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-01-01', 'date2' => '2020-12-31', 'period' => 4, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-01-01', 'date2' => '2020-12-31', 'period' => Year::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-01-01', 'date2' => '2020-12-31', 'period' => 4], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-01-01', 'date2' => '2020-12-31', 'period' => Year::PERIOD_ID], 'expected' => 'lower or same period in progress (period = year, date = 2020-01-01)' ]; yield 'day period should not be detected as intersecting when year is processed' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-01-01', 'date2' => '2020-12-31', 'period' => 4, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-01-01', 'date2' => '2020-12-31', 'period' => Year::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID], 'expected' => null ]; yield 'week period should not be detected as intersecting when year is processed' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-01-01', 'date2' => '2020-12-31', 'period' => 4, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-01-01', 'date2' => '2020-12-31', 'period' => Year::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => 2], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => Week::PERIOD_ID], 'expected' => null ]; yield 'month period should be detected as intersecting when year is processed' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => 3, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => Month::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-01-01', 'date2' => '2020-12-31', 'period' => 4], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 5, 'date1' => '2020-01-01', 'date2' => '2020-12-31', 'period' => Year::PERIOD_ID], 'expected' => 'lower or same period in progress (period = month, date = 2020-03-01)' ]; yield 'plugin and normal invalidation for same day period should be detected as intersecting' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done.Actions', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1], + 'archiveToProcess' => ['name' => 'done.Actions', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID], 'expected' => 'lower or same period in progress (period = day, date = 2020-03-04)' ]; // @todo is this needed? yield 'different plugin invalidations for same day period should be detected as intersecting' => [ 'existingInvalidations' => [ - ['name' => 'done.VisitsSummary', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done.VisitsSummary', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done.Actions', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1], + 'archiveToProcess' => ['name' => 'done.Actions', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID], 'expected' => 'lower or same period in progress (period = day, date = 2020-03-04)' ]; yield 'week period should be detected as intersecting when day is processed for a segment' => [ 'existingInvalidations' => [ - ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => 2, 'segment' => 'browserCode==IE'], + 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => Week::PERIOD_ID, 'segment' => 'browserCode==IE'], 'expected' => 'lower or same period in progress (period = day, date = 2020-03-04)' ]; yield 'plugin archive should be detected as intersecting when lower period is processed for a segment' => [ 'existingInvalidations' => [ - ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 5, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc.Actions', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => 2, 'segment' => 'browserCode==IE'], + 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc.Actions', 'idsite' => 5, 'date1' => '2020-03-02', 'date2' => '2020-03-08', 'period' => Week::PERIOD_ID, 'segment' => 'browserCode==IE'], 'expected' => 'lower or same period in progress (period = day, date = 2020-03-04)' ]; yield 'segment archiving during "all visits" archiving should be detected as intersecting with same period' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'segment' => 'browserCode==IE'], + 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'segment' => 'browserCode==IE'], 'expected' => 'all visits archive in progress for same site with lower or same period (period = day, date = 2020-03-04)' ]; yield 'segment archiving for plugin during "all visits" archiving should be detected as intersecting with same period' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc.VisitsSummary', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'segment' => 'browserCode==IE'], + 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc.VisitsSummary', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'segment' => 'browserCode==IE'], 'expected' => 'all visits archive in progress for same site with lower or same period (period = day, date = 2020-03-04)' ]; yield 'segment archiving during "all visits" plugin archiving should be detected as intersecting with same period' => [ 'existingInvalidations' => [ - ['name' => 'done.VisitsSummary', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done.VisitsSummary', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'segment' => 'browserCode==IE'], + 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'segment' => 'browserCode==IE'], 'expected' => 'all visits archive in progress for same site with lower or same period (period = day, date = 2020-03-04)' ]; yield 'segment archiving for plugin during "all visits" plugin archiving should be detected as intersecting with same period' => [ 'existingInvalidations' => [ - ['name' => 'done.VisitsSummary', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done.VisitsSummary', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc.Actions', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'segment' => 'browserCode==IE'], + 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc.Actions', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'segment' => 'browserCode==IE'], 'expected' => 'all visits archive in progress for same site with lower or same period (period = day, date = 2020-03-04)' ]; yield 'segment archiving during "all visits" archiving should be detected as intersecting with lower period' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 1, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => 3, 'segment' => 'browserCode==IE'], + 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 1, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => Month::PERIOD_ID, 'segment' => 'browserCode==IE'], 'expected' => 'all visits archive in progress for same site with lower or same period (period = day, date = 2020-03-04)' ]; yield 'segment archiving during "all visits" archiving not should be detected as intersecting with different periods' => [ 'existingInvalidations' => [ - ['name' => 'done', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 1, 'date1' => '2020-04-01', 'date2' => '2020-04-30', 'period' => 3, 'segment' => 'browserCode==IE'], + 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 1, 'date1' => '2020-04-01', 'date2' => '2020-04-30', 'period' => Month::PERIOD_ID, 'segment' => 'browserCode==IE'], 'expected' => null ]; yield '"all visits" archiving, while running a segment should be detected as intersecting' => [ 'existingInvalidations' => [ - ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID], 'expected' => 'segment archive in progress for same site with lower or same period (browserCode==IE, period = day, date = 2020-03-04)' ]; yield '"all visits" plugin archiving, while running a segment should be detected as intersecting' => [ 'existingInvalidations' => [ - ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done.VisitsSummary', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1], + 'archiveToProcess' => ['name' => 'done.VisitsSummary', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID], 'expected' => 'segment archive in progress for same site with lower or same period (browserCode==IE, period = day, date = 2020-03-04)' ]; yield '"all visits" archiving with bigger period, while running a segment should be detected as intersecting' => [ 'existingInvalidations' => [ - ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done', 'idsite' => 1, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => 3], + 'archiveToProcess' => ['name' => 'done', 'idsite' => 1, 'date1' => '2020-03-01', 'date2' => '2020-03-31', 'period' => Month::PERIOD_ID], 'expected' => 'segment archive in progress for same site with lower or same period (browserCode==IE, period = day, date = 2020-03-04)' ]; yield 'same period, but different segments archiving should not be detected as intersecting' => [ 'existingInvalidations' => [ - ['name' => 'done3736b708e4d20cfc10610e816a1b2341', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], + ['name' => 'done3736b708e4d20cfc10610e816a1b2341', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'status' => 1, 'ts_started' => date('Y-m-d H:i:s')], ], - 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => 1, 'segment' => 'browserCode==IE'], + 'archiveToProcess' => ['name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc', 'idsite' => 1, 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'period' => Day::PERIOD_ID, 'segment' => 'browserCode==IE'], 'expected' => null ]; } diff --git a/tests/PHPUnit/Integration/DataAccess/ModelTest.php b/tests/PHPUnit/Integration/DataAccess/ModelTest.php index d2932e03e131..8ac1e674a9e0 100644 --- a/tests/PHPUnit/Integration/DataAccess/ModelTest.php +++ b/tests/PHPUnit/Integration/DataAccess/ModelTest.php @@ -14,7 +14,12 @@ use Piwik\DataAccess\ArchiveWriter; use Piwik\Date; use Piwik\Db; +use Piwik\Period\Day; use Piwik\Period\Factory; +use Piwik\Period\Month; +use Piwik\Period\Range; +use Piwik\Period\Week; +use Piwik\Period\Year; use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; use Piwik\DataAccess\Model; @@ -44,27 +49,27 @@ public function testGetInvalidatedArchiveIdsSafeToDeleteHandlesCutOffGroupMaxLen Db::get()->query('SET SESSION group_concat_max_len=32'); $this->insertArchiveData([ - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_OK], ]); // sanity check @@ -86,11 +91,11 @@ public function testResetFailedArchivingJobsUpdatesCorrectStatuses() Date::$now = strtotime('2020-03-03 04:00:00'); $this->insertInvalidations([ - ['idsite' => 1, 'date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => 1, 'status' => 1, 'ts_invalidated' => '2020-03-01 00:00:00', 'ts_started' => '2020-03-02 03:00:00'], - ['idsite' => 2, 'date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done.Plugin', 'value' => 2, 'status' => 0, 'ts_invalidated' => '2020-03-01 00:00:00', 'ts_started' => '2020-03-02 03:00:00'], - ['idsite' => 1, 'date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'doneblablah', 'value' => 3, 'status' => 0, 'ts_invalidated' => '2020-03-01 00:00:00', 'ts_started' => '2020-03-03 00:00:00'], - ['idsite' => 3, 'date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'donebluhbluh', 'value' => 4, 'status' => 1, 'ts_invalidated' => '2020-03-01 00:00:00', 'ts_started' => '2020-03-02 12:00:00'], - ['idsite' => 1, 'date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'donedone', 'value' => 5, 'status' => 1, 'ts_invalidated' => '2020-03-01 00:00:00', 'ts_started' => '2020-03-01 03:00:00'], + ['idsite' => 1, 'date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => 1, 'status' => 1, 'ts_invalidated' => '2020-03-01 00:00:00', 'ts_started' => '2020-03-02 03:00:00'], + ['idsite' => 2, 'date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done.Plugin', 'value' => 2, 'status' => 0, 'ts_invalidated' => '2020-03-01 00:00:00', 'ts_started' => '2020-03-02 03:00:00'], + ['idsite' => 1, 'date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'doneblablah', 'value' => 3, 'status' => 0, 'ts_invalidated' => '2020-03-01 00:00:00', 'ts_started' => '2020-03-03 00:00:00'], + ['idsite' => 3, 'date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'donebluhbluh', 'value' => 4, 'status' => 1, 'ts_invalidated' => '2020-03-01 00:00:00', 'ts_started' => '2020-03-02 12:00:00'], + ['idsite' => 1, 'date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'donedone', 'value' => 5, 'status' => 1, 'ts_invalidated' => '2020-03-01 00:00:00', 'ts_started' => '2020-03-01 03:00:00'], ]); $this->model->resetFailedArchivingJobs(); @@ -128,7 +133,7 @@ private function assertAllocatedArchiveId($expectedId) public function testGetAndUpdateArchiveStatus() { $this->insertArchiveData([ - ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => 1, 'name' => 'done', 'value' => ArchiveWriter::DONE_ERROR], + ['date1' => '2020-02-03', 'date2' => '2020-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => ArchiveWriter::DONE_ERROR], ]); $numericTable = ArchiveTableCreator::getNumericTable(Date::factory('2020-02-03')); @@ -162,7 +167,7 @@ public function testHasInvalidationForPeriodAndNameReturnsTrueIfExists() { $date = '2021-03-23'; $this->insertInvalidations([ - ['date1' => $date, 'date2' => $date, 'period' => 1, 'name' => 'done'], + ['date1' => $date, 'date2' => $date, 'period' => Day::PERIOD_ID, 'name' => 'done'], ]); $periodObj = Factory::build('day', $date); @@ -174,7 +179,7 @@ public function testHasInvalidationForPeriodAndNameReturnsTrueIfExistsForReport( { $date = '2021-03-23'; $this->insertInvalidations([ - ['date1' => $date, 'date2' => $date, 'period' => 1, 'name' => 'done', 'report' => 'myReport'], + ['date1' => $date, 'date2' => $date, 'period' => Day::PERIOD_ID, 'name' => 'done', 'report' => 'myReport'], ]); $periodObj = Factory::build('day', $date); @@ -186,7 +191,7 @@ public function testHasInvalidationForPeriodAndNameReturnsFalseIfNotExistsForRep { $date = '2021-03-23'; $this->insertInvalidations([ - ['date1' => $date, 'date2' => $date, 'period' => 1, 'name' => 'done', 'report' => 'myReport'], + ['date1' => $date, 'date2' => $date, 'period' => Day::PERIOD_ID, 'name' => 'done', 'report' => 'myReport'], ]); $periodObj = Factory::build('day', $date); @@ -199,7 +204,7 @@ public function testHasInvalidationForPeriodAndNameReturnsFalseIfNotExists() $date = '2021-03-23'; $date2 = '2021-03-22'; $this->insertInvalidations([ - ['date1' => $date, 'date2' => $date, 'period' => 1, 'name' => 'done'], + ['date1' => $date, 'date2' => $date, 'period' => Day::PERIOD_ID, 'name' => 'done'], ]); $periodObj = Factory::build('day', $date2); @@ -213,7 +218,7 @@ public function getTestDataForHasChildArchivesInPeriod() // day period, no child [ [ - ['date1' => '2015-02-01', 'date2' => '2015-02-28', 'period' => 3, 'name' => 'done', 'value' => 1], + ['date1' => '2015-02-01', 'date2' => '2015-02-28', 'period' => Month::PERIOD_ID, 'name' => 'done', 'value' => 1], ], 1, '2015-02-03', @@ -224,7 +229,7 @@ public function getTestDataForHasChildArchivesInPeriod() // week period, no child [ [ - ['date1' => '2015-02-01', 'date2' => '2015-02-28', 'period' => 3, 'name' => 'done', 'value' => 1], + ['date1' => '2015-02-01', 'date2' => '2015-02-28', 'period' => Month::PERIOD_ID, 'name' => 'done', 'value' => 1], ], 1, '2015-02-03', @@ -235,8 +240,8 @@ public function getTestDataForHasChildArchivesInPeriod() // month period, no child [ [ - ['date1' => '2015-01-31', 'date2' => '2015-01-31', 'period' => 1, 'name' => 'done', 'value' => 1], - ['date1' => '2015-01-01', 'date2' => '2015-12-31', 'period' => 4, 'name' => 'done', 'value' => 1], + ['date1' => '2015-01-31', 'date2' => '2015-01-31', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => 1], + ['date1' => '2015-01-01', 'date2' => '2015-12-31', 'period' => Year::PERIOD_ID, 'name' => 'done', 'value' => 1], ], 1, '2015-02-04', @@ -256,8 +261,8 @@ public function getTestDataForHasChildArchivesInPeriod() // week period, w/ child [ [ - ['date1' => '2015-02-01', 'date2' => '2015-02-28', 'period' => 3, 'name' => 'done', 'value' => 1], - ['date1' => '2015-01-31', 'date2' => '2015-01-31', 'period' => 1, 'name' => 'done', 'value' => 1], + ['date1' => '2015-02-01', 'date2' => '2015-02-28', 'period' => Month::PERIOD_ID, 'name' => 'done', 'value' => 1], + ['date1' => '2015-01-31', 'date2' => '2015-01-31', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => 1], ], 1, '2015-02-01', @@ -266,8 +271,8 @@ public function getTestDataForHasChildArchivesInPeriod() ], [ [ - ['date1' => '2015-02-01', 'date2' => '2015-02-28', 'period' => 3, 'name' => 'done', 'value' => 1], - ['date1' => '2015-02-11', 'date2' => '2015-02-11', 'period' => 1, 'name' => 'done', 'value' => 1], + ['date1' => '2015-02-01', 'date2' => '2015-02-28', 'period' => Month::PERIOD_ID, 'name' => 'done', 'value' => 1], + ['date1' => '2015-02-11', 'date2' => '2015-02-11', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => 1], ], 1, '2015-02-10', @@ -278,7 +283,7 @@ public function getTestDataForHasChildArchivesInPeriod() // month period, w/ child [ [ - ['date1' => '2015-02-09', 'date2' => '2015-02-15', 'period' => 2, 'name' => 'done', 'value' => 1], + ['date1' => '2015-02-09', 'date2' => '2015-02-15', 'period' => Week::PERIOD_ID, 'name' => 'done', 'value' => 1], ], 1, '2015-02-10', @@ -287,7 +292,7 @@ public function getTestDataForHasChildArchivesInPeriod() ], [ [ - ['date1' => '2015-02-09', 'date2' => '2015-02-09', 'period' => 2, 'name' => 'done', 'value' => 1], + ['date1' => '2015-02-09', 'date2' => '2015-02-09', 'period' => Week::PERIOD_ID, 'name' => 'done', 'value' => 1], ], 1, '2015-02-10', @@ -296,7 +301,7 @@ public function getTestDataForHasChildArchivesInPeriod() ], [ [ - ['date1' => '2015-02-01', 'date2' => '2015-02-01', 'period' => 2, 'name' => 'done', 'value' => 1], + ['date1' => '2015-02-01', 'date2' => '2015-02-01', 'period' => Week::PERIOD_ID, 'name' => 'done', 'value' => 1], ], 1, '2015-02-10', @@ -307,7 +312,7 @@ public function getTestDataForHasChildArchivesInPeriod() // year period, w/ child [ [ - ['date1' => '2015-02-01', 'date2' => '2015-02-28', 'period' => 3, 'name' => 'done', 'value' => 1], + ['date1' => '2015-02-01', 'date2' => '2015-02-28', 'period' => Month::PERIOD_ID, 'name' => 'done', 'value' => 1], ], 1, '2015-02-04', @@ -316,7 +321,7 @@ public function getTestDataForHasChildArchivesInPeriod() ], [ [ - ['date1' => '2015-04-01', 'date2' => '2015-04-01', 'period' => 1, 'name' => 'done', 'value' => 1], + ['date1' => '2015-04-01', 'date2' => '2015-04-01', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => 1], ], 1, '2015-02-04', @@ -325,7 +330,7 @@ public function getTestDataForHasChildArchivesInPeriod() ], [ [ - ['date1' => '2015-04-01', 'date2' => '2015-04-01', 'period' => 1, 'name' => 'done', 'value' => 4], + ['date1' => '2015-04-01', 'date2' => '2015-04-01', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => 4], ], 1, '2015-02-04', @@ -334,8 +339,8 @@ public function getTestDataForHasChildArchivesInPeriod() ], [ [ - ['date1' => '2015-04-01', 'date2' => '2015-04-01', 'period' => 1, 'name' => 'done', 'value' => 5], - ['date1' => '2014-04-01', 'date2' => '2014-04-01', 'period' => 1, 'name' => 'done', 'value' => 1], + ['date1' => '2015-04-01', 'date2' => '2015-04-01', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => 5], + ['date1' => '2014-04-01', 'date2' => '2014-04-01', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => 1], ], 1, '2015-02-04', @@ -346,7 +351,7 @@ public function getTestDataForHasChildArchivesInPeriod() // range period w/ day child [ [ - ['date1' => '2015-04-01', 'date2' => '2015-04-01', 'period' => 1, 'name' => 'done', 'value' => 1], + ['date1' => '2015-04-01', 'date2' => '2015-04-01', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => 1], ], 1, '2015-03-30,2015-04-05', @@ -355,7 +360,7 @@ public function getTestDataForHasChildArchivesInPeriod() ], [ [ - ['date1' => '2015-04-01', 'date2' => '2015-04-01', 'period' => 1, 'name' => 'done', 'value' => 1], + ['date1' => '2015-04-01', 'date2' => '2015-04-01', 'period' => Day::PERIOD_ID, 'name' => 'done', 'value' => 1], ], 1, '2015-04-01,2015-04-05', @@ -368,28 +373,28 @@ public function getTestDataForHasChildArchivesInPeriod() public function testGetNextInvalidatedArchiveReturnsCorrectOrder() { $this->insertInvalidations([ - ['date1' => '2015-03-30', 'date2' => '2015-03-30', 'period' => 1, 'name' => 'done' . md5('testsegment8')], - ['date1' => '2015-04-01', 'date2' => '2015-04-01', 'period' => 1, 'name' => 'done'], - ['date1' => '2015-04-02', 'date2' => '2015-04-02', 'period' => 1, 'name' => 'done' . md5('testsegment1')], - ['date1' => '2015-01-01', 'date2' => '2015-12-31', 'period' => 4, 'name' => 'done'], - ['date1' => '2015-04-06', 'date2' => '2015-04-12', 'period' => 2, 'name' => 'done' . md5('testsegment3')], - ['date1' => '2015-03-29', 'date2' => '2015-03-29', 'period' => 1, 'name' => 'done'], - ['date1' => '2015-03-30', 'date2' => '2015-03-30', 'period' => 1, 'name' => 'done'], - ['date1' => '2015-04-04', 'date2' => '2015-04-04', 'period' => 1, 'name' => 'done'], - ['date1' => '2015-03-29', 'date2' => '2015-03-29', 'period' => 1, 'name' => 'done' . md5('testsegment2')], - ['date1' => '2015-04-01', 'date2' => '2015-04-30', 'period' => 3, 'name' => 'done'], - ['date1' => '2015-04-15', 'date2' => '2015-04-24', 'period' => 5, 'name' => 'done'], - ['date1' => '2015-04-06', 'date2' => '2015-04-06', 'period' => 1, 'name' => 'done'], - ['date1' => '2015-04-06', 'date2' => '2015-04-06', 'period' => 1, 'name' => 'done' . md5('testsegment3')], - ['date1' => '2015-04-03', 'date2' => '2015-04-03', 'period' => 1, 'name' => 'done'], - ['date1' => '2015-04-05', 'date2' => '2015-04-05', 'period' => 1, 'name' => 'done'], - ['date1' => '2015-03-30', 'date2' => '2015-04-05', 'period' => 2, 'name' => 'done'], - ['date1' => '2015-04-01', 'date2' => '2015-04-30', 'period' => 3, 'name' => 'done' . md5('testsegment1')], - ['date1' => '2015-03-01', 'date2' => '2015-03-24', 'period' => 1, 'name' => 'done'], - ['date1' => '2015-04-06', 'date2' => '2015-04-12', 'period' => 2, 'name' => 'done'], - ['date1' => '2015-04-02', 'date2' => '2015-04-02', 'period' => 1, 'name' => 'done'], - ['date1' => '2015-03-01', 'date2' => '2015-03-31', 'period' => 3, 'name' => 'done'], - ['date1' => '2015-03-31', 'date2' => '2015-03-31', 'period' => 1, 'name' => 'done'], + ['date1' => '2015-03-30', 'date2' => '2015-03-30', 'period' => Day::PERIOD_ID, 'name' => 'done' . md5('testsegment8')], + ['date1' => '2015-04-01', 'date2' => '2015-04-01', 'period' => Day::PERIOD_ID, 'name' => 'done'], + ['date1' => '2015-04-02', 'date2' => '2015-04-02', 'period' => Day::PERIOD_ID, 'name' => 'done' . md5('testsegment1')], + ['date1' => '2015-01-01', 'date2' => '2015-12-31', 'period' => Year::PERIOD_ID, 'name' => 'done'], + ['date1' => '2015-04-06', 'date2' => '2015-04-12', 'period' => Week::PERIOD_ID, 'name' => 'done' . md5('testsegment3')], + ['date1' => '2015-03-29', 'date2' => '2015-03-29', 'period' => Day::PERIOD_ID, 'name' => 'done'], + ['date1' => '2015-03-30', 'date2' => '2015-03-30', 'period' => Day::PERIOD_ID, 'name' => 'done'], + ['date1' => '2015-04-04', 'date2' => '2015-04-04', 'period' => Day::PERIOD_ID, 'name' => 'done'], + ['date1' => '2015-03-29', 'date2' => '2015-03-29', 'period' => Day::PERIOD_ID, 'name' => 'done' . md5('testsegment2')], + ['date1' => '2015-04-01', 'date2' => '2015-04-30', 'period' => Month::PERIOD_ID, 'name' => 'done'], + ['date1' => '2015-04-15', 'date2' => '2015-04-24', 'period' => Range::PERIOD_ID, 'name' => 'done'], + ['date1' => '2015-04-06', 'date2' => '2015-04-06', 'period' => Day::PERIOD_ID, 'name' => 'done'], + ['date1' => '2015-04-06', 'date2' => '2015-04-06', 'period' => Day::PERIOD_ID, 'name' => 'done' . md5('testsegment3')], + ['date1' => '2015-04-03', 'date2' => '2015-04-03', 'period' => Day::PERIOD_ID, 'name' => 'done'], + ['date1' => '2015-04-05', 'date2' => '2015-04-05', 'period' => Day::PERIOD_ID, 'name' => 'done'], + ['date1' => '2015-03-30', 'date2' => '2015-04-05', 'period' => Week::PERIOD_ID, 'name' => 'done'], + ['date1' => '2015-04-01', 'date2' => '2015-04-30', 'period' => Month::PERIOD_ID, 'name' => 'done' . md5('testsegment1')], + ['date1' => '2015-03-01', 'date2' => '2015-03-24', 'period' => Day::PERIOD_ID, 'name' => 'done'], + ['date1' => '2015-04-06', 'date2' => '2015-04-12', 'period' => Week::PERIOD_ID, 'name' => 'done'], + ['date1' => '2015-04-02', 'date2' => '2015-04-02', 'period' => Day::PERIOD_ID, 'name' => 'done'], + ['date1' => '2015-03-01', 'date2' => '2015-03-31', 'period' => Month::PERIOD_ID, 'name' => 'done'], + ['date1' => '2015-03-31', 'date2' => '2015-03-31', 'period' => Day::PERIOD_ID, 'name' => 'done'], ]); $expected = array ( @@ -399,7 +404,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-04-15', 'date2' => '2015-04-24', - 'period' => '5', + 'period' => Range::PERIOD_ID, 'name' => 'done', 'report' => null, 'ts_started' => null, @@ -411,7 +416,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-04-06', 'date2' => '2015-04-06', - 'period' => '1', + 'period' => Day::PERIOD_ID, 'name' => 'done', 'report' => null, 'ts_started' => null, @@ -423,7 +428,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-04-06', 'date2' => '2015-04-06', - 'period' => '1', + 'period' => Day::PERIOD_ID, 'name' => 'done764644a7142bdcbedaab92f9dedef5e5', 'report' => null, 'ts_started' => null, @@ -435,7 +440,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-04-06', 'date2' => '2015-04-12', - 'period' => '2', + 'period' => Week::PERIOD_ID, 'name' => 'done', 'report' => null, 'ts_started' => null, @@ -447,7 +452,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-04-06', 'date2' => '2015-04-12', - 'period' => '2', + 'period' => Week::PERIOD_ID, 'name' => 'done764644a7142bdcbedaab92f9dedef5e5', 'report' => null, 'ts_started' => null, @@ -459,7 +464,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-04-05', 'date2' => '2015-04-05', - 'period' => '1', + 'period' => Day::PERIOD_ID, 'name' => 'done', 'report' => null, 'ts_started' => null, @@ -471,7 +476,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-04-04', 'date2' => '2015-04-04', - 'period' => '1', + 'period' => Day::PERIOD_ID, 'name' => 'done', 'report' => null, 'ts_started' => null, @@ -483,7 +488,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-04-03', 'date2' => '2015-04-03', - 'period' => '1', + 'period' => Day::PERIOD_ID, 'name' => 'done', 'report' => null, 'ts_started' => null, @@ -495,7 +500,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-04-02', 'date2' => '2015-04-02', - 'period' => '1', + 'period' => Day::PERIOD_ID, 'name' => 'done', 'report' => null, 'ts_started' => null, @@ -507,7 +512,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-04-02', 'date2' => '2015-04-02', - 'period' => '1', + 'period' => Day::PERIOD_ID, 'name' => 'done67564f109e3f4bba6b185a5343ff2bb0', 'report' => null, 'ts_started' => null, @@ -519,7 +524,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-04-01', 'date2' => '2015-04-01', - 'period' => '1', + 'period' => Day::PERIOD_ID, 'name' => 'done', 'report' => null, 'ts_started' => null, @@ -531,7 +536,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-04-01', 'date2' => '2015-04-30', - 'period' => '3', + 'period' => Month::PERIOD_ID, 'name' => 'done', 'report' => null, 'ts_started' => null, @@ -543,7 +548,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-04-01', 'date2' => '2015-04-30', - 'period' => '3', + 'period' => Month::PERIOD_ID, 'name' => 'done67564f109e3f4bba6b185a5343ff2bb0', 'report' => null, 'ts_started' => null, @@ -555,7 +560,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-03-31', 'date2' => '2015-03-31', - 'period' => '1', + 'period' => Day::PERIOD_ID, 'name' => 'done', 'report' => null, 'ts_started' => null, @@ -567,7 +572,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-03-30', 'date2' => '2015-03-30', - 'period' => '1', + 'period' => Day::PERIOD_ID, 'name' => 'done', 'report' => null, 'ts_started' => null, @@ -579,7 +584,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-03-30', 'date2' => '2015-03-30', - 'period' => '1', + 'period' => Day::PERIOD_ID, 'name' => 'done0bb102ea2ac682a578480dd184736607', 'report' => null, 'ts_started' => null, @@ -591,7 +596,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-03-30', 'date2' => '2015-04-05', - 'period' => '2', + 'period' => Week::PERIOD_ID, 'name' => 'done', 'report' => null, 'ts_started' => null, @@ -603,7 +608,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-03-29', 'date2' => '2015-03-29', - 'period' => '1', + 'period' => Day::PERIOD_ID, 'name' => 'done', 'report' => null, 'ts_started' => null, @@ -615,7 +620,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-03-29', 'date2' => '2015-03-29', - 'period' => '1', + 'period' => Day::PERIOD_ID, 'name' => 'doneb321434abb5a139c17dadf08c9d2e315', 'report' => null, 'ts_started' => null, @@ -627,7 +632,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-03-01', 'date2' => '2015-03-24', - 'period' => '1', + 'period' => Day::PERIOD_ID, 'name' => 'done', 'report' => null, 'ts_started' => null, @@ -639,7 +644,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-03-01', 'date2' => '2015-03-31', - 'period' => '3', + 'period' => Month::PERIOD_ID, 'name' => 'done', 'report' => null, 'ts_started' => null, @@ -651,7 +656,7 @@ public function testGetNextInvalidatedArchiveReturnsCorrectOrder() 'idsite' => '1', 'date1' => '2015-01-01', 'date2' => '2015-12-31', - 'period' => '4', + 'period' => Year::PERIOD_ID, 'name' => 'done', 'report' => null, 'ts_started' => null, @@ -672,10 +677,10 @@ public function testDeleteInvalidationsForDeletedSites() Fixture::createWebsite('2014-01-01 00:00:00'); $this->insertInvalidations([ - ['idsite' => 1, 'date1' => '2014-02-03', 'date2' => '2014-02-03', 'period' => 1, 'name' => 'done'], - ['idsite' => 2, 'date1' => '2014-02-01', 'date2' => '2014-02-28', 'period' => 2, 'name' => 'done'], - ['idsite' => 2, 'date1' => '2014-02-01', 'date2' => '2014-02-01', 'period' => 1, 'name' => 'done'], - ['idsite' => 3, 'date1' => '2014-02-01', 'date2' => '2014-02-01', 'period' => 1, 'name' => 'done'], + ['idsite' => 1, 'date1' => '2014-02-03', 'date2' => '2014-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done'], + ['idsite' => 2, 'date1' => '2014-02-01', 'date2' => '2014-02-28', 'period' => Week::PERIOD_ID, 'name' => 'done'], + ['idsite' => 2, 'date1' => '2014-02-01', 'date2' => '2014-02-01', 'period' => Day::PERIOD_ID, 'name' => 'done'], + ['idsite' => 3, 'date1' => '2014-02-01', 'date2' => '2014-02-01', 'period' => Day::PERIOD_ID, 'name' => 'done'], ]); $this->model->deleteInvalidationsForDeletedSites(); @@ -690,15 +695,15 @@ public function testDeleteInvalidationsForDeletedSites() public function testGetInvalidationsInProgress() { $this->insertInvalidations([ - ['idsite' => 1, 'date1' => '2014-02-01', 'date2' => '2014-02-28', 'period' => 2, 'name' => 'done'], - ['idsite' => 1, 'date1' => '2014-02-01', 'date2' => '2014-02-01', 'period' => 1, 'name' => 'doneb321434abb5a139c17dadf08c9d2e315', 'ts_started' => '2014-02-03 23:13:00', 'status' => 1], - ['idsite' => 1, 'date1' => '2014-02-03', 'date2' => '2014-02-03', 'period' => 1, 'name' => 'done', 'ts_started' => '2014-02-03 23:00:00', 'status' => 1], - ['idsite' => 1, 'date1' => '2014-02-01', 'date2' => '2014-02-01', 'period' => 1, 'name' => 'done'], + ['idsite' => 1, 'date1' => '2014-02-01', 'date2' => '2014-02-28', 'period' => Week::PERIOD_ID, 'name' => 'done'], + ['idsite' => 1, 'date1' => '2014-02-01', 'date2' => '2014-02-01', 'period' => Day::PERIOD_ID, 'name' => 'doneb321434abb5a139c17dadf08c9d2e315', 'ts_started' => '2014-02-03 23:13:00', 'status' => 1], + ['idsite' => 1, 'date1' => '2014-02-03', 'date2' => '2014-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'ts_started' => '2014-02-03 23:00:00', 'status' => 1], + ['idsite' => 1, 'date1' => '2014-02-01', 'date2' => '2014-02-01', 'period' => Day::PERIOD_ID, 'name' => 'done'], ]); $expectedInvalidations = [ - ['idsite' => 1, 'date1' => '2014-02-03', 'date2' => '2014-02-03', 'period' => 1, 'name' => 'done', 'ts_started' => '2014-02-03 23:00:00'], - ['idsite' => 1, 'date1' => '2014-02-01', 'date2' => '2014-02-01', 'period' => 1, 'name' => 'doneb321434abb5a139c17dadf08c9d2e315', 'ts_started' => '2014-02-03 23:13:00'], + ['idsite' => 1, 'date1' => '2014-02-03', 'date2' => '2014-02-03', 'period' => Day::PERIOD_ID, 'name' => 'done', 'ts_started' => '2014-02-03 23:00:00'], + ['idsite' => 1, 'date1' => '2014-02-01', 'date2' => '2014-02-01', 'period' => Day::PERIOD_ID, 'name' => 'doneb321434abb5a139c17dadf08c9d2e315', 'ts_started' => '2014-02-03 23:13:00'], ]; self::assertEquals($expectedInvalidations, $this->model->getInvalidationsInProgress(1));