mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Tests for icon cache population
This commit is contained in:
parent
bd650765e1
commit
c3a57ca68b
6 changed files with 80 additions and 8 deletions
|
@ -1104,7 +1104,7 @@ class Database {
|
||||||
$icon = $icon['id'];
|
$icon = $icon['id'];
|
||||||
} else {
|
} else {
|
||||||
// add the new icon to the cache
|
// add the new icon to the cache
|
||||||
$icon = $this->db->prepare("INSERT INTO arsee_icons(url, type, data) values(?, ?, ?", "str", "str", "blob")->run($feed->iconUrl, $feed->iconType, $feed->iconData)->lastId();
|
$icon = $this->db->prepare("INSERT INTO arsse_icons(url, type, data) values(?, ?, ?)", "str", "str", "blob")->run($feed->iconUrl, $feed->iconType, $feed->iconData)->lastId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// actually perform updates
|
// actually perform updates
|
||||||
|
@ -1258,9 +1258,9 @@ class Database {
|
||||||
* @param string $url The URL of the icon to Retrieve
|
* @param string $url The URL of the icon to Retrieve
|
||||||
* @param bool $withData Whether to return the icon content along with the metadata
|
* @param bool $withData Whether to return the icon content along with the metadata
|
||||||
*/
|
*/
|
||||||
protected function iconGetByUrl(string $url, bool $withData = true): array {
|
protected function iconGetByUrl(string $url, bool $withData = true): ?array {
|
||||||
$data = $withData ? "data" : "null as data";
|
$data = $withData ? "data" : "null as data";
|
||||||
return $this->db->prepare("SELECT id, url, type, $data, next_fetch from arsse_icons where url = ?", "str")->run($id)->getRow();
|
return $this->db->prepare("SELECT id, url, type, $data, next_fetch from arsse_icons where url = ?", "str")->run($url)->getRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,20 @@ trait SeriesFeed {
|
||||||
["john.doe@example.com", "",2],
|
["john.doe@example.com", "",2],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'arsse_icons' => [
|
||||||
|
'columns' => [
|
||||||
|
'id' => "int",
|
||||||
|
'url' => "str",
|
||||||
|
'type' => "str",
|
||||||
|
'data' => "blob",
|
||||||
|
],
|
||||||
|
'rows' => [
|
||||||
|
[1,'http://localhost:8000/Icon/PNG','image/png',base64_decode("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMjHxIGmVAAAADUlEQVQYV2NgYGBgAAAABQABijPjAAAAAABJRU5ErkJggg==")],
|
||||||
|
[2,'http://localhost:8000/Icon/GIF','image/gif',base64_decode("R0lGODlhAQABAIABAAAAAP///yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==")],
|
||||||
|
// this actually contains the data of SVG2, which will lead to a row update when retieved
|
||||||
|
[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' => [
|
'arsse_feeds' => [
|
||||||
'columns' => [
|
'columns' => [
|
||||||
'id' => "int",
|
'id' => "int",
|
||||||
|
@ -36,13 +50,19 @@ trait SeriesFeed {
|
||||||
'modified' => "datetime",
|
'modified' => "datetime",
|
||||||
'next_fetch' => "datetime",
|
'next_fetch' => "datetime",
|
||||||
'size' => "int",
|
'size' => "int",
|
||||||
|
'icon' => "int",
|
||||||
],
|
],
|
||||||
'rows' => [
|
'rows' => [
|
||||||
[1,"http://localhost:8000/Feed/Matching/3","Ook",0,"",$past,$past,0],
|
[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],
|
[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],
|
[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],
|
[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],
|
[5,"http://localhost:8000/Feed/Parsing/Valid","Ooook",0,"",$past,$future,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
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'arsse_subscriptions' => [
|
'arsse_subscriptions' => [
|
||||||
|
@ -261,4 +281,44 @@ trait SeriesFeed {
|
||||||
Arsse::$db->feedUpdate(4);
|
Arsse::$db->feedUpdate(4);
|
||||||
$this->assertEquals([1], Arsse::$db->feedListStale());
|
$this->assertEquals([1], Arsse::$db->feedListStale());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCheckIconDuringFeedUpdate(): void {
|
||||||
|
Arsse::$db->feedUpdate(6);
|
||||||
|
$state = $this->primeExpectations($this->data, [
|
||||||
|
'arsse_icons' => ["id","url","type","data"],
|
||||||
|
'arsse_feeds' => ["id", "icon"],
|
||||||
|
]);
|
||||||
|
$this->compareExpectations(static::$drv, $state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAssignIconDuringFeedUpdate(): void {
|
||||||
|
Arsse::$db->feedUpdate(7);
|
||||||
|
$state = $this->primeExpectations($this->data, [
|
||||||
|
'arsse_icons' => ["id","url","type","data"],
|
||||||
|
'arsse_feeds' => ["id", "icon"],
|
||||||
|
]);
|
||||||
|
$state['arsse_feeds']['rows'][6][1] = 2;
|
||||||
|
$this->compareExpectations(static::$drv, $state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testChangeIconDuringFeedUpdate(): void {
|
||||||
|
Arsse::$db->feedUpdate(8);
|
||||||
|
$state = $this->primeExpectations($this->data, [
|
||||||
|
'arsse_icons' => ["id","url","type","data"],
|
||||||
|
'arsse_feeds' => ["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->feedUpdate(9);
|
||||||
|
$state = $this->primeExpectations($this->data, [
|
||||||
|
'arsse_icons' => ["id","url","type","data"],
|
||||||
|
'arsse_feeds' => ["id", "icon"],
|
||||||
|
]);
|
||||||
|
$state['arsse_feeds']['rows'][8][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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
'content' => <<<MESSAGE_BODY
|
'content' => <<<MESSAGE_BODY
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||||
<icon>/Icon/GIF</icon>
|
<icon>/Icon/GIF</icon>
|
||||||
|
<entry>
|
||||||
|
<title>Example title</title>
|
||||||
|
</entry>
|
||||||
</feed>
|
</feed>
|
||||||
MESSAGE_BODY
|
MESSAGE_BODY
|
||||||
];
|
];
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
'content' => <<<MESSAGE_BODY
|
'content' => <<<MESSAGE_BODY
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||||
<icon>/Icon/PNG</icon>
|
<icon>/Icon/PNG</icon>
|
||||||
|
<entry>
|
||||||
|
<title>Example title</title>
|
||||||
|
</entry>
|
||||||
</feed>
|
</feed>
|
||||||
MESSAGE_BODY
|
MESSAGE_BODY
|
||||||
];
|
];
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
'content' => <<<MESSAGE_BODY
|
'content' => <<<MESSAGE_BODY
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||||
<icon>/Icon/SVG1</icon>
|
<icon>/Icon/SVG1</icon>
|
||||||
|
<entry>
|
||||||
|
<title>Example title</title>
|
||||||
|
</entry>
|
||||||
</feed>
|
</feed>
|
||||||
MESSAGE_BODY
|
MESSAGE_BODY
|
||||||
];
|
];
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
'content' => <<<MESSAGE_BODY
|
'content' => <<<MESSAGE_BODY
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||||
<icon>/Icon/SVG2</icon>
|
<icon>/Icon/SVG2</icon>
|
||||||
|
<entry>
|
||||||
|
<title>Example title</title>
|
||||||
|
</entry>
|
||||||
</feed>
|
</feed>
|
||||||
MESSAGE_BODY
|
MESSAGE_BODY
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue