From c139f52ebc9952e06f0523187861d838161b0ad7 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Fri, 10 Mar 2023 18:52:33 -0500 Subject: [PATCH] Start on rewriting cleanup tests --- lib/Database.php | 4 ++-- tests/cases/Database/SeriesCleanup.php | 27 ++++++++++++++++---------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/lib/Database.php b/lib/Database.php index 5ce0603f..a2a132c6 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -2049,10 +2049,10 @@ class Database { arsse_articles where subscription = ? - and starred = 0 + and (starred = 0 or hidden = 1) and ( coalesce(marked,modified) <= ? - or (\"read\" = 1 and coalesce(marked,modified) <= ?) + or (coalesce(marked,modified) <= ? and (\"read\" = 1 or hidden = 1)) ) and id not in (select id from exempt_articles)", ["int", "int", "int", "datetime", "datetime"] diff --git a/tests/cases/Database/SeriesCleanup.php b/tests/cases/Database/SeriesCleanup.php index 41886819..f8d7ae7d 100644 --- a/tests/cases/Database/SeriesCleanup.php +++ b/tests/cases/Database/SeriesCleanup.php @@ -72,16 +72,18 @@ trait SeriesCleanup { ], ], 'arsse_subscriptions' => [ - 'columns' => ["id", "owner", "feed"], + 'columns' => ["id", "owner", "url", "size", "icon", "deleted", "modified"], 'rows' => [ - // one feed previously marked for deletion has a subscription again, and so should not be deleted - [1,'jane.doe@example.com',1], - // other subscriptions exist for article cleanup tests - [2,'john.doe@example.com',1], + // first two subscriptions are used for article cleanup tests: the latest two articles should be kept + [1,'jane.doe@example.com',"http://example.com/1",2,null,0,$daybefore], + [2,'john.doe@example.com',"http://example.com/1",2,null,0,$daybefore], + // the other subscriptions are used for subscription cleanup + [3,'jane.doe@example.com',"http://example.com/2",0, 2,1,$yesterday], + ], ], 'arsse_articles' => [ - 'columns' => ["id", "feed", "url_title_hash", "url_content_hash", "title_content_hash", "modified"], + 'columns' => ["id", "subscription", "url_title_hash", "url_content_hash", "title_content_hash", "modified"], 'rows' => [ [1,1,"","","",$weeksago], // is the latest article, thus is kept [2,1,"","","",$weeksago], // is the second latest article, thus is kept @@ -101,6 +103,11 @@ trait SeriesCleanup { [2,2], [3,3], [4,4], + [5,5], + [6,6], + [7,7], + [8,8], + [9,9], [201,1], [102,2], ], @@ -125,8 +132,8 @@ trait SeriesCleanup { unset($this->data); } - public function testCleanUpOrphanedFeeds(): void { - Arsse::$db->feedCleanup(); + public function testCleanUpDeletedSubscriptions(): void { + Arsse::$db->subscriptionCleanup(); $now = gmdate("Y-m-d H:i:s"); $state = $this->primeExpectations($this->data, [ 'arsse_feeds' => ["id","orphaned"], @@ -137,11 +144,11 @@ trait SeriesCleanup { $this->compareExpectations(static::$drv, $state); } - public function testCleanUpOrphanedFeedsWithUnlimitedRetention(): void { + public function testCleanUpDeletedSubscriptionsWithUnlimitedRetention(): void { Arsse::$conf->import([ 'purgeFeeds' => null, ]); - Arsse::$db->feedCleanup(); + Arsse::$db->subscriptionCleanup(); $now = gmdate("Y-m-d H:i:s"); $state = $this->primeExpectations($this->data, [ 'arsse_feeds' => ["id","orphaned"],