@ -114,10 +114,10 @@ trait SeriesArticle {
[1,1,null,"Title one", null,null,null,"First article", null,"","","","2000-01-01T00:00:00Z"],
[1,1,null,"Title one", null,null,null,"First article", null,"","","","2000-01-01T00:00:00Z"],
[2,1,null,"Title two", null,null,null,"Second article",null,"","","","2010-01-01T00:00:00Z"],
[2,1,null,"Title two", null,null,null,"Second article",null,"","","","2010-01-01T00:00:00Z"],
[3,2,null,"Title three",null,null,null,"Third article", null,"","","","2000-01-01T00:00:00Z"],
[3,2,null,"Title three",null,null,null,"Third article", null,"","","","2000-01-01T00:00:00Z"],
[4,2,null,null,null ,null,null,null,null,"","","","2010-01-01T00:00:00Z"],
[4,2,null,null,"John Doe" ,null,null,null,null,"","","","2010-01-01T00:00:00Z"],
[5,3,null,null,null ,null,null,null,null,"","","","2000-01-01T00:00:00Z"],
[5,3,null,null,"John Doe" ,null,null,null,null,"","","","2000-01-01T00:00:00Z"],
[6,3,null,null,null ,null,null,null,null,"","","","2010-01-01T00:00:00Z"],
[6,3,null,null,"Jane Doe" ,null,null,null,null,"","","","2010-01-01T00:00:00Z"],
[7,4,null,null,null ,null,null,null,null,"","","","2000-01-01T00:00:00Z"],
[7,4,null,null,"Jane Doe" ,null,null,null,null,"","","","2000-01-01T00:00:00Z"],
[8,4,null,null,null,null,null,null,null,"","","","2010-01-01T00:00:00Z"],
[8,4,null,null,null,null,null,null,null,"","","","2010-01-01T00:00:00Z"],
[9,5,null,null,null,null,null,null,null,"","","","2000-01-01T00:00:00Z"],
[9,5,null,null,null,null,null,null,null,"","","","2000-01-01T00:00:00Z"],
[10,5,null,null,null,null,null,null,null,"","","","2010-01-01T00:00:00Z"],
[10,5,null,null,null,null,null,null,null,"","","","2010-01-01T00:00:00Z"],
@ -414,94 +414,76 @@ trait SeriesArticle {
$this->assertEquals($exp, Arsse::$db->editionArticle(...range(1, 1001)));
$this->assertEquals($exp, Arsse::$db->editionArticle(...range(1, 1001)));
}
}
public function testListArticlesCheckingContext() {
/** @dataProvider provideContextMatches */
$compareIds = function(array $exp, Context $c ) {
public function testListArticlesCheckingContext(Context $c, array $exp ) {
$ids = array_column($ids = Arsse::$db->articleList("john.doe@example.com", $c)->getAll(), "id");
$ids = array_column($ids = Arsse::$db->articleList("john.doe@example.com", $c)->getAll(), "id");
sort($ids);
sort($ids);
sort($exp);
sort($exp);
$this->assertEquals($exp, $ids);
$this->assertEquals($exp, $ids);
};
}
// get all items for user
$exp = [1,2,3,4,5,6,7,8,19,20];
public function provideContextMatches() {
$compareIds($exp, new Context);
return [
$compareIds($exp, (new Context)->articles(range(1, Database::LIMIT_ARTICLES * 3)));
"Blank context" => [new Context, [1,2,3,4,5,6,7,8,19,20]],
// get items from a folder tree
"Folder tree" => [(new Context)->folder(1), [5,6,7,8]],
$compareIds([5,6,7,8], (new Context)->folder(1));
"Leaf folder" => [(new Context)->folder(6), [7,8]],
// get items from a leaf folder
"Root folder only" => [(new Context)->folderShallow(0), [1,2,3,4]],
$compareIds([7,8], (new Context)->folder(6));
"Shallow folder" => [(new Context)->folderShallow(1), [5,6]],
// get items from a non-leaf folder without descending
"Subscription" => [(new Context)->subscription(5), [19,20]],
$compareIds([1,2,3,4], (new Context)->folderShallow(0));
"Unread" => [(new Context)->subscription(5)->unread(true), [20]],
$compareIds([5,6], (new Context)->folderShallow(1));
"Read" => [(new Context)->subscription(5)->unread(false), [19]],
// get items from a single subscription
"Starred" => [(new Context)->starred(true), [1,20]],
$exp = [19,20];
"Unstarred" => [(new Context)->starred(false), [2,3,4,5,6,7,8,19]],
$compareIds($exp, (new Context)->subscription(5));
"Starred and Read" => [(new Context)->starred(true)->unread(false), [1]],
// get un/read items from a single subscription
"Starred and Read in subscription" => [(new Context)->starred(true)->unread(false)->subscription(5), []],
$compareIds([20], (new Context)->subscription(5)->unread(true));
"Annotated" => [(new Context)->annotated(true), [2]],
$compareIds([19], (new Context)->subscription(5)->unread(false));
"Not annotated" => [(new Context)->annotated(false), [1,3,4,5,6,7,8,19,20]],
// get starred articles
"Labelled" => [(new Context)->labelled(true), [1,5,8,19,20]],
$compareIds([1,20], (new Context)->starred(true));
"Not labelled" => [(new Context)->labelled(false), [2,3,4,6,7]],
$compareIds([2,3,4,5,6,7,8,19], (new Context)->starred(false));
"Not after edition 999" => [(new Context)->subscription(5)->latestEdition(999), [19]],
$compareIds([1], (new Context)->starred(true)->unread(false));
"Not after edition 19" => [(new Context)->subscription(5)->latestEdition(19), [19]],
$compareIds([], (new Context)->starred(true)->unread(false)->subscription(5));
"Not before edition 999" => [(new Context)->subscription(5)->oldestEdition(999), [20]],
// get items relative to edition
"Not before edition 1001" => [(new Context)->subscription(5)->oldestEdition(1001), [20]],
$compareIds([19], (new Context)->subscription(5)->latestEdition(999));
"Not after article 3" => [(new Context)->latestArticle(3), [1,2,3]],
$compareIds([19], (new Context)->subscription(5)->latestEdition(19));
"Not before article 19" => [(new Context)->oldestArticle(19), [19,20]],
$compareIds([20], (new Context)->subscription(5)->oldestEdition(999));
"Modified by author since 2005" => [(new Context)->modifiedSince("2005-01-01T00:00:00Z"), [2,4,6,8,20]],
$compareIds([20], (new Context)->subscription(5)->oldestEdition(1001));
"Modified by author since 2010" => [(new Context)->modifiedSince("2010-01-01T00:00:00Z"), [2,4,6,8,20]],
// get items relative to article ID
"Not modified by author since 2005" => [(new Context)->notModifiedSince("2005-01-01T00:00:00Z"), [1,3,5,7,19]],
$compareIds([1,2,3], (new Context)->latestArticle(3));
"Not modified by author since 2000" => [(new Context)->notModifiedSince("2000-01-01T00:00:00Z"), [1,3,5,7,19]],
$compareIds([19,20], (new Context)->oldestArticle(19));
"Marked or labelled since 2014" => [(new Context)->markedSince("2014-01-01T00:00:00Z"), [8,19]],
// get items relative to (feed) modification date
"Marked or labelled since 2010" => [(new Context)->markedSince("2010-01-01T00:00:00Z"), [2,4,6,8,19,20]],
$exp = [2,4,6,8,20];
"Not marked or labelled since 2014" => [(new Context)->notMarkedSince("2014-01-01T00:00:00Z"), [1,2,3,4,5,6,7,20]],
$compareIds($exp, (new Context)->modifiedSince("2005-01-01T00:00:00Z"));
"Not marked or labelled since 2005" => [(new Context)->notMarkedSince("2005-01-01T00:00:00Z"), [1,3,5,7]],
$compareIds($exp, (new Context)->modifiedSince("2010-01-01T00:00:00Z"));
"Paged results" => [(new Context)->limit(2)->oldestEdition(4), [4,5]],
$exp = [1,3,5,7,19];
"Reversed paged results" => [(new Context)->limit(2)->latestEdition(7)->reverse(true), [7,6]],
$compareIds($exp, (new Context)->notModifiedSince("2005-01-01T00:00:00Z"));
"With label ID 1" => [(new Context)->label(1), [1,19]],
$compareIds($exp, (new Context)->notModifiedSince("2000-01-01T00:00:00Z"));
"With label ID 2" => [(new Context)->label(2), [1,5,20]],
// get items relative to (user) modification date (both marks and labels apply)
"With label 'Interesting'" => [(new Context)->labelName("Interesting"), [1,19]],
$compareIds([8,19], (new Context)->markedSince("2014-01-01T00:00:00Z"));
"With label 'Fascinating'" => [(new Context)->labelName("Fascinating"), [1,5,20]],
$compareIds([2,4,6,8,19,20], (new Context)->markedSince("2010-01-01T00:00:00Z"));
"Article ID 20" => [(new Context)->article(20), [20]],
$compareIds([1,2,3,4,5,6,7,20], (new Context)->notMarkedSince("2014-01-01T00:00:00Z"));
"Edition ID 1001" => [(new Context)->edition(1001), [20]],
$compareIds([1,3,5,7], (new Context)->notMarkedSince("2005-01-01T00:00:00Z"));
"Multiple articles" => [(new Context)->articles([1,20,50]), [1,20]],
// paged results
"Multiple starred articles" => [(new Context)->articles([1,2,3])->starred(true), [1]],
$compareIds([1], (new Context)->limit(1));
"Multiple unstarred articles" => [(new Context)->articles([1,2,3])->starred(false), [2,3]],
$compareIds([2], (new Context)->limit(1)->oldestEdition(1+1));
"Multiple articles" => [(new Context)->articles([1,20,50]), [1,20]],
$compareIds([3], (new Context)->limit(1)->oldestEdition(2+1));
"Multiple editions" => [(new Context)->editions([1,1001,50]), [1,20]],
$compareIds([4,5], (new Context)->limit(2)->oldestEdition(3+1));
"150 articles" => [(new Context)->articles(range(1, Database::LIMIT_ARTICLES * 3)), [1,2,3,4,5,6,7,8,19,20]],
// reversed results
"Search title or content 1" => [(new Context)->searchTerms(["Article"]), [1,2,3]],
$compareIds([20], (new Context)->reverse(true)->limit(1));
"Search title or content 2" => [(new Context)->searchTerms(["one", "first"]), [1]],
$compareIds([19], (new Context)->reverse(true)->limit(1)->latestEdition(1001-1));
"Search title or content 3" => [(new Context)->searchTerms(["one first"]), []],
$compareIds([8], (new Context)->reverse(true)->limit(1)->latestEdition(19-1));
"Search title 1" => [(new Context)->titleTerms(["two"]), [2]],
$compareIds([7,6], (new Context)->reverse(true)->limit(2)->latestEdition(8-1));
"Search title 2" => [(new Context)->titleTerms(["title two"]), [2]],
// get articles by label ID
"Search title 3" => [(new Context)->titleTerms(["two", "title"]), [2]],
$compareIds([1,19], (new Context)->label(1));
"Search title 4" => [(new Context)->titleTerms(["two title"]), []],
$compareIds([1,5,20], (new Context)->label(2));
"Search note 1" => [(new Context)->annotationTerms(["some"]), [2]],
// get articles by label name
"Search note 2" => [(new Context)->annotationTerms(["some Note"]), [2]],
$compareIds([1,19], (new Context)->labelName("Interesting"));
"Search note 3" => [(new Context)->annotationTerms(["note", "some"]), [2]],
$compareIds([1,5,20], (new Context)->labelName("Fascinating"));
"Search note 4" => [(new Context)->annotationTerms(["some", "sauce"]), []],
// get articles with any or no label
"Search author 1" => [(new Context)->authorTerms(["doe"]), [4,5,6,7]],
$compareIds([1,5,8,19,20], (new Context)->labelled(true));
"Search author 2" => [(new Context)->authorTerms(["jane doe"]), [6,7]],
$compareIds([2,3,4,6,7], (new Context)->labelled(false));
"Search author 3" => [(new Context)->authorTerms(["doe", "jane"]), [6,7]],
// get a specific article or edition
"Search author 4" => [(new Context)->authorTerms(["doe jane"]), []],
$compareIds([20], (new Context)->article(20));
];
$compareIds([20], (new Context)->edition(1001));
// get multiple specific articles or editions
$compareIds([1,20], (new Context)->articles([1,20,50]));
$compareIds([1,20], (new Context)->editions([1,1001,50]));
// get articles base on whether or not they have notes
$compareIds([1,3,4,5,6,7,8,19,20], (new Context)->annotated(false));
$compareIds([2], (new Context)->annotated(true));
// get specific starred articles
$compareIds([1], (new Context)->articles([1,2,3])->starred(true));
$compareIds([2,3], (new Context)->articles([1,2,3])->starred(false));
// get items that match search terms
$compareIds([1,2,3], (new Context)->searchTerms(["Article"]));
$compareIds([1], (new Context)->searchTerms(["one", "first"]));
// get items that match search terms in note
$compareIds([2], (new Context)->annotationTerms(["some"]));
$compareIds([2], (new Context)->annotationTerms(["some", "note"]));
$compareIds([2], (new Context)->annotationTerms(["some note"]));
$compareIds([], (new Context)->annotationTerms(["some", "sauce"]));
}
}
public function testListArticlesOfAMissingFolder() {
public function testListArticlesOfAMissingFolder() {