mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-23 05:34:55 +00:00
Test filter rule retrieval
This commit is contained in:
parent
d66cf32c1f
commit
88cf3c6dae
2 changed files with 28 additions and 10 deletions
|
@ -1197,7 +1197,7 @@ class Database {
|
||||||
* - "block": The block rule; any article which matches this rule are hidden
|
* - "block": The block rule; any article which matches this rule are hidden
|
||||||
*/
|
*/
|
||||||
public function feedRulesGet(int $feedID): Db\Result {
|
public function feedRulesGet(int $feedID): Db\Result {
|
||||||
return $this->db->prepare("SELECT owner, keep_rule as keep, block_rule as block from arsse_subscriptions where feed = ? and (coalesce(keep_rule, '') || coalesce(block_rule, '')) <> ''", "int")->run($feedID);
|
return $this->db->prepare("SELECT owner, coalesce(keep_rule, '') as keep, coalesce(block_rule, '') as block from arsse_subscriptions where feed = ? and (keep || block) <> '' order by owner", "int")->run($feedID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Retrieves various identifiers for the latest $count articles in the given newsfeed. The identifiers are:
|
/** Retrieves various identifiers for the latest $count articles in the given newsfeed. The identifiers are:
|
||||||
|
|
|
@ -7,6 +7,7 @@ declare(strict_types=1);
|
||||||
namespace JKingWeb\Arsse\TestCase\Database;
|
namespace JKingWeb\Arsse\TestCase\Database;
|
||||||
|
|
||||||
use JKingWeb\Arsse\Arsse;
|
use JKingWeb\Arsse\Arsse;
|
||||||
|
use JKingWeb\Arsse\Test\Result;
|
||||||
|
|
||||||
trait SeriesFeed {
|
trait SeriesFeed {
|
||||||
protected function setUpSeriesFeed(): void {
|
protected function setUpSeriesFeed(): void {
|
||||||
|
@ -70,14 +71,16 @@ trait SeriesFeed {
|
||||||
'id' => "int",
|
'id' => "int",
|
||||||
'owner' => "str",
|
'owner' => "str",
|
||||||
'feed' => "int",
|
'feed' => "int",
|
||||||
|
'keep_rule' => "str",
|
||||||
|
'block_rule' => "str",
|
||||||
],
|
],
|
||||||
'rows' => [
|
'rows' => [
|
||||||
[1,'john.doe@example.com',1],
|
[1,'john.doe@example.com',1,null,'^Sport$'],
|
||||||
[2,'john.doe@example.com',2],
|
[2,'john.doe@example.com',2,null,null],
|
||||||
[3,'john.doe@example.com',3],
|
[3,'john.doe@example.com',3,'\w+',null],
|
||||||
[4,'john.doe@example.com',4],
|
[4,'john.doe@example.com',4,null,null],
|
||||||
[5,'john.doe@example.com',5],
|
[5,'john.doe@example.com',5,null,'and/or'],
|
||||||
[6,'jane.doe@example.com',1],
|
[6,'jane.doe@example.com',1,'^(?i)[a-z]+','bluberry'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'arsse_articles' => [
|
'arsse_articles' => [
|
||||||
|
@ -200,6 +203,21 @@ trait SeriesFeed {
|
||||||
$this->assertResult([['id' => 1]], Arsse::$db->feedMatchIds(1, ['e433653cef2e572eee4215fa299a4a5af9137b2cefd6283c85bd69a32915beda'])); // this ID appears in both feed 1 and feed 2; only one result should be returned
|
$this->assertResult([['id' => 1]], Arsse::$db->feedMatchIds(1, ['e433653cef2e572eee4215fa299a4a5af9137b2cefd6283c85bd69a32915beda'])); // this ID appears in both feed 1 and feed 2; only one result should be returned
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @dataProvider provideFilterRules */
|
||||||
|
public function testGetRules(int $in, array $exp): void {
|
||||||
|
$this->assertResult($exp, Arsse::$db->feedRulesGet($in));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideFilterRules(): iterable {
|
||||||
|
return [
|
||||||
|
[1, [['owner' => "john.doe@example.com", 'keep' => "", 'block' => "^Sport$"], ['owner' => "jane.doe@example.com", 'keep' => "^(?i)[a-z]+", 'block' => "bluberry"]]],
|
||||||
|
[2, []],
|
||||||
|
[3, [['owner' => "john.doe@example.com", 'keep' => '\w+', 'block' => ""]]],
|
||||||
|
[4, []],
|
||||||
|
[5, [['owner' => "john.doe@example.com", 'keep' => "", 'block' => "and/or"]]],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function testUpdateAFeed(): void {
|
public function testUpdateAFeed(): void {
|
||||||
// update a valid feed with both new and changed items
|
// update a valid feed with both new and changed items
|
||||||
Arsse::$db->feedUpdate(1);
|
Arsse::$db->feedUpdate(1);
|
||||||
|
|
Loading…
Reference in a new issue