From acb5b40c5310b59ec6b24846f7c6076a4f2260df Mon Sep 17 00:00:00 2001 From: sgiehl Date: Tue, 16 Jul 2024 14:32:09 +0200 Subject: [PATCH] add test for new method --- core/DataAccess/Model.php | 2 +- .../Integration/DataAccess/ModelTest.php | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/DataAccess/Model.php b/core/DataAccess/Model.php index 3aab4bb76f8..e4838d6a4ba 100644 --- a/core/DataAccess/Model.php +++ b/core/DataAccess/Model.php @@ -793,7 +793,7 @@ public function getInvalidationsInProgress(int $idSite): array $bind = [$idSite, ArchiveInvalidator::INVALIDATION_STATUS_IN_PROGRESS]; - $sql = "SELECT idsite, period, date1, date2, name FROM `$table` WHERE idsite = ? AND `status` = ? AND ts_started IS NOT NULL"; + $sql = "SELECT idsite, period, date1, date2, name, ts_started FROM `$table` WHERE idsite = ? AND `status` = ? AND ts_started IS NOT NULL"; return Db::fetchAll($sql, $bind); } diff --git a/tests/PHPUnit/Integration/DataAccess/ModelTest.php b/tests/PHPUnit/Integration/DataAccess/ModelTest.php index c385747daea..57b15d688de 100644 --- a/tests/PHPUnit/Integration/DataAccess/ModelTest.php +++ b/tests/PHPUnit/Integration/DataAccess/ModelTest.php @@ -666,6 +666,23 @@ public function testDeleteInvalidationsForDeletedSites() ], $invalidations); } + public function testGetInvalidationsInProgress() + { + $this->insertInvalidations([ + ['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-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-01', 'date2' => '2014-02-01', 'period' => 1, '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'], + ]; + + $this->assertEquals($expectedInvalidations, $this->model->getInvalidationsInProgress(1)); + } + private function insertArchiveData($archivesToInsert) { $idarchive = 1;