Browse Source

Partially fix up feed tests

The main test still needs fixing, and a new test may need to be written
to properly exercise the reduplicated schema.
redup
J. King 1 year ago
parent
commit
e110dfcf89
  1. 22
      lib/Database.php
  2. 131
      tests/cases/Database/SeriesFeed.php

22
lib/Database.php

@ -1204,7 +1204,7 @@ class Database {
/** Returns an indexed array of numeric identifiers for newsfeeds which should be refreshed */
public function feedListStale(): array {
$feeds = $this->db->query("SELECT id from arsse_feeds where next_fetch <= CURRENT_TIMESTAMP")->getAll();
$feeds = $this->db->query("SELECT id from arsse_subscriptions where next_fetch <= CURRENT_TIMESTAMP")->getAll();
return array_column($feeds, 'id');
}
@ -1221,7 +1221,7 @@ class Database {
}
$f = $this->db->prepareArray(
"SELECT
url, las_mod as modified, etag, err_count, scrape as scrapers, keep_rule, block_rule
url, last_mod as modified, etag, err_count, scrape as scrapers, keep_rule, block_rule
FROM arsse_subscriptions
where id = ? and owner = coalesce(?, owner)",
["int", "str"]
@ -1235,7 +1235,7 @@ class Database {
// here. When an exception is thrown it should update the database with the
// error instead of failing; if other exceptions are thrown, we should simply roll back
try {
$feed = new Feed((int) $subID, $f['url'], (string) Date::transform($f['modified'], "http", "sql"), $f['etag'], $f['username'], $f['password'], $scrape);
$feed = new Feed((int) $subID, $f['url'], (string) Date::transform($f['modified'], "http", "sql"), $f['etag'], "", "", $scrape);
if (!$feed->modified) {
// if the feed hasn't changed, just compute the next fetch time and record it
$this->db->prepare("UPDATE arsse_subscriptions SET updated = CURRENT_TIMESTAMP, next_fetch = ? WHERE id = ?", 'datetime', 'int')->run($feed->nextFetch, $subID);
@ -1263,14 +1263,16 @@ class Database {
"INSERT INTO arsse_articles(url,title,author,published,edited,guid,url_title_hash,url_content_hash,title_content_hash,subscription,hidden) values(?,?,?,?,?,?,?,?,?,?,?)",
["str", "str", "str", "datetime", "datetime", "str", "str", "str", "str", "int", "bool"]
);
$qInsertContent = $this->db->prepareArray("INSERT INTO arsse_article_contents(id, content) values(?,?)", ["int", "str"]);
}
if (sizeof($feed->changedItems)) {
$qDeleteEnclosures = $this->db->prepare("DELETE FROM arsse_enclosures WHERE article = ?", 'int');
$qDeleteCategories = $this->db->prepare("DELETE FROM arsse_categories WHERE article = ?", 'int');
$qUpdateArticle = $this->db->prepareArray(
"UPDATE arsse_articles SET \"read\" = 0, hidden = ?, url = ?, title = ?, author = ?, published = ?, edited = ?, modified = CURRENT_TIMESTAMP, guid = ?, content = ?, url_title_hash = ?, url_content_hash = ?, title_content_hash = ?, content_scraped = ? WHERE id = ?",
["bool", "str", "str", "str", "datetime", "datetime", "str", "str", "str", "str", "str", "str", "int"]
"UPDATE arsse_articles SET \"read\" = 0, hidden = ?, url = ?, title = ?, author = ?, published = ?, edited = ?, modified = CURRENT_TIMESTAMP, guid = ?, url_title_hash = ?, url_content_hash = ?, title_content_hash = ? WHERE id = ?",
["bool", "str", "str", "str", "datetime", "datetime", "str", "str", "str", "str", "int"]
);
$qUpdateContent = $this->db->prepareArray("UPDATE arsse_article_contents set content = ? where id = ?", ["str", "int"]);
}
// prepare the keep and block rules
try {
@ -1315,6 +1317,7 @@ class Database {
$subID,
!Rule::apply($keep, $block, $article->title, $article->categories)
)->lastId();
$qInsertContent->run($articleID, $article->scrapedContent ?? $article->content);
// note the new ID for later use
$articleMap[$k] = $articleID;
// insert any enclosures
@ -1338,13 +1341,12 @@ class Database {
$article->publishedDate,
$article->updatedDate,
$article->id,
$article->content,
$article->urlTitleHash,
$article->urlContentHash,
$article->titleContentHash,
$article->scrapedContent ?? null,
$articleID
);
$qUpdateContent->run($article->scrapedContent ?? $article->content, $articleID);
// delete all enclosures and categories and re-insert them
$qDeleteEnclosures->run($articleID);
$qDeleteCategories->run($articleID);
@ -1410,7 +1412,7 @@ class Database {
*/
public function feedMatchLatest(int $feedID, int $count): Db\Result {
return $this->db->prepare(
"SELECT id, edited, guid, url_title_hash, url_content_hash, title_content_hash FROM arsse_articles WHERE feed = ? ORDER BY modified desc, id desc limit ?",
"SELECT id, edited, guid, url_title_hash, url_content_hash, title_content_hash FROM arsse_articles WHERE subscription = ? ORDER BY modified desc, id desc limit ?",
'int',
'int'
)->run($feedID, $count);
@ -1439,7 +1441,7 @@ class Database {
[$cHashTC, $tHashTC, $vHashTC] = $this->generateIn($hashesTC, "str");
// perform the query
return $this->db->prepareArray(
"SELECT id, edited, guid, url_title_hash, url_content_hash, title_content_hash FROM arsse_articles WHERE feed = ? and (guid in($cId) or url_title_hash in($cHashUT) or url_content_hash in($cHashUC) or title_content_hash in($cHashTC))",
"SELECT id, edited, guid, url_title_hash, url_content_hash, title_content_hash FROM arsse_articles WHERE subscription = ? and (guid in($cId) or url_title_hash in($cHashUT) or url_content_hash in($cHashUC) or title_content_hash in($cHashTC))",
['int', $tId, $tHashUT, $tHashUC, $tHashTC]
)->run($feedID, $vId, $vHashUT, $vHashUC, $vHashTC);
}
@ -1493,7 +1495,7 @@ class Database {
'url' => "arsse_articles.url", // The URL of the article's full content
'title' => "arsse_articles.title", // The title
'author' => "arsse_articles.author", // The name of the author
'content' => "coalesce(case when arsse_subscriptions.scrape = 1 then arsse_articles.content_scraped end, arsse_articles.content)", // The article content
'content' => "arsse_article_contents.content", // The article content
'guid' => "arsse_articles.guid", // The GUID of the article, as presented in the feed (NOTE: Picofeed actually provides a hash of the ID)
'fingerprint' => "arsse_articles.url_title_hash || ':' || arsse_articles.url_content_hash || ':' || arsse_articles.title_content_hash", // A combination of three hashes
'folder' => "coalesce(arsse_subscriptions.folder,0)", // The folder of the article's feed. This is mainly for use in WHERE clauses

131
tests/cases/Database/SeriesFeed.php

@ -21,8 +21,9 @@ trait SeriesFeed {
'arsse_users' => [
'columns' => ["id", "password", "num"],
'rows' => [
["jane.doe@example.com", "",1],
["john.doe@example.com", "",2],
["jane.doe@example.com", "", 1],
["john.doe@example.com", "", 2],
["jane.doe@example.org", "", 3],
],
],
'arsse_icons' => [
@ -34,42 +35,54 @@ trait SeriesFeed {
[3,'http://localhost:8000/Icon/SVG1','image/svg+xml','<svg xmlns="http://www.w3.org/2000/svg" width="900" height="600"><rect width="900" height="600" fill="#ED2939"/><rect width="600" height="600" fill="#fff"/><rect width="300" height="600" fill="#002395"/></svg>'],
],
],
'arsse_feeds' => [
'columns' => ["id", "url", "title", "err_count", "err_msg", "modified", "next_fetch", "size", "icon"],
'arsse_subscriptions' => [
'columns' => ["id", "owner", "keep_rule", "block_rule", "url", "feed_title", "err_count", "err_msg", "last_mod", "next_fetch", "size", "icon"],
'rows' => [
[1,"http://localhost:8000/Feed/Matching/3","Ook",0,"",$past,$past,0,null],
[2,"http://localhost:8000/Feed/Matching/1","Eek",5,"There was an error last time",$past,$future,0,null],
[3,"http://localhost:8000/Feed/Fetching/Error?code=404","Ack",0,"",$past,$now,0,null],
[4,"http://localhost:8000/Feed/NextFetch/NotModified?t=".time(),"Ooook",0,"",$past,$past,0,null],
[5,"http://localhost:8000/Feed/Parsing/Valid","Ooook",0,"",$past,$future,0,null],
[1, 'john.doe@example.com',null, '^Sport$',"http://localhost:8000/Feed/Matching/3", "Ook", 0,"", $past,$past, 0,null],
[2, 'john.doe@example.com',"", null, "http://localhost:8000/Feed/Matching/1", "Eek", 5,"There was an error last time",$past,$future,0,null],
[3, 'john.doe@example.com','\w+', null, "http://localhost:8000/Feed/Fetching/Error?code=404", "Ack", 0,"", $past,$now, 0,null],
[4, 'john.doe@example.com','\w+', "[", "http://localhost:8000/Feed/NextFetch/NotModified?t=".time(),"Ooook",0,"", $past,$past, 0,null], // invalid rule leads to both rules being ignored
[5, 'john.doe@example.com',null, 'and/or', "http://localhost:8000/Feed/Parsing/Valid", "Ooook",0,"", $past,$future,0,null],
[6, 'jane.doe@example.com','^(?i)[a-z]+','3|6', "http://localhost:8000/Feed/Matching/3", "Ook", 0,"", $past,$past, 0,null],
// these feeds all test icon caching
[6,"http://localhost:8000/Feed/WithIcon/PNG",null,0,"",$past,$future,0,1], // no change when updated
[7,"http://localhost:8000/Feed/WithIcon/GIF",null,0,"",$past,$future,0,1], // icon ID 2 will be assigned to feed when updated
[8,"http://localhost:8000/Feed/WithIcon/SVG1",null,0,"",$past,$future,0,3], // icon ID 3 will be modified when updated
[9,"http://localhost:8000/Feed/WithIcon/SVG2",null,0,"",$past,$future,0,null], // icon ID 4 will be created and assigned to feed when updated
[16,'jane.doe@example.org',null, null, "http://localhost:8000/Feed/WithIcon/PNG", null, 0,"", $past,$future,0,1], // no change when updated
[17,'jane.doe@example.org',null, null, "http://localhost:8000/Feed/WithIcon/GIF", null, 0,"", $past,$future,0,1], // icon ID 2 will be assigned to feed when updated
[18,'jane.doe@example.org',null, null, "http://localhost:8000/Feed/WithIcon/SVG1", null, 0,"", $past,$future,0,3], // icon ID 3 will be modified when updated
[19,'jane.doe@example.org',null, null, "http://localhost:8000/Feed/WithIcon/SVG2", null, 0,"", $past,$future,0,null], // icon ID 4 will be created and assigned to feed when updated
],
],
'arsse_subscriptions' => [
'columns' => ["id", "owner", "feed", "keep_rule", "block_rule"],
'arsse_articles' => [
'columns' => ["id", "subscription", "url", "title", "author", "published", "edited", "guid", "url_title_hash", "url_content_hash", "title_content_hash", "modified", "read", "starred", "hidden", "marked"],
'rows' => [
[1,'john.doe@example.com',1,null,'^Sport$'],
[2,'john.doe@example.com',2,"",null],
[3,'john.doe@example.com',3,'\w+',null],
[4,'john.doe@example.com',4,'\w+',"["], // invalid rule leads to both rules being ignored
[5,'john.doe@example.com',5,null,'and/or'],
[6,'jane.doe@example.com',1,'^(?i)[a-z]+','3|6'],
[1, 1,'http://example.com/1','Article title 1','','2000-01-01 00:00:00','2000-01-01 00:00:00','e433653cef2e572eee4215fa299a4a5af9137b2cefd6283c85bd69a32915beda','f5cb8bfc1c7396dc9816af212a3e2ac5221585c2a00bf7ccb6aabd95dcfcd6a6','fb0bc8f8cb08913dc5a497db700e327f1d34e4987402687d494a5891f24714d4','18fdd4fa93d693128c43b004399e5c9cea6c261ddfa002518d3669f55d8c2207',$past,1,0,0,null],
[2, 1,'http://example.com/2','Article title 2','','2000-01-02 00:00:00','2000-01-02 00:00:00','5be8a5a46ecd52ed132191c8d27fb1af6b3d4edc00234c5d9f8f0e10562ed3b7','0e86d2de822a174fe3c44a466953e63ca1f1a58a19cbf475fce0855d4e3d5153','13075894189c47ffcfafd1dfe7fbb539f7c74a69d35a399b3abf8518952714f9','2abd0a8cba83b8214a66c8f0293ba63e467d720540e29ff8ddcdab069d4f1c9e',$past,0,0,0,null],
[3, 1,'http://example.com/3','Article title 3','','2000-01-03 00:00:00','2000-01-03 00:00:00','31a6594500a48b59fcc8a075ce82b946c9c3c782460d088bd7b8ef3ede97ad92','f74b06b240bd08abf4d3fdfc20dba6a6f6eb8b4f1a00e9a617efd63a87180a4b','b278380e984cefe63f0e412b88ffc9cb0befdfa06fdc00bace1da99a8daff406','ad622b31e739cd3a3f3c788991082cf4d2f7a8773773008e75f0572e58cd373b',$past,1,0,0,null],
[4, 1,'http://example.com/4','Article title 4','','2000-01-04 00:00:00','2000-01-04 00:00:00','804e517d623390e71497982c77cf6823180342ebcd2e7d5e32da1e55b09dd180','f3615c7f16336d3ea242d35cf3fc17dbc4ee3afb78376bf49da2dd7a5a25dec8','f11c2b4046f207579aeb9c69a8c20ca5461cef49756ccfa5ba5e2344266da3b3','ab2da63276acce431250b18d3d49b988b226a99c7faadf275c90b751aee05be9',$past,0,1,0,null],
[5, 1,'http://example.com/5','Article title 5','','2000-01-05 00:00:00','2000-01-05 00:00:00','db3e736c2c492f5def5c5da33ddcbea1824040e9ced2142069276b0a6e291a41','d40da96e39eea6c55948ccbe9b3d275b5f931298288dbe953990c5f496097022','834240f84501b5341d375414718204ec421561f3825d34c22bf9182203e42900','43b970ac6ec5f8a9647b2c7e4eed8b1d7f62e154a95eed748b0294c1256764ba',$past,0,0,0,null],
[6, 2,'http://example.com/1','Article title 1','','2000-01-01 00:00:00','2000-01-01 00:00:00','e433653cef2e572eee4215fa299a4a5af9137b2cefd6283c85bd69a32915beda','f5cb8bfc1c7396dc9816af212a3e2ac5221585c2a00bf7ccb6aabd95dcfcd6a6','fb0bc8f8cb08913dc5a497db700e327f1d34e4987402687d494a5891f24714d4','18fdd4fa93d693128c43b004399e5c9cea6c261ddfa002518d3669f55d8c2207',$past,0,0,0,null],
[7, 5,'', '', '','2000-01-01 00:00:00','2000-01-01 00:00:00','205e986f4f8b3acfa281227beadb14f5e8c32c8dae4737f888c94c0df49c56f8','', '', '', $past,0,0,0,null],
[11,6,'http://example.com/1','Article title 1','','2000-01-01 00:00:00','2000-01-01 00:00:00','e433653cef2e572eee4215fa299a4a5af9137b2cefd6283c85bd69a32915beda','f5cb8bfc1c7396dc9816af212a3e2ac5221585c2a00bf7ccb6aabd95dcfcd6a6','fb0bc8f8cb08913dc5a497db700e327f1d34e4987402687d494a5891f24714d4','18fdd4fa93d693128c43b004399e5c9cea6c261ddfa002518d3669f55d8c2207',$past,1,0,0,$past],
[12,6,'http://example.com/2','Article title 2','','2000-01-02 00:00:00','2000-01-02 00:00:00','5be8a5a46ecd52ed132191c8d27fb1af6b3d4edc00234c5d9f8f0e10562ed3b7','0e86d2de822a174fe3c44a466953e63ca1f1a58a19cbf475fce0855d4e3d5153','13075894189c47ffcfafd1dfe7fbb539f7c74a69d35a399b3abf8518952714f9','2abd0a8cba83b8214a66c8f0293ba63e467d720540e29ff8ddcdab069d4f1c9e',$past,1,0,0,$past],
[13,6,'http://example.com/3','Article title 3','','2000-01-03 00:00:00','2000-01-03 00:00:00','31a6594500a48b59fcc8a075ce82b946c9c3c782460d088bd7b8ef3ede97ad92','f74b06b240bd08abf4d3fdfc20dba6a6f6eb8b4f1a00e9a617efd63a87180a4b','b278380e984cefe63f0e412b88ffc9cb0befdfa06fdc00bace1da99a8daff406','ad622b31e739cd3a3f3c788991082cf4d2f7a8773773008e75f0572e58cd373b',$past,1,1,0,$past],
[14,6,'http://example.com/4','Article title 4','','2000-01-04 00:00:00','2000-01-04 00:00:00','804e517d623390e71497982c77cf6823180342ebcd2e7d5e32da1e55b09dd180','f3615c7f16336d3ea242d35cf3fc17dbc4ee3afb78376bf49da2dd7a5a25dec8','f11c2b4046f207579aeb9c69a8c20ca5461cef49756ccfa5ba5e2344266da3b3','ab2da63276acce431250b18d3d49b988b226a99c7faadf275c90b751aee05be9',$past,1,0,1,$past],
[15,6,'http://example.com/5','Article title 5','','2000-01-05 00:00:00','2000-01-05 00:00:00','db3e736c2c492f5def5c5da33ddcbea1824040e9ced2142069276b0a6e291a41','d40da96e39eea6c55948ccbe9b3d275b5f931298288dbe953990c5f496097022','834240f84501b5341d375414718204ec421561f3825d34c22bf9182203e42900','43b970ac6ec5f8a9647b2c7e4eed8b1d7f62e154a95eed748b0294c1256764ba',$past,1,1,0,$past],
],
],
'arsse_articles' => [
'columns' => ["id", "feed", "url", "title", "author", "published", "edited", "content", "guid", "url_title_hash", "url_content_hash", "title_content_hash", "modified"],
'arsse_article_contents' => [
'columns' => ["id", "content"],
'rows' => [
[1,1,'http://example.com/1','Article title 1','','2000-01-01 00:00:00','2000-01-01 00:00:00','<p>Article content 1</p>','e433653cef2e572eee4215fa299a4a5af9137b2cefd6283c85bd69a32915beda','f5cb8bfc1c7396dc9816af212a3e2ac5221585c2a00bf7ccb6aabd95dcfcd6a6','fb0bc8f8cb08913dc5a497db700e327f1d34e4987402687d494a5891f24714d4','18fdd4fa93d693128c43b004399e5c9cea6c261ddfa002518d3669f55d8c2207',$past],
[2,1,'http://example.com/2','Article title 2','','2000-01-02 00:00:00','2000-01-02 00:00:00','<p>Article content 2</p>','5be8a5a46ecd52ed132191c8d27fb1af6b3d4edc00234c5d9f8f0e10562ed3b7','0e86d2de822a174fe3c44a466953e63ca1f1a58a19cbf475fce0855d4e3d5153','13075894189c47ffcfafd1dfe7fbb539f7c74a69d35a399b3abf8518952714f9','2abd0a8cba83b8214a66c8f0293ba63e467d720540e29ff8ddcdab069d4f1c9e',$past],
[3,1,'http://example.com/3','Article title 3','','2000-01-03 00:00:00','2000-01-03 00:00:00','<p>Article content 3</p>','31a6594500a48b59fcc8a075ce82b946c9c3c782460d088bd7b8ef3ede97ad92','f74b06b240bd08abf4d3fdfc20dba6a6f6eb8b4f1a00e9a617efd63a87180a4b','b278380e984cefe63f0e412b88ffc9cb0befdfa06fdc00bace1da99a8daff406','ad622b31e739cd3a3f3c788991082cf4d2f7a8773773008e75f0572e58cd373b',$past],
[4,1,'http://example.com/4','Article title 4','','2000-01-04 00:00:00','2000-01-04 00:00:00','<p>Article content 4</p>','804e517d623390e71497982c77cf6823180342ebcd2e7d5e32da1e55b09dd180','f3615c7f16336d3ea242d35cf3fc17dbc4ee3afb78376bf49da2dd7a5a25dec8','f11c2b4046f207579aeb9c69a8c20ca5461cef49756ccfa5ba5e2344266da3b3','ab2da63276acce431250b18d3d49b988b226a99c7faadf275c90b751aee05be9',$past],
[5,1,'http://example.com/5','Article title 5','','2000-01-05 00:00:00','2000-01-05 00:00:00','<p>Article content 5</p>','db3e736c2c492f5def5c5da33ddcbea1824040e9ced2142069276b0a6e291a41','d40da96e39eea6c55948ccbe9b3d275b5f931298288dbe953990c5f496097022','834240f84501b5341d375414718204ec421561f3825d34c22bf9182203e42900','43b970ac6ec5f8a9647b2c7e4eed8b1d7f62e154a95eed748b0294c1256764ba',$past],
[6,2,'http://example.com/1','Article title 1','','2000-01-01 00:00:00','2000-01-01 00:00:00','<p>Article content 1</p>','e433653cef2e572eee4215fa299a4a5af9137b2cefd6283c85bd69a32915beda','f5cb8bfc1c7396dc9816af212a3e2ac5221585c2a00bf7ccb6aabd95dcfcd6a6','fb0bc8f8cb08913dc5a497db700e327f1d34e4987402687d494a5891f24714d4','18fdd4fa93d693128c43b004399e5c9cea6c261ddfa002518d3669f55d8c2207',$past],
[7,5,'', '', '','2000-01-01 00:00:00','2000-01-01 00:00:00','', '205e986f4f8b3acfa281227beadb14f5e8c32c8dae4737f888c94c0df49c56f8','', '', '', $past],
[1, '<p>Article content 1</p>'],
[2, '<p>Article content 2</p>'],
[3, '<p>Article content 3</p>'],
[4, '<p>Article content 4</p>'],
[5, '<p>Article content 5</p>'],
[6, '<p>Article content 1</p>'],
[7, ''],
[11,'<p>Article content 1</p>'],
[12,'<p>Article content 2</p>'],
[13,'<p>Article content 3</p>'],
[14,'<p>Article content 4</p>'],
[15,'<p>Article content 5</p>'],
],
],
'arsse_editions' => [
@ -82,21 +95,6 @@ trait SeriesFeed {
[5,5,$past],
],
],
'arsse_marks' => [
'columns' => ["article", "subscription", "read", "starred", "hidden", "modified"],
'rows' => [
// Jane's marks
[1,6,1,0,0,$past],
[2,6,1,0,0,$past],
[3,6,1,1,0,$past],
[4,6,1,0,1,$past],
[5,6,1,1,0,$past],
// John's marks
[1,1,1,0,0,$past],
[3,1,1,0,0,$past],
[4,1,0,1,0,$past],
],
],
'arsse_enclosures' => [
'columns' => ["article", "url", "type"],
'rows' => [
@ -152,12 +150,13 @@ trait SeriesFeed {
public function testUpdateAFeed(): void {
// update a valid feed with both new and changed items
Arsse::$db->subscriptionUpdate(null, 1);
Arsse::$db->subscriptionUpdate(null, 6);
$now = gmdate("Y-m-d H:i:s");
$state = $this->primeExpectations($this->data, [
'arsse_articles' => ["id", "feed","url","title","author","published","edited","content","guid","url_title_hash","url_content_hash","title_content_hash","modified"],
'arsse_editions' => ["id","article","modified"],
'arsse_marks' => ["subscription","article","read","starred","hidden","modified"],
'arsse_feeds' => ["id","size"],
'arsse_articles' => ["id", "feed","url","title","author","published","edited","guid","url_title_hash","url_content_hash","title_content_hash","modified","read","starred","hidden","marked"],
'arsse_article_contents' => ["id", "content"],
'arsse_editions' => ["id","article","modified"],
'arsse_subscriptionss' => ["id","size"],
]);
$state['arsse_articles']['rows'][2] = [3,1,'http://example.com/3','Article title 3 (updated)','','2000-01-03 00:00:00','2000-01-03 00:00:00','<p>Article content 3</p>','31a6594500a48b59fcc8a075ce82b946c9c3c782460d088bd7b8ef3ede97ad92','6cc99be662ef3486fef35a890123f18d74c29a32d714802d743c5b4ef713315a','b278380e984cefe63f0e412b88ffc9cb0befdfa06fdc00bace1da99a8daff406','d5faccc13bf8267850a1e8e61f95950a0f34167df2c8c58011c0aaa6367026ac',$now];
$state['arsse_articles']['rows'][3] = [4,1,'http://example.com/4','Article title 4','','2000-01-04 00:00:00','2000-01-04 00:00:01','<p>Article content 4</p>','804e517d623390e71497982c77cf6823180342ebcd2e7d5e32da1e55b09dd180','f3615c7f16336d3ea242d35cf3fc17dbc4ee3afb78376bf49da2dd7a5a25dec8','f11c2b4046f207579aeb9c69a8c20ca5461cef49756ccfa5ba5e2344266da3b3','ab2da63276acce431250b18d3d49b988b226a99c7faadf275c90b751aee05be9',$now];
@ -171,7 +170,7 @@ trait SeriesFeed {
$state['arsse_marks']['rows'][3] = [6,4,0,0,0,$now];
$state['arsse_marks']['rows'][6] = [1,3,0,0,0,$now];
$state['arsse_marks']['rows'][] = [6,8,0,0,1,null];
$state['arsse_feeds']['rows'][0] = [1,6];
$state['arsse_subscriptions']['rows'][0] = [1,6];
$this->compareExpectations(static::$drv, $state);
// update a valid feed which previously had an error
Arsse::$db->subscriptionUpdate(null, 2);
@ -226,48 +225,48 @@ trait SeriesFeed {
}
public function testListStaleFeeds(): void {
$this->assertEquals([1,3,4], Arsse::$db->feedListStale());
$this->assertEquals([1,3,4, 6], Arsse::$db->feedListStale());
Arsse::$db->subscriptionUpdate(null, 3);
Arsse::$db->subscriptionUpdate(null, 4);
$this->assertEquals([1], Arsse::$db->feedListStale());
$this->assertEquals([1, 6], Arsse::$db->feedListStale());
}
public function testCheckIconDuringFeedUpdate(): void {
Arsse::$db->subscriptionUpdate(null, 6);
Arsse::$db->subscriptionUpdate(null, 16);
$state = $this->primeExpectations($this->data, [
'arsse_icons' => ["id","url","type","data"],
'arsse_feeds' => ["id", "icon"],
'arsse_icons' => ["id","url","type","data"],
'arsse_subscriptions' => ["id", "icon"],
]);
$this->compareExpectations(static::$drv, $state);
}
public function testAssignIconDuringFeedUpdate(): void {
Arsse::$db->subscriptionUpdate(null, 7);
Arsse::$db->subscriptionUpdate(null, 17);
$state = $this->primeExpectations($this->data, [
'arsse_icons' => ["id","url","type","data"],
'arsse_feeds' => ["id", "icon"],
'arsse_icons' => ["id","url","type","data"],
'arsse_subscriptions' => ["id", "icon"],
]);
$state['arsse_feeds']['rows'][6][1] = 2;
$state['arsse_subscriptions']['rows'][7][1] = 2;
$this->compareExpectations(static::$drv, $state);
}
public function testChangeIconDuringFeedUpdate(): void {
Arsse::$db->subscriptionUpdate(null, 8);
Arsse::$db->subscriptionUpdate(null, 18);
$state = $this->primeExpectations($this->data, [
'arsse_icons' => ["id","url","type","data"],
'arsse_feeds' => ["id", "icon"],
'arsse_icons' => ["id","url","type","data"],
'arsse_subscriptions' => ["id", "icon"],
]);
$state['arsse_icons']['rows'][2][3] = '<svg xmlns="http://www.w3.org/2000/svg" width="900" height="600"><rect fill="#fff" height="600" width="900"/><circle fill="#bc002d" cx="450" cy="300" r="180"/></svg>';
$this->compareExpectations(static::$drv, $state);
}
public function testAddIconDuringFeedUpdate(): void {
Arsse::$db->subscriptionUpdate(null, 9);
Arsse::$db->subscriptionUpdate(null, 19);
$state = $this->primeExpectations($this->data, [
'arsse_icons' => ["id","url","type","data"],
'arsse_feeds' => ["id", "icon"],
'arsse_icons' => ["id","url","type","data"],
'arsse_subscriptions' => ["id", "icon"],
]);
$state['arsse_feeds']['rows'][8][1] = 4;
$state['arsse_subscriptions']['rows'][9][1] = 4;
$state['arsse_icons']['rows'][] = [4,'http://localhost:8000/Icon/SVG2','image/svg+xml','<svg xmlns="http://www.w3.org/2000/svg" width="900" height="600"><rect width="900" height="600" fill="#ED2939"/><rect width="600" height="600" fill="#fff"/><rect width="300" height="600" fill="#002395"/></svg>'];
$this->compareExpectations(static::$drv, $state);
}

Loading…
Cancel
Save