diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2020-11-23 04:18:29 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-23 04:18:29 +0300 |
commit | 9da2de3233592acc789eb61bdc775bd8ddf6b115 (patch) | |
tree | f12a4741048a81274cb4cf4b03e5adcac3493e8a /tests | |
parent | 4cfbe93000e610bd152eb66e5b4a8874cd9304e2 (diff) |
Remove existing invalidations before scheduling new ones (#16772)4.0.0-rc7
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php b/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php index 9aa35cd543..e2d2d59af0 100644 --- a/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php +++ b/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php @@ -1209,7 +1209,7 @@ class ArchiveInvalidatorTest extends IntegrationTestCase $this->invalidator->scheduleReArchiving('all', 'VisitsSummary'); $this->invalidator->applyScheduledReArchiving(); - $countInvalidations = Db::fetchOne("SELECT COUNT(*) FROM " . Common::prefixTable('archive_invalidations')); + $countInvalidations = $this->getNumInvalidations(); $invalidationSites = Db::fetchAll("SELECT DISTINCT idsite FROM " . Common::prefixTable('archive_invalidations')); $invalidationSites = array_column($invalidationSites, 'idsite'); @@ -1218,6 +1218,23 @@ class ArchiveInvalidatorTest extends IntegrationTestCase $this->assertEquals([1,2,3,4,5,6,7,8,9,10], $invalidationSites); } + private function getNumInvalidations() + { + return Db::fetchOne("SELECT COUNT(*) FROM " . Common::prefixTable('archive_invalidations')); + } + + public function test_scheduleReArchiving_cleanupWhenReportGiven() + { + $this->invalidator->scheduleReArchiving([1, 2, 3], 'ExamplePlugin', '5'); + $this->invalidator->applyScheduledReArchiving(); + $this->assertEquals(729, $this->getNumInvalidations()); + + $this->invalidator->scheduleReArchiving([1, 2, 3], 'ExamplePlugin', '5'); + $this->invalidator->applyScheduledReArchiving(); + // should not end up having twice the amount of invalidations but delete existing + $this->assertEquals(729, $this->getNumInvalidations()); + + } public function test_reArchiveReport_createsCorrectInvalidationEntries_ifNoReportSpecified() { Date::$now = strtotime('2020-06-16 12:00:00'); |