Skip to content

Commit

Permalink
add test for new method
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Jul 16, 2024
1 parent c841fb2 commit a516546
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/DataAccess/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ORDER BY ts_started ASC";
return Db::fetchAll($sql, $bind);
}

Expand Down
17 changes: 17 additions & 0 deletions tests/PHPUnit/Integration/DataAccess/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,23 @@ public function testDeleteInvalidationsForDeletedSites()
], $invalidations);
}

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'],
]);

$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'],
];

self::assertEquals($expectedInvalidations, $this->model->getInvalidationsInProgress(1));
}

private function insertArchiveData($archivesToInsert)
{
$idarchive = 1;
Expand Down

0 comments on commit a516546

Please sign in to comment.