mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Retire article field groups
This commit is contained in:
parent
0129965bbd
commit
51755a2ce6
6 changed files with 128 additions and 145 deletions
|
@ -16,11 +16,6 @@ use JKingWeb\Arsse\Misc\ValueInfo;
|
||||||
class Database {
|
class Database {
|
||||||
const SCHEMA_VERSION = 4;
|
const SCHEMA_VERSION = 4;
|
||||||
const LIMIT_ARTICLES = 50;
|
const LIMIT_ARTICLES = 50;
|
||||||
// articleList verbosity levels
|
|
||||||
const LIST_MINIMAL = 0; // only that metadata which is required for context matching
|
|
||||||
const LIST_CONSERVATIVE = 1; // base metadata plus anything that is not potentially large text
|
|
||||||
const LIST_TYPICAL = 2; // conservative, with the addition of content
|
|
||||||
const LIST_FULL = 3; // all possible fields
|
|
||||||
|
|
||||||
/** @var Db\Driver */
|
/** @var Db\Driver */
|
||||||
public $db;
|
public $db;
|
||||||
|
@ -994,7 +989,7 @@ class Database {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function articleList(string $user, Context $context = null, int $fields = self::LIST_FULL): Db\Result {
|
public function articleList(string $user, Context $context = null, array $fields = ["id"]): Db\Result {
|
||||||
if (!Arsse::$user->authorize($user, __FUNCTION__)) {
|
if (!Arsse::$user->authorize($user, __FUNCTION__)) {
|
||||||
throw new User\ExceptionAuthz("notAuthorized", ["action" => __FUNCTION__, "user" => $user]);
|
throw new User\ExceptionAuthz("notAuthorized", ["action" => __FUNCTION__, "user" => $user]);
|
||||||
}
|
}
|
||||||
|
@ -1009,52 +1004,9 @@ class Database {
|
||||||
$tr->commit();
|
$tr->commit();
|
||||||
return new Db\ResultAggregate(...$out);
|
return new Db\ResultAggregate(...$out);
|
||||||
} else {
|
} else {
|
||||||
$columns = [];
|
$q = $this->articleQuery($user, $context, $fields);
|
||||||
switch ($fields) {
|
$q->setOrder("arsse_articles.edited".($context->reverse ? " desc" : ""));
|
||||||
// NOTE: the cases all cascade into each other: a given verbosity level is always a superset of the previous one
|
$q->setOrder("latest_editions.edition".($context->reverse ? " desc" : ""));
|
||||||
case self::LIST_FULL: // everything
|
|
||||||
$columns = array_merge($columns, [
|
|
||||||
"note",
|
|
||||||
]);
|
|
||||||
// no break
|
|
||||||
case self::LIST_TYPICAL: // conservative, plus content
|
|
||||||
$columns = array_merge($columns, [
|
|
||||||
"content",
|
|
||||||
"media_url", // enclosures are potentially large due to data: URLs
|
|
||||||
"media_type", // FIXME: enclosures should eventually have their own fetch method
|
|
||||||
]);
|
|
||||||
// no break
|
|
||||||
case self::LIST_CONSERVATIVE: // base metadata, plus anything that is not likely to be large text
|
|
||||||
$columns = array_merge($columns, [
|
|
||||||
"url",
|
|
||||||
"title",
|
|
||||||
"subscription_title",
|
|
||||||
"author",
|
|
||||||
"guid",
|
|
||||||
"published_date",
|
|
||||||
"edited_date",
|
|
||||||
"fingerprint",
|
|
||||||
]);
|
|
||||||
// no break
|
|
||||||
case self::LIST_MINIMAL: // base metadata (always included: required for context matching)
|
|
||||||
$columns = array_merge($columns, [
|
|
||||||
"id",
|
|
||||||
"subscription",
|
|
||||||
"feed",
|
|
||||||
"modified_date",
|
|
||||||
"marked_date",
|
|
||||||
"unread",
|
|
||||||
"starred",
|
|
||||||
"edition",
|
|
||||||
"edited_date",
|
|
||||||
]);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Exception("constantUnknown", $fields);
|
|
||||||
}
|
|
||||||
$q = $this->articleQuery($user, $context, $columns);
|
|
||||||
$q->setOrder("edited_date".($context->reverse ? " desc" : ""));
|
|
||||||
$q->setOrder("edition".($context->reverse ? " desc" : ""));
|
|
||||||
// perform the query and return results
|
// perform the query and return results
|
||||||
return $this->db->prepare($q->getQuery(), $q->getTypes())->run($q->getValues());
|
return $this->db->prepare($q->getQuery(), $q->getTypes())->run($q->getValues());
|
||||||
}
|
}
|
||||||
|
|
|
@ -563,7 +563,23 @@ class V1_2 extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
}
|
}
|
||||||
// perform the fetch
|
// perform the fetch
|
||||||
try {
|
try {
|
||||||
$items = Arsse::$db->articleList(Arsse::$user->id, $c, Database::LIST_TYPICAL);
|
$items = Arsse::$db->articleList(Arsse::$user->id, $c, [
|
||||||
|
"edition",
|
||||||
|
"guid",
|
||||||
|
"id",
|
||||||
|
"url",
|
||||||
|
"title",
|
||||||
|
"author",
|
||||||
|
"edited_date",
|
||||||
|
"content",
|
||||||
|
"media_type",
|
||||||
|
"media_url",
|
||||||
|
"subscription",
|
||||||
|
"unread",
|
||||||
|
"starred",
|
||||||
|
"modified_date",
|
||||||
|
"fingerprint",
|
||||||
|
]);
|
||||||
} catch (ExceptionInput $e) {
|
} catch (ExceptionInput $e) {
|
||||||
// ID of subscription or folder is not valid
|
// ID of subscription or folder is not valid
|
||||||
return new EmptyResponse(422);
|
return new EmptyResponse(422);
|
||||||
|
|
|
@ -1113,8 +1113,8 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
$out += Arsse::$db->articleMark(Arsse::$user->id, ['starred' => (bool) $data['mode']], (new Context)->articles($articles));
|
$out += Arsse::$db->articleMark(Arsse::$user->id, ['starred' => (bool) $data['mode']], (new Context)->articles($articles));
|
||||||
break;
|
break;
|
||||||
case 2: //toggle
|
case 2: //toggle
|
||||||
$on = array_column(Arsse::$db->articleList(Arsse::$user->id, (new Context)->articles($articles)->starred(true), Database::LIST_MINIMAL)->getAll(), "id");
|
$on = array_column(Arsse::$db->articleList(Arsse::$user->id, (new Context)->articles($articles)->starred(true), ["id"])->getAll(), "id");
|
||||||
$off = array_column(Arsse::$db->articleList(Arsse::$user->id, (new Context)->articles($articles)->starred(false), Database::LIST_MINIMAL)->getAll(), "id");
|
$off = array_column(Arsse::$db->articleList(Arsse::$user->id, (new Context)->articles($articles)->starred(false), ["id"])->getAll(), "id");
|
||||||
if ($off) {
|
if ($off) {
|
||||||
$out += Arsse::$db->articleMark(Arsse::$user->id, ['starred' => true], (new Context)->articles($off));
|
$out += Arsse::$db->articleMark(Arsse::$user->id, ['starred' => true], (new Context)->articles($off));
|
||||||
}
|
}
|
||||||
|
@ -1145,8 +1145,8 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
$out += Arsse::$db->articleMark(Arsse::$user->id, ['read' => !$data['mode']], (new Context)->articles($articles));
|
$out += Arsse::$db->articleMark(Arsse::$user->id, ['read' => !$data['mode']], (new Context)->articles($articles));
|
||||||
break;
|
break;
|
||||||
case 2: //toggle
|
case 2: //toggle
|
||||||
$on = array_column(Arsse::$db->articleList(Arsse::$user->id, (new Context)->articles($articles)->unread(true), Database::LIST_MINIMAL)->getAll(), "id");
|
$on = array_column(Arsse::$db->articleList(Arsse::$user->id, (new Context)->articles($articles)->unread(true), ["id"])->getAll(), "id");
|
||||||
$off = array_column(Arsse::$db->articleList(Arsse::$user->id, (new Context)->articles($articles)->unread(false), Database::LIST_MINIMAL)->getAll(), "id");
|
$off = array_column(Arsse::$db->articleList(Arsse::$user->id, (new Context)->articles($articles)->unread(false), ["id"])->getAll(), "id");
|
||||||
if ($off) {
|
if ($off) {
|
||||||
$out += Arsse::$db->articleMark(Arsse::$user->id, ['read' => false], (new Context)->articles($off));
|
$out += Arsse::$db->articleMark(Arsse::$user->id, ['read' => false], (new Context)->articles($off));
|
||||||
}
|
}
|
||||||
|
@ -1183,7 +1183,22 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
}
|
}
|
||||||
// retrieve the requested articles
|
// retrieve the requested articles
|
||||||
$out = [];
|
$out = [];
|
||||||
foreach (Arsse::$db->articleList(Arsse::$user->id, (new Context)->articles($articles)) as $article) {
|
$columns = [
|
||||||
|
"id",
|
||||||
|
"guid",
|
||||||
|
"title",
|
||||||
|
"url",
|
||||||
|
"unread",
|
||||||
|
"starred",
|
||||||
|
"edited_date",
|
||||||
|
"subscription",
|
||||||
|
"subscription_title",
|
||||||
|
"note",
|
||||||
|
"content",
|
||||||
|
"media_url",
|
||||||
|
"media_type",
|
||||||
|
];
|
||||||
|
foreach (Arsse::$db->articleList(Arsse::$user->id, (new Context)->articles($articles), $columns) as $article) {
|
||||||
$out[] = [
|
$out[] = [
|
||||||
'id' => (string) $article['id'], // string cast to be consistent with TTRSS
|
'id' => (string) $article['id'], // string cast to be consistent with TTRSS
|
||||||
'guid' => $article['guid'] ? "SHA256:".$article['guid'] : null,
|
'guid' => $article['guid'] ? "SHA256:".$article['guid'] : null,
|
||||||
|
@ -1246,7 +1261,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
// fetch the list of IDs
|
// fetch the list of IDs
|
||||||
$out = [];
|
$out = [];
|
||||||
try {
|
try {
|
||||||
foreach ($this->fetchArticles($data, Database::LIST_MINIMAL) as $row) {
|
foreach ($this->fetchArticles($data, ["id"]) as $row) {
|
||||||
$out[] = ['id' => (int) $row['id']];
|
$out[] = ['id' => (int) $row['id']];
|
||||||
}
|
}
|
||||||
} catch (ExceptionInput $e) {
|
} catch (ExceptionInput $e) {
|
||||||
|
@ -1267,7 +1282,23 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
// retrieve the requested articles
|
// retrieve the requested articles
|
||||||
$out = [];
|
$out = [];
|
||||||
try {
|
try {
|
||||||
foreach ($this->fetchArticles($data, Database::LIST_FULL) as $article) {
|
$columns = [
|
||||||
|
"id",
|
||||||
|
"guid",
|
||||||
|
"title",
|
||||||
|
"url",
|
||||||
|
"unread",
|
||||||
|
"starred",
|
||||||
|
"edited_date",
|
||||||
|
"published_date",
|
||||||
|
"subscription",
|
||||||
|
"subscription_title",
|
||||||
|
"note",
|
||||||
|
($data['show_content'] || $data['show_excerpt']) ? "content" : "",
|
||||||
|
($data['include_attachments']) ? "media_url": "",
|
||||||
|
($data['include_attachments']) ? "media_type": "",
|
||||||
|
];
|
||||||
|
foreach ($this->fetchArticles($data, $columns) as $article) {
|
||||||
$row = [
|
$row = [
|
||||||
'id' => (int) $article['id'],
|
'id' => (int) $article['id'],
|
||||||
'guid' => $article['guid'] ? "SHA256:".$article['guid'] : "",
|
'guid' => $article['guid'] ? "SHA256:".$article['guid'] : "",
|
||||||
|
@ -1325,7 +1356,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
// when paginating the header returns the latest ("first") item ID in the full list; we get this ID here
|
// when paginating the header returns the latest ("first") item ID in the full list; we get this ID here
|
||||||
$data['skip'] = 0;
|
$data['skip'] = 0;
|
||||||
$data['limit'] = 1;
|
$data['limit'] = 1;
|
||||||
$firstID = ($this->fetchArticles($data, Database::LIST_MINIMAL)->getRow() ?? ['id' => 0])['id'];
|
$firstID = ($this->fetchArticles($data, ["id"])->getRow() ?? ['id' => 0])['id'];
|
||||||
} elseif ($data['order_by']=="date_reverse") {
|
} elseif ($data['order_by']=="date_reverse") {
|
||||||
// the "date_reverse" sort order doesn't get a first ID because it's meaningless for ascending-order pagination (pages doesn't go stale)
|
// the "date_reverse" sort order doesn't get a first ID because it's meaningless for ascending-order pagination (pages doesn't go stale)
|
||||||
$firstID = 0;
|
$firstID = 0;
|
||||||
|
@ -1346,7 +1377,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function fetchArticles(array $data, int $fields): \JKingWeb\Arsse\Db\Result {
|
protected function fetchArticles(array $data, array $fields): \JKingWeb\Arsse\Db\Result {
|
||||||
// normalize input
|
// normalize input
|
||||||
if (is_null($data['feed_id'])) {
|
if (is_null($data['feed_id'])) {
|
||||||
throw new Exception("INCORRECT_USAGE");
|
throw new Exception("INCORRECT_USAGE");
|
||||||
|
|
|
@ -364,24 +364,10 @@ trait SeriesArticle {
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$this->fields = [
|
$this->fields = [
|
||||||
Database::LIST_MINIMAL => [
|
|
||||||
"id", "subscription", "feed", "modified_date", "marked_date", "unread", "starred", "edition", "edited_date",
|
|
||||||
],
|
|
||||||
Database::LIST_CONSERVATIVE => [
|
|
||||||
"id", "subscription", "feed", "modified_date", "marked_date", "unread", "starred", "edition", "edited_date",
|
|
||||||
"url", "title", "subscription_title", "author", "guid", "published_date", "fingerprint",
|
|
||||||
],
|
|
||||||
Database::LIST_TYPICAL => [
|
|
||||||
"id", "subscription", "feed", "modified_date", "marked_date", "unread", "starred", "edition", "edited_date",
|
|
||||||
"url", "title", "subscription_title", "author", "guid", "published_date", "fingerprint",
|
|
||||||
"content", "media_url", "media_type",
|
|
||||||
],
|
|
||||||
Database::LIST_FULL => [
|
|
||||||
"id", "subscription", "feed", "modified_date", "marked_date", "unread", "starred", "edition", "edited_date",
|
"id", "subscription", "feed", "modified_date", "marked_date", "unread", "starred", "edition", "edited_date",
|
||||||
"url", "title", "subscription_title", "author", "guid", "published_date", "fingerprint",
|
"url", "title", "subscription_title", "author", "guid", "published_date", "fingerprint",
|
||||||
"content", "media_url", "media_type",
|
"content", "media_url", "media_type",
|
||||||
"note",
|
"note",
|
||||||
],
|
|
||||||
];
|
];
|
||||||
$this->checkTables = ['arsse_marks' => ["subscription","article","read","starred","modified","note"],];
|
$this->checkTables = ['arsse_marks' => ["subscription","article","read","starred","modified","note"],];
|
||||||
$this->user = "john.doe@example.net";
|
$this->user = "john.doe@example.net";
|
||||||
|
@ -522,17 +508,15 @@ trait SeriesArticle {
|
||||||
|
|
||||||
public function testListArticlesCheckingProperties() {
|
public function testListArticlesCheckingProperties() {
|
||||||
$this->user = "john.doe@example.org";
|
$this->user = "john.doe@example.org";
|
||||||
$this->assertResult($this->matches, Arsse::$db->articleList($this->user));
|
|
||||||
// check that the different fieldset groups return the expected columns
|
// check that the different fieldset groups return the expected columns
|
||||||
foreach ($this->fields as $constant => $columns) {
|
foreach ($this->fields as $column) {
|
||||||
$test = array_keys(Arsse::$db->articleList($this->user, (new Context)->article(101), $constant)->getRow());
|
$test = array_keys(Arsse::$db->articleList($this->user, (new Context)->article(101), [$column])->getRow());
|
||||||
sort($columns);
|
$this->assertEquals([$column], $test);
|
||||||
sort($test);
|
|
||||||
$this->assertEquals($columns, $test, "Fields do not match expectation for verbosity $constant");
|
|
||||||
}
|
}
|
||||||
// check that an unknown fieldset produces an exception
|
// check that an unknown field is silently ignored
|
||||||
$this->assertException("constantUnknown");
|
$columns = array_merge($this->fields, ["unknown_column", "bogus_column"]);
|
||||||
Arsse::$db->articleList($this->user, (new Context)->article(101), \PHP_INT_MAX);
|
$test = array_keys(Arsse::$db->articleList($this->user, (new Context)->article(101), $columns)->getRow());
|
||||||
|
$this->assertEquals($this->fields, $test);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testListArticlesWithoutAuthority() {
|
public function testListArticlesWithoutAuthority() {
|
||||||
|
|
|
@ -734,11 +734,11 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
['lastModified' => $t->getTimestamp()],
|
['lastModified' => $t->getTimestamp()],
|
||||||
['oldestFirst' => false, 'batchSize' => 5, 'offset' => 0], // offset=0 should not set the latestEdition context
|
['oldestFirst' => false, 'batchSize' => 5, 'offset' => 0], // offset=0 should not set the latestEdition context
|
||||||
];
|
];
|
||||||
Phake::when(Arsse::$db)->articleList(Arsse::$user->id, $this->anything(), Database::LIST_TYPICAL)->thenReturn(new Result($this->v($this->articles['db'])));
|
Phake::when(Arsse::$db)->articleList(Arsse::$user->id, $this->anything(), $this->anything())->thenReturn(new Result($this->v($this->articles['db'])));
|
||||||
Phake::when(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->subscription(42), Database::LIST_TYPICAL)->thenThrow(new ExceptionInput("idMissing"));
|
Phake::when(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->subscription(42), $this->anything())->thenThrow(new ExceptionInput("idMissing"));
|
||||||
Phake::when(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->folder(2112), Database::LIST_TYPICAL)->thenThrow(new ExceptionInput("idMissing"));
|
Phake::when(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->folder(2112), $this->anything())->thenThrow(new ExceptionInput("idMissing"));
|
||||||
Phake::when(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->subscription(-1), Database::LIST_TYPICAL)->thenThrow(new ExceptionInput("typeViolation"));
|
Phake::when(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->subscription(-1), $this->anything())->thenThrow(new ExceptionInput("typeViolation"));
|
||||||
Phake::when(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->folder(-1), Database::LIST_TYPICAL)->thenThrow(new ExceptionInput("typeViolation"));
|
Phake::when(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->folder(-1), $this->anything())->thenThrow(new ExceptionInput("typeViolation"));
|
||||||
$exp = new Response(['items' => $this->articles['rest']]);
|
$exp = new Response(['items' => $this->articles['rest']]);
|
||||||
// check the contents of the response
|
// check the contents of the response
|
||||||
$this->assertMessage($exp, $this->req("GET", "/items")); // first instance of base context
|
$this->assertMessage($exp, $this->req("GET", "/items")); // first instance of base context
|
||||||
|
@ -759,17 +759,17 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
$this->req("GET", "/items", json_encode($in[10]));
|
$this->req("GET", "/items", json_encode($in[10]));
|
||||||
$this->req("GET", "/items", json_encode($in[11]));
|
$this->req("GET", "/items", json_encode($in[11]));
|
||||||
// perform method verifications
|
// perform method verifications
|
||||||
Phake::verify(Arsse::$db, Phake::times(4))->articleList(Arsse::$user->id, (new Context)->reverse(true), Database::LIST_TYPICAL);
|
Phake::verify(Arsse::$db, Phake::times(4))->articleList(Arsse::$user->id, (new Context)->reverse(true), $this->anything());
|
||||||
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->subscription(42), Database::LIST_TYPICAL);
|
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->subscription(42), $this->anything());
|
||||||
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->folder(2112), Database::LIST_TYPICAL);
|
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->folder(2112), $this->anything());
|
||||||
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->subscription(-1), Database::LIST_TYPICAL);
|
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->subscription(-1), $this->anything());
|
||||||
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->folder(-1), Database::LIST_TYPICAL);
|
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->folder(-1), $this->anything());
|
||||||
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->starred(true), Database::LIST_TYPICAL);
|
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->starred(true), $this->anything());
|
||||||
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(false)->limit(10)->oldestEdition(6), Database::LIST_TYPICAL); // offset is one more than specified
|
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(false)->limit(10)->oldestEdition(6), $this->anything()); // offset is one more than specified
|
||||||
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->limit(5)->latestEdition(4), Database::LIST_TYPICAL); // offset is one less than specified
|
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->limit(5)->latestEdition(4), $this->anything()); // offset is one less than specified
|
||||||
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->unread(true), Database::LIST_TYPICAL);
|
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->unread(true), $this->anything());
|
||||||
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->markedSince($t), Database::LIST_TYPICAL);
|
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->markedSince($t), $this->anything());
|
||||||
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->limit(5), Database::LIST_TYPICAL);
|
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(true)->limit(5), $this->anything());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMarkAFolderRead() {
|
public function testMarkAFolderRead() {
|
||||||
|
@ -958,6 +958,6 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
$url = "/items?type=2";
|
$url = "/items?type=2";
|
||||||
Phake::when(Arsse::$db)->articleList->thenReturn(new Result([]));
|
Phake::when(Arsse::$db)->articleList->thenReturn(new Result([]));
|
||||||
$this->req("GET", $url, json_encode($in));
|
$this->req("GET", $url, json_encode($in));
|
||||||
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(false)->starred(true), Database::LIST_TYPICAL);
|
Phake::verify(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->reverse(false)->starred(true), $this->anything());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1641,9 +1641,9 @@ LONG_STRING;
|
||||||
Phake::when(Arsse::$db)->labelList($this->anything(), false)->thenReturn(new Result($this->v($this->usedLabels)));
|
Phake::when(Arsse::$db)->labelList($this->anything(), false)->thenReturn(new Result($this->v($this->usedLabels)));
|
||||||
Phake::when(Arsse::$db)->articleLabelsGet($this->anything(), 101)->thenReturn([]);
|
Phake::when(Arsse::$db)->articleLabelsGet($this->anything(), 101)->thenReturn([]);
|
||||||
Phake::when(Arsse::$db)->articleLabelsGet($this->anything(), 102)->thenReturn($this->v([1,3]));
|
Phake::when(Arsse::$db)->articleLabelsGet($this->anything(), 102)->thenReturn($this->v([1,3]));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (new Context)->articles([101, 102]))->thenReturn(new Result($this->v($this->articles)));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (new Context)->articles([101, 102]), $this->anything())->thenReturn(new Result($this->v($this->articles)));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (new Context)->articles([101]))->thenReturn(new Result($this->v([$this->articles[0]])));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (new Context)->articles([101]), $this->anything())->thenReturn(new Result($this->v([$this->articles[0]])));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (new Context)->articles([102]))->thenReturn(new Result($this->v([$this->articles[1]])));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (new Context)->articles([102]), $this->anything())->thenReturn(new Result($this->v([$this->articles[1]])));
|
||||||
$exp = $this->respErr("INCORRECT_USAGE");
|
$exp = $this->respErr("INCORRECT_USAGE");
|
||||||
$this->assertMessage($exp, $this->req($in[0]));
|
$this->assertMessage($exp, $this->req($in[0]));
|
||||||
$this->assertMessage($exp, $this->req($in[1]));
|
$this->assertMessage($exp, $this->req($in[1]));
|
||||||
|
@ -1750,18 +1750,18 @@ LONG_STRING;
|
||||||
Phake::when(Arsse::$db)->articleCount->thenReturn(0);
|
Phake::when(Arsse::$db)->articleCount->thenReturn(0);
|
||||||
Phake::when(Arsse::$db)->articleCount($this->anything(), (new Context)->unread(true))->thenReturn(1);
|
Phake::when(Arsse::$db)->articleCount($this->anything(), (new Context)->unread(true))->thenReturn(1);
|
||||||
$c = (new Context)->reverse(true);
|
$c = (new Context)->reverse(true);
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->subscription(2112), Database::LIST_MINIMAL)->thenThrow(new ExceptionInput("subjectMissing"));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->subscription(2112), ["id"])->thenThrow(new ExceptionInput("subjectMissing"));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), $c, Database::LIST_MINIMAL)->thenReturn(new Result($this->v($this->articles)));
|
Phake::when(Arsse::$db)->articleList($this->anything(), $c, ["id"])->thenReturn(new Result($this->v($this->articles)));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->starred(true), Database::LIST_MINIMAL)->thenReturn(new Result($this->v([['id' => 1]])));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->starred(true), ["id"])->thenReturn(new Result($this->v([['id' => 1]])));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->label(1088), Database::LIST_MINIMAL)->thenReturn(new Result($this->v([['id' => 2]])));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->label(1088), ["id"])->thenReturn(new Result($this->v([['id' => 2]])));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->unread(true), Database::LIST_MINIMAL)->thenReturn(new Result($this->v([['id' => 3]])));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->unread(true), ["id"])->thenReturn(new Result($this->v([['id' => 3]])));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->label(1088)->unread(true), Database::LIST_MINIMAL)->thenReturn(new Result($this->v([['id' => 4]])));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->label(1088)->unread(true), ["id"])->thenReturn(new Result($this->v([['id' => 4]])));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->subscription(42)->starred(true), Database::LIST_MINIMAL)->thenReturn(new Result($this->v([['id' => 5]])));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->subscription(42)->starred(true), ["id"])->thenReturn(new Result($this->v([['id' => 5]])));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->subscription(42)->annotated(true), Database::LIST_MINIMAL)->thenReturn(new Result($this->v([['id' => 6]])));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->subscription(42)->annotated(true), ["id"])->thenReturn(new Result($this->v([['id' => 6]])));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->limit(5), Database::LIST_MINIMAL)->thenReturn(new Result($this->v([['id' => 7]])));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->limit(5), ["id"])->thenReturn(new Result($this->v([['id' => 7]])));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->offset(2), Database::LIST_MINIMAL)->thenReturn(new Result($this->v([['id' => 8]])));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->offset(2), ["id"])->thenReturn(new Result($this->v([['id' => 8]])));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->limit(5)->offset(2), Database::LIST_MINIMAL)->thenReturn(new Result($this->v([['id' => 9]])));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->limit(5)->offset(2), ["id"])->thenReturn(new Result($this->v([['id' => 9]])));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->oldestArticle(48), Database::LIST_MINIMAL)->thenReturn(new Result($this->v([['id' => 10]])));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->oldestArticle(48), ["id"])->thenReturn(new Result($this->v([['id' => 10]])));
|
||||||
$out1 = [
|
$out1 = [
|
||||||
$this->respErr("INCORRECT_USAGE"),
|
$this->respErr("INCORRECT_USAGE"),
|
||||||
$this->respGood([]),
|
$this->respGood([]),
|
||||||
|
@ -1793,9 +1793,9 @@ LONG_STRING;
|
||||||
$this->assertMessage($out1[$a], $this->req($in1[$a]), "Test $a failed");
|
$this->assertMessage($out1[$a], $this->req($in1[$a]), "Test $a failed");
|
||||||
}
|
}
|
||||||
for ($a = 0; $a < sizeof($in2); $a++) {
|
for ($a = 0; $a < sizeof($in2); $a++) {
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->unread(false)->markedSince(Date::sub("PT24H")), Database::LIST_MINIMAL)->thenReturn(new Result($this->v([['id' => 1001]])));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->unread(false)->markedSince(Date::sub("PT24H")), ["id"])->thenReturn(new Result($this->v([['id' => 1001]])));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->unread(true)->modifiedSince(Date::sub("PT24H")), Database::LIST_MINIMAL)->thenReturn(new Result($this->v([['id' => 1002]])));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->unread(true)->modifiedSince(Date::sub("PT24H")), ["id"])->thenReturn(new Result($this->v([['id' => 1002]])));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->unread(true)->modifiedSince(Date::sub("PT24H"))->starred(true), Database::LIST_MINIMAL)->thenReturn(new Result($this->v([['id' => 1003]])));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->unread(true)->modifiedSince(Date::sub("PT24H"))->starred(true), ["id"])->thenReturn(new Result($this->v([['id' => 1003]])));
|
||||||
$this->assertMessage($out2[$a], $this->req($in2[$a]), "Test $a failed");
|
$this->assertMessage($out2[$a], $this->req($in2[$a]), "Test $a failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1851,23 +1851,23 @@ LONG_STRING;
|
||||||
Phake::when(Arsse::$db)->articleCount->thenReturn(0);
|
Phake::when(Arsse::$db)->articleCount->thenReturn(0);
|
||||||
Phake::when(Arsse::$db)->articleCount($this->anything(), (new Context)->unread(true))->thenReturn(1);
|
Phake::when(Arsse::$db)->articleCount($this->anything(), (new Context)->unread(true))->thenReturn(1);
|
||||||
$c = (new Context)->limit(200)->reverse(true);
|
$c = (new Context)->limit(200)->reverse(true);
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->subscription(2112), Database::LIST_FULL)->thenThrow(new ExceptionInput("subjectMissing"));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->subscription(2112), $this->anything())->thenThrow(new ExceptionInput("subjectMissing"));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->starred(true), Database::LIST_FULL)->thenReturn($this->generateHeadlines(1));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->starred(true), $this->anything())->thenReturn($this->generateHeadlines(1));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->label(1088), Database::LIST_FULL)->thenReturn($this->generateHeadlines(2));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->label(1088), $this->anything())->thenReturn($this->generateHeadlines(2));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->unread(true), Database::LIST_FULL)->thenReturn($this->generateHeadlines(3));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->unread(true), $this->anything())->thenReturn($this->generateHeadlines(3));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->label(1088)->unread(true), Database::LIST_FULL)->thenReturn($this->generateHeadlines(4));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->label(1088)->unread(true), $this->anything())->thenReturn($this->generateHeadlines(4));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->subscription(42)->starred(true), Database::LIST_FULL)->thenReturn($this->generateHeadlines(5));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->subscription(42)->starred(true), $this->anything())->thenReturn($this->generateHeadlines(5));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->subscription(42)->annotated(true), Database::LIST_FULL)->thenReturn($this->generateHeadlines(6));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->subscription(42)->annotated(true), $this->anything())->thenReturn($this->generateHeadlines(6));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->limit(5), Database::LIST_FULL)->thenReturn($this->generateHeadlines(7));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->limit(5), $this->anything())->thenReturn($this->generateHeadlines(7));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->offset(2), Database::LIST_FULL)->thenReturn($this->generateHeadlines(8));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->offset(2), $this->anything())->thenReturn($this->generateHeadlines(8));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->limit(5)->offset(2), Database::LIST_FULL)->thenReturn($this->generateHeadlines(9));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->limit(5)->offset(2), $this->anything())->thenReturn($this->generateHeadlines(9));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->oldestArticle(48), Database::LIST_FULL)->thenReturn($this->generateHeadlines(10));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->oldestArticle(48), $this->anything())->thenReturn($this->generateHeadlines(10));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c), Database::LIST_FULL)->thenReturn($this->generateHeadlines(11));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c), $this->anything())->thenReturn($this->generateHeadlines(11));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->labelled(true), Database::LIST_FULL)->thenReturn($this->generateHeadlines(12));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->labelled(true), $this->anything())->thenReturn($this->generateHeadlines(12));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->folderShallow(0), Database::LIST_FULL)->thenReturn($this->generateHeadlines(13));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->folderShallow(0), $this->anything())->thenReturn($this->generateHeadlines(13));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->folderShallow(42), Database::LIST_FULL)->thenReturn($this->generateHeadlines(14));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->folderShallow(42), $this->anything())->thenReturn($this->generateHeadlines(14));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->folder(42), Database::LIST_FULL)->thenReturn($this->generateHeadlines(15));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->folder(42), $this->anything())->thenReturn($this->generateHeadlines(15));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->reverse(false), Database::LIST_FULL)->thenReturn($this->generateHeadlines(16));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->reverse(false), $this->anything())->thenReturn($this->generateHeadlines(16));
|
||||||
$out2 = [
|
$out2 = [
|
||||||
$this->respErr("INCORRECT_USAGE"),
|
$this->respErr("INCORRECT_USAGE"),
|
||||||
$this->outputHeadlines(11),
|
$this->outputHeadlines(11),
|
||||||
|
@ -1904,9 +1904,9 @@ LONG_STRING;
|
||||||
$this->assertMessage($out2[$a], $this->req($in2[$a]), "Test $a failed");
|
$this->assertMessage($out2[$a], $this->req($in2[$a]), "Test $a failed");
|
||||||
}
|
}
|
||||||
for ($a = 0; $a < sizeof($in3); $a++) {
|
for ($a = 0; $a < sizeof($in3); $a++) {
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->unread(false)->markedSince(Date::sub("PT24H")), Database::LIST_FULL)->thenReturn($this->generateHeadlines(1001));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->unread(false)->markedSince(Date::sub("PT24H")), $this->anything())->thenReturn($this->generateHeadlines(1001));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->unread(true)->modifiedSince(Date::sub("PT24H")), Database::LIST_FULL)->thenReturn($this->generateHeadlines(1002));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->unread(true)->modifiedSince(Date::sub("PT24H")), $this->anything())->thenReturn($this->generateHeadlines(1002));
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->unread(true)->modifiedSince(Date::sub("PT24H"))->starred(true), Database::LIST_FULL)->thenReturn($this->generateHeadlines(1003));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (clone $c)->unread(true)->modifiedSince(Date::sub("PT24H"))->starred(true), $this->anything())->thenReturn($this->generateHeadlines(1003));
|
||||||
$this->assertMessage($out3[$a], $this->req($in3[$a]), "Test $a failed");
|
$this->assertMessage($out3[$a], $this->req($in3[$a]), "Test $a failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2000,7 +2000,7 @@ LONG_STRING;
|
||||||
]);
|
]);
|
||||||
$this->assertMessage($exp, $test);
|
$this->assertMessage($exp, $test);
|
||||||
// test 'include_header' with skip
|
// test 'include_header' with skip
|
||||||
Phake::when(Arsse::$db)->articleList($this->anything(), (new Context)->reverse(true)->limit(1)->subscription(42), Database::LIST_MINIMAL)->thenReturn($this->generateHeadlines(1867));
|
Phake::when(Arsse::$db)->articleList($this->anything(), (new Context)->reverse(true)->limit(1)->subscription(42), $this->anything())->thenReturn($this->generateHeadlines(1867));
|
||||||
$test = $this->req($in[8]);
|
$test = $this->req($in[8]);
|
||||||
$exp = $this->respGood([
|
$exp = $this->respGood([
|
||||||
['id' => 42, 'is_cat' => false, 'first_id' => 1867],
|
['id' => 42, 'is_cat' => false, 'first_id' => 1867],
|
||||||
|
|
Loading…
Reference in a new issue