1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 21:22:40 +00:00

Style fixes

This commit is contained in:
J. King 2020-03-01 15:16:50 -05:00
parent a7f69c845f
commit bc53a2d24a
89 changed files with 1638 additions and 1664 deletions

View file

@ -121,7 +121,7 @@ class RoboFile extends \Robo\Tasks {
return $all ? ">$hole 2>&1" : "2>$hole"; return $all ? ">$hole 2>&1" : "2>$hole";
} }
protected function runTests(string $executor, string $set, array $args) : Result { protected function runTests(string $executor, string $set, array $args): Result {
switch ($set) { switch ($set) {
case "typical": case "typical":
$set = ["--exclude-group", "optional"]; $set = ["--exclude-group", "optional"];

View file

@ -3,6 +3,7 @@
* Copyright 2017 J. King, Dustin Wilson et al. * Copyright 2017 J. King, Dustin Wilson et al.
* See LICENSE and AUTHORS files for details */ * See LICENSE and AUTHORS files for details */
declare(strict_types=1);
namespace JKingWeb\Arsse; namespace JKingWeb\Arsse;
const BASE = __DIR__.DIRECTORY_SEPARATOR; const BASE = __DIR__.DIRECTORY_SEPARATOR;
@ -13,7 +14,6 @@ ignore_user_abort(true);
ini_set("memory_limit", "-1"); ini_set("memory_limit", "-1");
ini_set("max_execution_time", "0"); ini_set("max_execution_time", "0");
if (\PHP_SAPI === "cli") { if (\PHP_SAPI === "cli") {
// initialize the CLI; this automatically handles --help and --version // initialize the CLI; this automatically handles --help and --version
$cli = new CLI; $cli = new CLI;

View file

@ -379,7 +379,7 @@ class Database {
$max = Date::add(Arsse::$conf->userSessionTimeout, $now)->getTimestamp(); $max = Date::add(Arsse::$conf->userSessionTimeout, $now)->getTimestamp();
$diff = intdiv($max - $now, 2); $diff = intdiv($max - $now, 2);
// determine if the expiry time is less than half the session timeout into the future // determine if the expiry time is less than half the session timeout into the future
return (($now + $diff) >= $expiry->getTimestamp()); return ($now + $diff) >= $expiry->getTimestamp();
} }
/** Creates a new token for the given user in the given class /** Creates a new token for the given user in the given class
@ -587,7 +587,7 @@ class Database {
'name' => "str", 'name' => "str",
'parent' => "int", 'parent' => "int",
]; ];
list($setClause, $setTypes, $setValues) = $this->generateSet($in, $valid); [$setClause, $setTypes, $setValues] = $this->generateSet($in, $valid);
return (bool) $this->db->prepare("UPDATE arsse_folders set $setClause, modified = CURRENT_TIMESTAMP where owner = ? and id = ?", $setTypes, "str", "int")->run($setValues, $user, $id)->changes(); return (bool) $this->db->prepare("UPDATE arsse_folders set $setClause, modified = CURRENT_TIMESTAMP where owner = ? and id = ?", $setTypes, "str", "int")->run($setValues, $user, $id)->changes();
} }
@ -881,7 +881,7 @@ class Database {
'order_type' => "strict int", 'order_type' => "strict int",
'pinned' => "strict bool", 'pinned' => "strict bool",
]; ];
list($setClause, $setTypes, $setValues) = $this->generateSet($data, $valid); [$setClause, $setTypes, $setValues] = $this->generateSet($data, $valid);
if (!$setClause) { if (!$setClause) {
// if no changes would actually be applied, just return // if no changes would actually be applied, just return
return false; return false;
@ -1220,10 +1220,10 @@ class Database {
*/ */
public function feedMatchIds(int $feedID, array $ids = [], array $hashesUT = [], array $hashesUC = [], array $hashesTC = []): Db\Result { public function feedMatchIds(int $feedID, array $ids = [], array $hashesUT = [], array $hashesUC = [], array $hashesTC = []): Db\Result {
// compile SQL IN() clauses and necessary type bindings for the four identifier lists // compile SQL IN() clauses and necessary type bindings for the four identifier lists
list($cId, $tId, $vId) = $this->generateIn($ids, "str"); [$cId, $tId, $vId] = $this->generateIn($ids, "str");
list($cHashUT, $tHashUT, $vHashUT) = $this->generateIn($hashesUT, "str"); [$cHashUT, $tHashUT, $vHashUT] = $this->generateIn($hashesUT, "str");
list($cHashUC, $tHashUC, $vHashUC) = $this->generateIn($hashesUC, "str"); [$cHashUC, $tHashUC, $vHashUC] = $this->generateIn($hashesUC, "str");
list($cHashTC, $tHashTC, $vHashTC) = $this->generateIn($hashesTC, "str"); [$cHashTC, $tHashTC, $vHashTC] = $this->generateIn($hashesTC, "str");
// perform the query // perform the query
return $articles = $this->db->prepare( return $articles = $this->db->prepare(
"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 feed = ? and (guid in($cId) or url_title_hash in($cHashUT) or url_content_hash in($cHashUC) or title_content_hash in($cHashTC))",
@ -1359,7 +1359,7 @@ class Database {
"unread" => ["unread", "=", "bool", ""], "unread" => ["unread", "=", "bool", ""],
"starred" => ["starred", "=", "bool", ""], "starred" => ["starred", "=", "bool", ""],
]; ];
foreach ($options as $m => list($col, $op, $type, $pair)) { foreach ($options as $m => [$col, $op, $type, $pair]) {
if (!$context->$m()) { if (!$context->$m()) {
// context is not being used // context is not being used
continue; continue;
@ -1368,7 +1368,7 @@ class Database {
if (!$context->$m) { if (!$context->$m) {
throw new Db\ExceptionInput("tooShort", ['field' => $m, 'action' => $this->caller(), 'min' => 1]); // must have at least one array element throw new Db\ExceptionInput("tooShort", ['field' => $m, 'action' => $this->caller(), 'min' => 1]); // must have at least one array element
} }
list($clause, $types, $values) = $this->generateIn($context->$m, $type); [$clause, $types, $values] = $this->generateIn($context->$m, $type);
$q->setWhere("{$colDefs[$col]} $op ($clause)", $types, $values); $q->setWhere("{$colDefs[$col]} $op ($clause)", $types, $values);
} elseif ($pair && $context->$pair()) { } elseif ($pair && $context->$pair()) {
// option is paired with another which is also being used // option is paired with another which is also being used
@ -1383,7 +1383,7 @@ class Database {
} }
} }
// further handle exclusionary options if specified // further handle exclusionary options if specified
foreach ($options as $m => list($col, $op, $type, $pair)) { foreach ($options as $m => [$col, $op, $type, $pair]) {
if (!method_exists($context->not, $m) || !$context->not->$m()) { if (!method_exists($context->not, $m) || !$context->not->$m()) {
// context option is not being used // context option is not being used
continue; continue;
@ -1392,7 +1392,7 @@ class Database {
// for exclusions we don't care if the array is empty // for exclusions we don't care if the array is empty
continue; continue;
} }
list($clause, $types, $values) = $this->generateIn($context->not->$m, $type); [$clause, $types, $values] = $this->generateIn($context->not->$m, $type);
$q->setWhereNot("{$colDefs[$col]} $op ($clause)", $types, $values); $q->setWhereNot("{$colDefs[$col]} $op ($clause)", $types, $values);
} elseif ($pair && $context->not->$pair()) { } elseif ($pair && $context->not->$pair()) {
// option is paired with another which is also being used // option is paired with another which is also being used
@ -1452,7 +1452,7 @@ class Database {
throw new Db\ExceptionInput("tooShort", ['field' => $m, 'action' => $this->caller(), 'min' => 1]); // must have at least one array element throw new Db\ExceptionInput("tooShort", ['field' => $m, 'action' => $this->caller(), 'min' => 1]); // must have at least one array element
} }
if ($multi) { if ($multi) {
list($test, $types, $values) = $this->generateIn($context->$m, $named ? "str" : "int"); [$test, $types, $values] = $this->generateIn($context->$m, $named ? "str" : "int");
$test = "in ($test)"; $test = "in ($test)";
} else { } else {
$test = "= ?"; $test = "= ?";
@ -1464,7 +1464,7 @@ class Database {
if ($context->not->$m()) { if ($context->not->$m()) {
$seen = true; $seen = true;
if ($multi) { if ($multi) {
list($test, $types, $values) = $this->generateIn($context->not->$m, $named ? "str" : "int"); [$test, $types, $values] = $this->generateIn($context->not->$m, $named ? "str" : "int");
$test = "in ($test)"; $test = "in ($test)";
} else { } else {
$test = "= ?"; $test = "= ?";
@ -1496,7 +1496,7 @@ class Database {
$q->setWhere("coalesce(arsse_subscriptions.folder,0) in (select folder from folders)"); $q->setWhere("coalesce(arsse_subscriptions.folder,0) in (select folder from folders)");
} }
if ($context->folders()) { if ($context->folders()) {
list($inClause, $inTypes, $inValues) = $this->generateIn($context->folders, "int"); [$inClause, $inTypes, $inValues] = $this->generateIn($context->folders, "int");
// add a common table expression to list the folders and their children so that we select from the entire subtree // add a common table expression to list the folders and their children so that we select from the entire subtree
$q->setCTE("folders_multi(folder)", "SELECT id as folder from (select id from (select 0 as id union select id from arsse_folders where owner = ?) as f where id in ($inClause)) as folders_multi union select id from arsse_folders join folders_multi on coalesce(parent,0) = folder", ["str", $inTypes], [$user, $inValues]); $q->setCTE("folders_multi(folder)", "SELECT id as folder from (select id from (select 0 as id union select id from arsse_folders where owner = ?) as f where id in ($inClause)) as folders_multi union select id from arsse_folders join folders_multi on coalesce(parent,0) = folder", ["str", $inTypes], [$user, $inValues]);
// limit subscriptions to the listed folders // limit subscriptions to the listed folders
@ -1509,7 +1509,7 @@ class Database {
$q->setWhereNot("coalesce(arsse_subscriptions.folder,0) in (select folder from folders_excluded)"); $q->setWhereNot("coalesce(arsse_subscriptions.folder,0) in (select folder from folders_excluded)");
} }
if ($context->not->folders()) { if ($context->not->folders()) {
list($inClause, $inTypes, $inValues) = $this->generateIn($context->not->folders, "int"); [$inClause, $inTypes, $inValues] = $this->generateIn($context->not->folders, "int");
// add a common table expression to list the folders and their children so that we select from the entire subtree // add a common table expression to list the folders and their children so that we select from the entire subtree
$q->setCTE("folders_multi_excluded(folder)", "SELECT id as folder from (select id from (select 0 as id union select id from arsse_folders where owner = ?) as f where id in ($inClause)) as folders_multi_excluded union select id from arsse_folders join folders_multi_excluded on coalesce(parent,0) = folder", ["str", $inTypes], [$user, $inValues]); $q->setCTE("folders_multi_excluded(folder)", "SELECT id as folder from (select id from (select 0 as id union select id from arsse_folders where owner = ?) as f where id in ($inClause)) as folders_multi_excluded union select id from arsse_folders join folders_multi_excluded on coalesce(parent,0) = folder", ["str", $inTypes], [$user, $inValues]);
// limit subscriptions to the listed folders // limit subscriptions to the listed folders
@ -1664,7 +1664,7 @@ class Database {
$data = array_filter($data, function($v) { $data = array_filter($data, function($v) {
return isset($v); return isset($v);
}); });
list($set, $setTypes, $setValues) = $this->generateSet($data, ['starred' => "bool", 'note' => "str"]); [$set, $setTypes, $setValues] = $this->generateSet($data, ['starred' => "bool", 'note' => "str"]);
$q->setBody("UPDATE arsse_marks set touched = 1, $set where article in(select article from target_articles) and subscription in(select distinct subscription from target_articles)", $setTypes, $setValues); $q->setBody("UPDATE arsse_marks set touched = 1, $set where article in(select article from target_articles) and subscription in(select distinct subscription from target_articles)", $setTypes, $setValues);
$this->db->prepare($q->getQuery(), $q->getTypes())->run($q->getValues()); $this->db->prepare($q->getQuery(), $q->getTypes())->run($q->getValues());
} }
@ -1688,7 +1688,7 @@ class Database {
$data = array_filter($data, function($v) { $data = array_filter($data, function($v) {
return isset($v); return isset($v);
}); });
list($set, $setTypes, $setValues) = $this->generateSet($data, ['read' => "bool", 'starred' => "bool", 'note' => "str"]); [$set, $setTypes, $setValues] = $this->generateSet($data, ['read' => "bool", 'starred' => "bool", 'note' => "str"]);
$q->setBody("UPDATE arsse_marks set $set, modified = CURRENT_TIMESTAMP where article in(select article from target_articles) and subscription in(select distinct subscription from target_articles)", $setTypes, $setValues); $q->setBody("UPDATE arsse_marks set $set, modified = CURRENT_TIMESTAMP where article in(select article from target_articles) and subscription in(select distinct subscription from target_articles)", $setTypes, $setValues);
$out = $this->db->prepare($q->getQuery(), $q->getTypes())->run($q->getValues())->changes(); $out = $this->db->prepare($q->getQuery(), $q->getTypes())->run($q->getValues())->changes();
} }
@ -1860,7 +1860,7 @@ class Database {
public function editionArticle(int ...$edition): array { public function editionArticle(int ...$edition): array {
$out = []; $out = [];
$context = (new Context)->editions($edition); $context = (new Context)->editions($edition);
list($in, $inTypes, $inValues) = $this->generateIn($context->editions, "int"); [$in, $inTypes, $inValues] = $this->generateIn($context->editions, "int");
$out = $this->db->prepare("SELECT id as edition, article from arsse_editions where id in($in)", $inTypes)->run($inValues)->getAll(); $out = $this->db->prepare("SELECT id as edition, article from arsse_editions where id in($in)", $inTypes)->run($inValues)->getAll();
return $out ? array_combine(array_column($out, "edition"), array_column($out, "article")) : []; return $out ? array_combine(array_column($out, "edition"), array_column($out, "article")) : [];
} }
@ -2018,7 +2018,7 @@ class Database {
$valid = [ $valid = [
'name' => "str", 'name' => "str",
]; ];
list($setClause, $setTypes, $setValues) = $this->generateSet($data, $valid); [$setClause, $setTypes, $setValues] = $this->generateSet($data, $valid);
if (!$setClause) { if (!$setClause) {
// if no changes would actually be applied, just return // if no changes would actually be applied, just return
return false; return false;
@ -2086,7 +2086,7 @@ class Database {
$articles = array_column($articles, "id"); $articles = array_column($articles, "id");
} }
// prepare up to three queries: removing requires one, adding two, and replacing three // prepare up to three queries: removing requires one, adding two, and replacing three
list($inClause, $inTypes, $inValues) = $this->generateIn($articles, "int"); [$inClause, $inTypes, $inValues] = $this->generateIn($articles, "int");
$updateQ = "UPDATE arsse_label_members set assigned = ?, modified = CURRENT_TIMESTAMP where label = ? and assigned <> ? and article %in% ($inClause)"; $updateQ = "UPDATE arsse_label_members set assigned = ?, modified = CURRENT_TIMESTAMP where label = ? and assigned <> ? and article %in% ($inClause)";
$updateT = ["bool", "int", "bool", $inTypes]; $updateT = ["bool", "int", "bool", $inTypes];
$insertQ = "INSERT INTO arsse_label_members(label,article,subscription) SELECT ?,a.id,s.id from arsse_articles as a join arsse_subscriptions as s on a.feed = s.feed where s.owner = ? and a.id not in (select article from arsse_label_members where label = ?) and a.id in ($inClause)"; $insertQ = "INSERT INTO arsse_label_members(label,article,subscription) SELECT ?,a.id,s.id from arsse_articles as a join arsse_subscriptions as s on a.feed = s.feed where s.owner = ? and a.id not in (select article from arsse_label_members where label = ?) and a.id in ($inClause)";
@ -2112,7 +2112,7 @@ class Database {
// execute them in a transaction // execute them in a transaction
$out = 0; $out = 0;
$tr = $this->begin(); $tr = $this->begin();
foreach ($qList as list($q, $t, $v)) { foreach ($qList as [$q, $t, $v]) {
$out += $this->db->prepare($q, ...$t)->run(...$v)->changes(); $out += $this->db->prepare($q, ...$t)->run(...$v)->changes();
} }
$tr->commit(); $tr->commit();
@ -2321,7 +2321,7 @@ class Database {
$valid = [ $valid = [
'name' => "str", 'name' => "str",
]; ];
list($setClause, $setTypes, $setValues) = $this->generateSet($data, $valid); [$setClause, $setTypes, $setValues] = $this->generateSet($data, $valid);
if (!$setClause) { if (!$setClause) {
// if no changes would actually be applied, just return // if no changes would actually be applied, just return
return false; return false;
@ -2385,7 +2385,7 @@ class Database {
} }
} }
// prepare up to three queries: removing requires one, adding two, and replacing three // prepare up to three queries: removing requires one, adding two, and replacing three
list($inClause, $inTypes, $inValues) = $this->generateIn($subscriptions, "int"); [$inClause, $inTypes, $inValues] = $this->generateIn($subscriptions, "int");
$updateQ = "UPDATE arsse_tag_members set assigned = ?, modified = CURRENT_TIMESTAMP where tag = ? and assigned <> ? and subscription in (select id from arsse_subscriptions where owner = ? and id %in% ($inClause))"; $updateQ = "UPDATE arsse_tag_members set assigned = ?, modified = CURRENT_TIMESTAMP where tag = ? and assigned <> ? and subscription in (select id from arsse_subscriptions where owner = ? and id %in% ($inClause))";
$updateT = ["bool", "int", "bool", "str", $inTypes]; $updateT = ["bool", "int", "bool", "str", $inTypes];
$insertQ = "INSERT INTO arsse_tag_members(tag,subscription) SELECT ?,id from arsse_subscriptions where id not in (select subscription from arsse_tag_members where tag = ?) and owner = ? and id in ($inClause)"; $insertQ = "INSERT INTO arsse_tag_members(tag,subscription) SELECT ?,id from arsse_subscriptions where id not in (select subscription from arsse_tag_members where tag = ?) and owner = ? and id in ($inClause)";
@ -2411,7 +2411,7 @@ class Database {
// execute them in a transaction // execute them in a transaction
$out = 0; $out = 0;
$tr = $this->begin(); $tr = $this->begin();
foreach ($qList as list($q, $t, $v)) { foreach ($qList as [$q, $t, $v]) {
$out += $this->db->prepare($q, ...$t)->run(...$v)->changes(); $out += $this->db->prepare($q, ...$t)->run(...$v)->changes();
} }
$tr->commit(); $tr->commit();

View file

@ -40,9 +40,9 @@ abstract class AbstractDriver implements Driver {
throw new Exception("updateFileUnreadable", ['file' => $file, 'driver_name' => $this->driverName(), 'current' => $a]); throw new Exception("updateFileUnreadable", ['file' => $file, 'driver_name' => $this->driverName(), 'current' => $a]);
} }
$sql = @file_get_contents($file); $sql = @file_get_contents($file);
if ($sql===false) { if ($sql === false) {
throw new Exception("updateFileUnusable", ['file' => $file, 'driver_name' => $this->driverName(), 'current' => $a]); // @codeCoverageIgnore throw new Exception("updateFileUnusable", ['file' => $file, 'driver_name' => $this->driverName(), 'current' => $a]); // @codeCoverageIgnore
} elseif ($sql==="") { } elseif ($sql === "") {
throw new Exception("updateFileIncomplete", ['file' => $file, 'driver_name' => $this->driverName(), 'current' => $a]); throw new Exception("updateFileIncomplete", ['file' => $file, 'driver_name' => $this->driverName(), 'current' => $a]);
} }
try { try {
@ -50,7 +50,7 @@ abstract class AbstractDriver implements Driver {
} catch (\Throwable $e) { } catch (\Throwable $e) {
throw new Exception("updateFileError", ['file' => $file, 'driver_name' => $this->driverName(), 'current' => $a, 'message' => $e->getMessage()]); throw new Exception("updateFileError", ['file' => $file, 'driver_name' => $this->driverName(), 'current' => $a, 'message' => $e->getMessage()]);
} }
if ($this->schemaVersion() != $a+1) { if ($this->schemaVersion() != $a + 1) {
throw new Exception("updateFileIncomplete", ['file' => $file, 'driver_name' => $this->driverName(), 'current' => $a]); throw new Exception("updateFileIncomplete", ['file' => $file, 'driver_name' => $this->driverName(), 'current' => $a]);
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {

View file

@ -78,7 +78,7 @@ abstract class AbstractStatement implements Statement {
$value = $this->cast($value, $this->types[$a]); $value = $this->cast($value, $this->types[$a]);
$this->bindValue($value, $this->types[$a] % self::T_NOT_NULL, ++$a); $this->bindValue($value, $this->types[$a] % self::T_NOT_NULL, ++$a);
} else { } else {
throw new Exception("paramTypeMissing", $a+1); throw new Exception("paramTypeMissing", $a + 1);
} }
} }
// once all values are bound, check that all parameters have been supplied values and bind null for any missing ones // once all values are bound, check that all parameters have been supplied values and bind null for any missing ones

View file

@ -163,7 +163,7 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
$this->db->options(\MYSQLI_OPT_CONNECT_TIMEOUT, ceil(Arsse::$conf->dbTimeoutConnect)); $this->db->options(\MYSQLI_OPT_CONNECT_TIMEOUT, ceil(Arsse::$conf->dbTimeoutConnect));
@$this->db->real_connect($host, $user, $password, $db, $port, $socket); @$this->db->real_connect($host, $user, $password, $db, $port, $socket);
if ($this->db->connect_errno) { if ($this->db->connect_errno) {
list($excClass, $excMsg, $excData) = $this->buildConnectionException($this->db->connect_errno, $this->db->connect_error); [$excClass, $excMsg, $excData] = $this->buildConnectionException($this->db->connect_errno, $this->db->connect_error);
throw new $excClass($excMsg, $excData); throw new $excClass($excMsg, $excData);
} }
$this->db->set_charset("utf8mb4"); $this->db->set_charset("utf8mb4");
@ -184,9 +184,9 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
do { do {
if ($this->db->sqlstate !== "00000") { if ($this->db->sqlstate !== "00000") {
if ($this->db->sqlstate === "HY000") { if ($this->db->sqlstate === "HY000") {
list($excClass, $excMsg, $excData) = $this->buildEngineException($this->db->errno, $this->db->error); [$excClass, $excMsg, $excData] = $this->buildEngineException($this->db->errno, $this->db->error);
} else { } else {
list($excClass, $excMsg, $excData) = $this->buildStandardException($this->db->sqlstate, $this->db->error); [$excClass, $excMsg, $excData] = $this->buildStandardException($this->db->sqlstate, $this->db->error);
} }
$e = new $excClass($excMsg, $excData, $e); $e = new $excClass($excMsg, $excData, $e);
} }

View file

@ -34,7 +34,7 @@ class PDODriver extends Driver {
$msg = $e->getMessage(); $msg = $e->getMessage();
$code = (int) substr($msg, 17, 4); $code = (int) substr($msg, 17, 4);
$msg = substr($msg, 23); $msg = substr($msg, 23);
list($excClass, $excMsg, $excData) = $this->buildConnectionException($code, $msg); [$excClass, $excMsg, $excData] = $this->buildConnectionException($code, $msg);
throw new $excClass($excMsg, $excData); throw new $excClass($excMsg, $excData);
} }
} }

View file

@ -44,6 +44,6 @@ class Result extends \JKingWeb\Arsse\Db\AbstractResult {
public function valid() { public function valid() {
$this->cur = $this->set ? $this->set->fetch_assoc() : null; $this->cur = $this->set ? $this->set->fetch_assoc() : null;
return ($this->cur !== null); return $this->cur !== null;
} }
} }

View file

@ -37,7 +37,7 @@ class Statement extends \JKingWeb\Arsse\Db\AbstractStatement {
protected function prepare(string $query): bool { protected function prepare(string $query): bool {
$this->st = $this->db->prepare($query); $this->st = $this->db->prepare($query);
if (!$this->st) { // @codeCoverageIgnore if (!$this->st) { // @codeCoverageIgnore
list($excClass, $excMsg, $excData) = $this->buildEngineException($this->db->errno, $this->db->error); // @codeCoverageIgnore [$excClass, $excMsg, $excData] = $this->buildEngineException($this->db->errno, $this->db->error); // @codeCoverageIgnore
throw new $excClass($excMsg, $excData); // @codeCoverageIgnore throw new $excClass($excMsg, $excData); // @codeCoverageIgnore
} }
return true; return true;
@ -76,9 +76,9 @@ class Statement extends \JKingWeb\Arsse\Db\AbstractStatement {
// check for errors // check for errors
if ($this->st->sqlstate !== "00000") { if ($this->st->sqlstate !== "00000") {
if ($this->st->sqlstate === "HY000") { if ($this->st->sqlstate === "HY000") {
list($excClass, $excMsg, $excData) = $this->buildEngineException($this->st->errno, $this->st->error); [$excClass, $excMsg, $excData] = $this->buildEngineException($this->st->errno, $this->st->error);
} else { } else {
list($excClass, $excMsg, $excData) = $this->buildStandardException($this->st->sqlstate, $this->st->error); [$excClass, $excMsg, $excData] = $this->buildStandardException($this->st->sqlstate, $this->st->error);
} }
throw new $excClass($excMsg, $excData); throw new $excClass($excMsg, $excData);
} }

View file

@ -14,7 +14,7 @@ trait PDODriver {
$this->db->exec($query); $this->db->exec($query);
return true; return true;
} catch (\PDOException $e) { } catch (\PDOException $e) {
list($excClass, $excMsg, $excData) = $this->buildPDOException(); [$excClass, $excMsg, $excData] = $this->buildPDOException();
throw new $excClass($excMsg, $excData); throw new $excClass($excMsg, $excData);
} }
} }
@ -23,7 +23,7 @@ trait PDODriver {
try { try {
$r = $this->db->query($query); $r = $this->db->query($query);
} catch (\PDOException $e) { } catch (\PDOException $e) {
list($excClass, $excMsg, $excData) = $this->buildPDOException(); [$excClass, $excMsg, $excData] = $this->buildPDOException();
throw new $excClass($excMsg, $excData); throw new $excClass($excMsg, $excData);
} }
return new PDOResult($this->db, $r); return new PDOResult($this->db, $r);

View file

@ -45,6 +45,6 @@ class PDOResult extends AbstractResult {
public function valid() { public function valid() {
$this->cur = $this->set->fetch(\PDO::FETCH_ASSOC); $this->cur = $this->set->fetch(\PDO::FETCH_ASSOC);
return ($this->cur !== false); return $this->cur !== false;
} }
} }

View file

@ -34,7 +34,7 @@ abstract class PDOStatement extends AbstractStatement {
$this->st = $this->db->prepare($query); $this->st = $this->db->prepare($query);
return true; return true;
} catch (\PDOException $e) { // @codeCoverageIgnore } catch (\PDOException $e) { // @codeCoverageIgnore
list($excClass, $excMsg, $excData) = $this->buildPDOException(); // @codeCoverageIgnore [$excClass, $excMsg, $excData] = $this->buildPDOException(); // @codeCoverageIgnore
throw new $excClass($excMsg, $excData); // @codeCoverageIgnore throw new $excClass($excMsg, $excData); // @codeCoverageIgnore
} }
} }
@ -49,7 +49,7 @@ abstract class PDOStatement extends AbstractStatement {
try { try {
$this->st->execute(); $this->st->execute();
} catch (\PDOException $e) { } catch (\PDOException $e) {
list($excClass, $excMsg, $excData) = $this->buildPDOException(true); [$excClass, $excMsg, $excData] = $this->buildPDOException(true);
throw new $excClass($excMsg, $excData); throw new $excClass($excMsg, $excData);
} }
return new PDOResult($this->db, $this->st); return new PDOResult($this->db, $this->st);

View file

@ -198,7 +198,7 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
pg_send_query($this->db, $query); pg_send_query($this->db, $query);
while ($result = pg_get_result($this->db)) { while ($result = pg_get_result($this->db)) {
if (($code = pg_result_error_field($result, \PGSQL_DIAG_SQLSTATE)) && isset($code) && $code) { if (($code = pg_result_error_field($result, \PGSQL_DIAG_SQLSTATE)) && isset($code) && $code) {
list($excClass, $excMsg, $excData) = $this->buildStandardException($code, pg_result_error($result)); [$excClass, $excMsg, $excData] = $this->buildStandardException($code, pg_result_error($result));
throw new $excClass($excMsg, $excData); throw new $excClass($excMsg, $excData);
} }
} }
@ -210,7 +210,7 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
if (is_resource($r)) { if (is_resource($r)) {
return new Result($this->db, $r); return new Result($this->db, $r);
} else { } else {
list($excClass, $excMsg, $excData) = $r; [$excClass, $excMsg, $excData] = $r;
throw new $excClass($excMsg, $excData); throw new $excClass($excMsg, $excData);
} }
} }

View file

@ -53,7 +53,6 @@ class PDODriver extends Driver {
} }
} }
public static function driverName(): string { public static function driverName(): string {
return Arsse::$lang->msg("Driver.Db.PostgreSQLPDO.Name"); return Arsse::$lang->msg("Driver.Db.PostgreSQLPDO.Name");
} }

View file

@ -41,6 +41,6 @@ class Result extends \JKingWeb\Arsse\Db\AbstractResult {
public function valid() { public function valid() {
$this->cur = pg_fetch_row($this->r, null, \PGSQL_ASSOC); $this->cur = pg_fetch_row($this->r, null, \PGSQL_ASSOC);
return ($this->cur !== false); return $this->cur !== false;
} }
} }

View file

@ -38,7 +38,7 @@ class Statement extends \JKingWeb\Arsse\Db\AbstractStatement {
if (is_resource($r)) { if (is_resource($r)) {
return new Result($this->db, $r); return new Result($this->db, $r);
} else { } else {
list($excClass, $excMsg, $excData) = $r; [$excClass, $excMsg, $excData] = $r;
throw new $excClass($excMsg, $excData); throw new $excClass($excMsg, $excData);
} }
} }

View file

@ -6,10 +6,6 @@
declare(strict_types=1); declare(strict_types=1);
namespace JKingWeb\Arsse\Db; namespace JKingWeb\Arsse\Db;
use JKingWeb\Arsse\Db\Exception;
use JKingWeb\Arsse\Db\ExceptionInput;
use JKingWeb\Arsse\Db\ExceptionTimeout;
trait SQLState { trait SQLState {
protected static function buildStandardException(string $code, string $msg): array { protected static function buildStandardException(string $code, string $msg): array {
switch ($code) { switch ($code) {

View file

@ -98,7 +98,6 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
} }
} }
public static function driverName(): string { public static function driverName(): string {
return Arsse::$lang->msg("Driver.Db.SQLite3.Name"); return Arsse::$lang->msg("Driver.Db.SQLite3.Name");
} }
@ -146,7 +145,7 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
try { try {
return (bool) $this->db->exec($query); return (bool) $this->db->exec($query);
} catch (\Exception $e) { } catch (\Exception $e) {
list($excClass, $excMsg, $excData) = $this->buildException(); [$excClass, $excMsg, $excData] = $this->buildException();
throw new $excClass($excMsg, $excData); throw new $excClass($excMsg, $excData);
} }
} }
@ -155,7 +154,7 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
try { try {
$r = $this->db->query($query); $r = $this->db->query($query);
} catch (\Exception $e) { } catch (\Exception $e) {
list($excClass, $excMsg, $excData) = $this->buildException(); [$excClass, $excMsg, $excData] = $this->buildException();
throw new $excClass($excMsg, $excData); throw new $excClass($excMsg, $excData);
} }
$changes = $this->db->changes(); $changes = $this->db->changes();

View file

@ -37,7 +37,6 @@ class PDODriver extends AbstractPDODriver {
} }
} }
public static function driverName(): string { public static function driverName(): string {
return Arsse::$lang->msg("Driver.Db.SQLite3PDO.Name"); return Arsse::$lang->msg("Driver.Db.SQLite3PDO.Name");
} }

View file

@ -44,6 +44,6 @@ class Result extends \JKingWeb\Arsse\Db\AbstractResult {
public function valid() { public function valid() {
$this->cur = $this->set->fetchArray(\SQLITE3_ASSOC); $this->cur = $this->set->fetchArray(\SQLITE3_ASSOC);
return ($this->cur !== false); return $this->cur !== false;
} }
} }

View file

@ -37,7 +37,7 @@ class Statement extends \JKingWeb\Arsse\Db\AbstractStatement {
$this->st = $this->db->prepare($query); $this->st = $this->db->prepare($query);
return true; return true;
} catch (\Exception $e) { // @codeCoverageIgnore } catch (\Exception $e) { // @codeCoverageIgnore
list($excClass, $excMsg, $excData) = $this->buildException(); // @codeCoverageIgnore [$excClass, $excMsg, $excData] = $this->buildException(); // @codeCoverageIgnore
throw new $excClass($excMsg, $excData); // @codeCoverageIgnore throw new $excClass($excMsg, $excData); // @codeCoverageIgnore
} }
} }
@ -56,7 +56,7 @@ class Statement extends \JKingWeb\Arsse\Db\AbstractStatement {
try { try {
$r = $this->st->execute(); $r = $this->st->execute();
} catch (\Exception $e) { } catch (\Exception $e) {
list($excClass, $excMsg, $excData) = $this->buildException(); [$excClass, $excMsg, $excData] = $this->buildException();
throw new $excClass($excMsg, $excData); throw new $excClass($excMsg, $excData);
} }
$changes = $this->db->changes(); $changes = $this->db->changes();

View file

@ -259,7 +259,7 @@ class Feed {
// get as many of the latest articles in the database as there are in the feed // get as many of the latest articles in the database as there are in the feed
$articles = Arsse::$db->feedMatchLatest($feedID, sizeof($items))->getAll(); $articles = Arsse::$db->feedMatchLatest($feedID, sizeof($items))->getAll();
// perform a first pass matching the latest articles against items in the feed // perform a first pass matching the latest articles against items in the feed
list($this->newItems, $this->changedItems) = $this->matchItems($items, $articles); [$this->newItems, $this->changedItems] = $this->matchItems($items, $articles);
if (sizeof($this->newItems) && sizeof($items) <= sizeof($articles)) { if (sizeof($this->newItems) && sizeof($items) <= sizeof($articles)) {
// if we need to, perform a second pass on the database looking specifically for IDs and hashes of the new items // if we need to, perform a second pass on the database looking specifically for IDs and hashes of the new items
$ids = $hashesUT = $hashesUC = $hashesTC = []; $ids = $hashesUT = $hashesUC = $hashesTC = [];
@ -278,7 +278,7 @@ class Feed {
} }
} }
$articles = Arsse::$db->feedMatchIds($feedID, $ids, $hashesUT, $hashesUC, $hashesTC)->getAll(); $articles = Arsse::$db->feedMatchIds($feedID, $ids, $hashesUT, $hashesUC, $hashesTC)->getAll();
list($this->newItems, $changed) = $this->matchItems($this->newItems, $articles); [$this->newItems, $changed] = $this->matchItems($this->newItems, $articles);
// merge the two change-lists, preserving keys // merge the two change-lists, preserving keys
$this->changedItems = array_combine(array_merge(array_keys($this->changedItems), array_keys($changed)), array_merge($this->changedItems, $changed)); $this->changedItems = array_combine(array_merge(array_keys($this->changedItems), array_keys($changed)), array_merge($this->changedItems, $changed));
} }
@ -348,7 +348,7 @@ class Feed {
$dates = $this->gatherDates(); $dates = $this->gatherDates();
if (sizeof($dates) > 3) { if (sizeof($dates) > 3) {
for ($a = 0; $a < 3; $a++) { for ($a = 0; $a < 3; $a++) {
$diff = $dates[$a] - $dates[$a+1]; $diff = $dates[$a] - $dates[$a + 1];
$offsets[] = $this->normalizeDateDiff($diff); $offsets[] = $this->normalizeDateDiff($diff);
} }
if ($offsets[0] === $offsets[1] || $offsets[0] === $offsets[2]) { if ($offsets[0] === $offsets[1] || $offsets[0] === $offsets[2]) {

View file

@ -12,8 +12,8 @@ use GuzzleHttp\Exception\TooManyRedirectsException;
use PicoFeed\PicoFeedException; use PicoFeed\PicoFeedException;
class Exception extends \JKingWeb\Arsse\AbstractException { class Exception extends \JKingWeb\Arsse\AbstractException {
const CURL_ERROR_MAP = [1=>"invalidUrl",3=>"invalidUrl",5=>"transmissionError","connectionFailed","connectionFailed","transmissionError","forbidden","unauthorized","transmissionError","transmissionError","transmissionError","transmissionError","connectionFailed","connectionFailed","transmissionError","transmissionError","transmissionError","transmissionError","transmissionError","invalidUrl","transmissionError","transmissionError","transmissionError","transmissionError",28=>"timeout","transmissionError","transmissionError","transmissionError","transmissionError","transmissionError",35=>"invalidCertificate","transmissionError","transmissionError","transmissionError","transmissionError",45=>"transmissionError","unauthorized","maxRedirect",52=>"transmissionError","invalidCertificate","invalidCertificate","transmissionError","transmissionError",58=>"invalidCertificate","invalidCertificate","invalidCertificate","transmissionError","invalidUrl","transmissionError","invalidCertificate","transmissionError","invalidCertificate","forbidden","invalidUrl","forbidden","transmissionError",73=>"transmissionError","transmissionError",77=>"invalidCertificate","invalidUrl",90=>"invalidCertificate","invalidCertificate","transmissionError",94=>"unauthorized","transmissionError","connectionFailed"]; const CURL_ERROR_MAP = [1 => "invalidUrl",3 => "invalidUrl",5 => "transmissionError","connectionFailed","connectionFailed","transmissionError","forbidden","unauthorized","transmissionError","transmissionError","transmissionError","transmissionError","connectionFailed","connectionFailed","transmissionError","transmissionError","transmissionError","transmissionError","transmissionError","invalidUrl","transmissionError","transmissionError","transmissionError","transmissionError",28 => "timeout","transmissionError","transmissionError","transmissionError","transmissionError","transmissionError",35 => "invalidCertificate","transmissionError","transmissionError","transmissionError","transmissionError",45 => "transmissionError","unauthorized","maxRedirect",52 => "transmissionError","invalidCertificate","invalidCertificate","transmissionError","transmissionError",58 => "invalidCertificate","invalidCertificate","invalidCertificate","transmissionError","invalidUrl","transmissionError","invalidCertificate","transmissionError","invalidCertificate","forbidden","invalidUrl","forbidden","transmissionError",73 => "transmissionError","transmissionError",77 => "invalidCertificate","invalidUrl",90 => "invalidCertificate","invalidCertificate","transmissionError",94 => "unauthorized","transmissionError","connectionFailed"];
const HTTP_ERROR_MAP = [401=>"unauthorized",403=>"forbidden",404=>"invalidUrl",408=>"timeout",410=>"invalidUrl",414=>"invalidUrl",451=>"invalidUrl"]; const HTTP_ERROR_MAP = [401 => "unauthorized",403 => "forbidden",404 => "invalidUrl",408 => "timeout",410 => "invalidUrl",414 => "invalidUrl",451 => "invalidUrl"];
public function __construct($url, \Throwable $e) { public function __construct($url, \Throwable $e) {
if ($e instanceof BadResponseException) { if ($e instanceof BadResponseException) {

View file

@ -17,7 +17,7 @@ abstract class AbstractImportExport {
throw new UserException("doesNotExist", ["action" => __FUNCTION__, "user" => $user]); throw new UserException("doesNotExist", ["action" => __FUNCTION__, "user" => $user]);
} }
// first extract useful information from the input // first extract useful information from the input
list($feeds, $folders) = $this->parse($data, $flat); [$feeds, $folders] = $this->parse($data, $flat);
$folderMap = []; $folderMap = [];
foreach ($folders as $f) { foreach ($folders as $f) {
// check to make sure folder names are all valid // check to make sure folder names are all valid

View file

@ -97,7 +97,7 @@ class Lang {
} }
$msg = $this->strings[$msgID]; $msg = $this->strings[$msgID];
// variables fed to MessageFormatter must be contained in an array // variables fed to MessageFormatter must be contained in an array
if ($vars===null) { if ($vars === null) {
// even though strings not given parameters will not get formatted, we do not optimize this case away: we still want to catch invalid strings // even though strings not given parameters will not get formatted, we do not optimize this case away: we still want to catch invalid strings
$vars = []; $vars = [];
} elseif (!is_array($vars)) { } elseif (!is_array($vars)) {
@ -108,7 +108,7 @@ class Lang {
throw new Lang\Exception("stringInvalid", ['error' => $this->formatter->getErrorMessage(), 'msgID' => $msgID, 'fileList' => implode(", ", $this->loaded)]); throw new Lang\Exception("stringInvalid", ['error' => $this->formatter->getErrorMessage(), 'msgID' => $msgID, 'fileList' => implode(", ", $this->loaded)]);
} }
$msg = $this->formatter->format($vars); $msg = $this->formatter->format($vars);
if ($msg===false) { if ($msg === false) {
throw new Lang\Exception("dataInvalid", ['error' => $this->formatter->getErrorMessage(), 'msgID' => $msgID, 'fileList' => implode(", ", $this->loaded)]); // @codeCoverageIgnore throw new Lang\Exception("dataInvalid", ['error' => $this->formatter->getErrorMessage(), 'msgID' => $msgID, 'fileList' => implode(", ", $this->loaded)]); // @codeCoverageIgnore
} }
return $msg; return $msg;
@ -148,7 +148,7 @@ class Lang {
// trim the returned file paths to return just the language tag // trim the returned file paths to return just the language tag
$out = array_map(function($file) { $out = array_map(function($file) {
$file = str_replace(DIRECTORY_SEPARATOR, "/", $file); // we replace the directory separator because we don't use native paths in testing $file = str_replace(DIRECTORY_SEPARATOR, "/", $file); // we replace the directory separator because we don't use native paths in testing
$file = substr($file, strrpos($file, "/")+1); $file = substr($file, strrpos($file, "/") + 1);
return strtolower(substr($file, 0, strrpos($file, "."))); return strtolower(substr($file, 0, strrpos($file, ".")));
}, $out); }, $out);
// sort the results // sort the results

View file

@ -24,7 +24,6 @@ class Query {
protected $limit = 0; protected $limit = 0;
protected $offset = 0; protected $offset = 0;
public function __construct(string $body = "", $types = null, $values = null) { public function __construct(string $body = "", $types = null, $values = null) {
$this->setBody($body, $types, $values); $this->setBody($body, $types, $values);
} }

View file

@ -77,7 +77,7 @@ class URL {
$c = $part[$pos]; $c = $part[$pos];
if ($c === "%") { if ($c === "%") {
// the % character signals an encoded character... // the % character signals an encoded character...
$d = substr($part, $pos+1, 2); $d = substr($part, $pos + 1, 2);
if (!preg_match("/^[0-9a-fA-F]{2}$/", $d)) { if (!preg_match("/^[0-9a-fA-F]{2}$/", $d)) {
// unless there are fewer than two characters left in the string or the two characters are not hex digits // unless there are fewer than two characters left in the string or the two characters are not hex digits
$d = ord($c); $d = ord($c);

View file

@ -166,7 +166,7 @@ class ValueInfo {
throw new ExceptionType("strictFailure", $type); throw new ExceptionType("strictFailure", $type);
} }
$out = filter_var($value, \FILTER_VALIDATE_FLOAT); $out = filter_var($value, \FILTER_VALIDATE_FLOAT);
if ($strict && $out===false) { if ($strict && $out === false) {
// if strict and input is not a float, this is an error // if strict and input is not a float, this is an error
if ($drop) { if ($drop) {
return null; return null;

View file

@ -6,7 +6,6 @@
declare(strict_types=1); declare(strict_types=1);
namespace JKingWeb\Arsse; namespace JKingWeb\Arsse;
use JKingWeb\Arsse\Arsse;
use JKingWeb\Arsse\Misc\URL; use JKingWeb\Arsse\Misc\URL;
use Psr\Http\Message\RequestInterface; use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
@ -71,7 +70,7 @@ class REST {
$req = $req ?? ServerRequestFactory::fromGlobals(); $req = $req ?? ServerRequestFactory::fromGlobals();
// find the API to handle // find the API to handle
try { try {
list($api, $target, $class) = $this->apiMatch($req->getRequestTarget(), $this->apis); [$api, $target, $class] = $this->apiMatch($req->getRequestTarget(), $this->apis);
// authenticate the request pre-emptively // authenticate the request pre-emptively
$req = $this->authenticateRequest($req); $req = $this->authenticateRequest($req);
// modify the request to have an uppercase method and a stripped target // modify the request to have an uppercase method and a stripped target
@ -108,7 +107,7 @@ class REST {
// find a match // find a match
foreach ($map as $id => $api) { foreach ($map as $id => $api) {
// first try a simple substring match // first try a simple substring match
if (strpos($url, $api['match'])===0) { if (strpos($url, $api['match']) === 0) {
// if it matches, perform a more rigorous match and then strip off any defined prefix // if it matches, perform a more rigorous match and then strip off any defined prefix
$pattern = "<^".preg_quote($api['match'])."([/\?#]|$)>"; $pattern = "<^".preg_quote($api['match'])."([/\?#]|$)>";
if ($url === $api['match'] || in_array(substr($api['match'], -1, 1), ["/", "?", "#"]) || preg_match($pattern, $url)) { if ($url === $api['match'] || in_array(substr($api['match'], -1, 1), ["/", "?", "#"]) || preg_match($pattern, $url)) {
@ -200,7 +199,7 @@ class REST {
if ($req->hasHeader("Access-Control-Request-Headers")) { if ($req->hasHeader("Access-Control-Request-Headers")) {
$res = $res->withHeader("Access-Control-Allow-Headers", $req->getHeaderLine("Access-Control-Request-Headers")); $res = $res->withHeader("Access-Control-Allow-Headers", $req->getHeaderLine("Access-Control-Request-Headers"));
} }
$res = $res->withHeader("Access-Control-Max-Age", (string) (60 *60 *24)); // one day $res = $res->withHeader("Access-Control-Max-Age", (string) (60 * 60 * 24)); // one day
} }
$res = $res->withHeader("Access-Control-Allow-Origin", $req->getHeaderLine("Origin")); $res = $res->withHeader("Access-Control-Allow-Origin", $req->getHeaderLine("Origin"));
$res = $res->withHeader("Access-Control-Allow-Credentials", "true"); $res = $res->withHeader("Access-Control-Allow-Credentials", "true");

View file

@ -215,7 +215,7 @@ class V1_2 extends \JKingWeb\Arsse\REST\AbstractHandler {
return $feed; return $feed;
} }
protected function articleTranslate(array $article) :array { protected function articleTranslate(array $article): array {
// map fields to proper names // map fields to proper names
$article = $this->fieldMapNames($article, [ $article = $this->fieldMapNames($article, [
'id' => "edition", 'id' => "edition",
@ -616,7 +616,7 @@ class V1_2 extends \JKingWeb\Arsse\REST\AbstractHandler {
$c = new Context; $c = new Context;
$c->article((int) $url[2]); $c->article((int) $url[2]);
// determine whether to mark read or unread // determine whether to mark read or unread
$set = ($url[3] ==="star"); $set = ($url[3] === "star");
try { try {
Arsse::$db->articleMark(Arsse::$user->id, ['starred' => $set], $c); Arsse::$db->articleMark(Arsse::$user->id, ['starred' => $set], $c);
} catch (ExceptionInput $e) { } catch (ExceptionInput $e) {
@ -629,7 +629,7 @@ class V1_2 extends \JKingWeb\Arsse\REST\AbstractHandler {
// mark an array of articles as read // mark an array of articles as read
protected function articleMarkReadMulti(array $url, array $data): ResponseInterface { protected function articleMarkReadMulti(array $url, array $data): ResponseInterface {
// determine whether to mark read or unread // determine whether to mark read or unread
$set = ($url[1] ==="read"); $set = ($url[1] === "read");
// initialize the matching context // initialize the matching context
$c = new Context; $c = new Context;
$c->editions($data['items'] ?? []); $c->editions($data['items'] ?? []);
@ -643,7 +643,7 @@ class V1_2 extends \JKingWeb\Arsse\REST\AbstractHandler {
// mark an array of articles as starred // mark an array of articles as starred
protected function articleMarkStarredMulti(array $url, array $data): ResponseInterface { protected function articleMarkStarredMulti(array $url, array $data): ResponseInterface {
// determine whether to mark starred or unstarred // determine whether to mark starred or unstarred
$set = ($url[1] ==="star"); $set = ($url[1] === "star");
// initialize the matching context // initialize the matching context
$c = new Context; $c = new Context;
$c->articles(array_column($data['items'] ?? [], "guidHash")); $c->articles(array_column($data['items'] ?? [], "guidHash"));
@ -688,7 +688,7 @@ class V1_2 extends \JKingWeb\Arsse\REST\AbstractHandler {
'warnings' => [ 'warnings' => [
'improperlyConfiguredCron' => !Service::hasCheckedIn(), 'improperlyConfiguredCron' => !Service::hasCheckedIn(),
'incorrectDbCharset' => !Arsse::$db->driverCharsetAcceptable(), 'incorrectDbCharset' => !Arsse::$db->driverCharsetAcceptable(),
] ],
]); ]);
} }
} }

View file

@ -29,7 +29,7 @@ class Versions implements \JKingWeb\Arsse\REST\Handler {
$out = [ $out = [
'apiLevels' => [ 'apiLevels' => [
'v1-2', 'v1-2',
] ],
]; ];
return new Response($out); return new Response($out);
default: default:

View file

@ -190,7 +190,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
// are not enforced, create a session for the HTTP user regardless // are not enforced, create a session for the HTTP user regardless
// of which user the API call mentions // of which user the API call mentions
$id = Arsse::$db->sessionCreate(Arsse::$user->id); $id = Arsse::$db->sessionCreate(Arsse::$user->id);
} elseif ((!Arsse::$conf->userPreAuth && (Arsse::$user->auth($user, $pass) || Arsse::$user->auth($user, base64_decode($pass)))) || (Arsse::$conf->userPreAuth && Arsse::$user->id===$user)) { } elseif ((!Arsse::$conf->userPreAuth && (Arsse::$user->auth($user, $pass) || Arsse::$user->auth($user, base64_decode($pass)))) || (Arsse::$conf->userPreAuth && Arsse::$user->id === $user)) {
// otherwise both cleartext and base64 passwords are accepted // otherwise both cleartext and base64 passwords are accepted
// if pre-authentication is in use, just make sure the user names match // if pre-authentication is in use, just make sure the user names match
$id = Arsse::$db->sessionCreate($user); $id = Arsse::$db->sessionCreate($user);
@ -199,7 +199,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
} }
return [ return [
'session_id' => $id, 'session_id' => $id,
'api_level' => self::LEVEL 'api_level' => self::LEVEL,
]; ];
} }
@ -304,7 +304,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
return array_merge($special, $labels, $feeds, $cats); return array_merge($special, $labels, $feeds, $cats);
} }
public function opGetFeedTree(array $data) : array { public function opGetFeedTree(array $data): array {
$all = $data['include_empty'] ?? false; $all = $data['include_empty'] ?? false;
$user = Arsse::$user->id; $user = Arsse::$user->id;
$tSpecial = [ $tSpecial = [
@ -843,7 +843,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
$subs = Arsse::$db->subscriptionList(Arsse::$user->id); $subs = Arsse::$db->subscriptionList(Arsse::$user->id);
$id = false; $id = false;
foreach ($subs as $sub) { foreach ($subs as $sub) {
if ($sub['url']===$url) { if ($sub['url'] === $url) {
$id = (int) $sub['id']; $id = (int) $sub['id'];
break; break;
} }
@ -940,11 +940,11 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
return 0; return 0;
} }
} }
return (abs($id) - self::LABEL_OFFSET); return abs($id) - self::LABEL_OFFSET;
} }
protected function labelOut($id): int { protected function labelOut($id): int {
return ((int) $id * -1 - self::LABEL_OFFSET); return (int) $id * -1 - self::LABEL_OFFSET;
} }
public function opGetLabels(array $data): array { public function opGetLabels(array $data): array {

View file

@ -66,7 +66,7 @@ class Service {
$limit->sub($int); $limit->sub($int);
$limit->sub($int); $limit->sub($int);
// return whether the check-in time is within the acceptable limit // return whether the check-in time is within the acceptable limit
return ($checkin >= $limit); return $checkin >= $limit;
} }
public static function cleanupPre(): bool { public static function cleanupPre(): bool {

View file

@ -15,9 +15,7 @@ class User {
public $id = null; public $id = null;
/** /** @var User\Driver */
* @var User\Driver
*/
protected $u; protected $u;
public function __construct(\JKingWeb\Arsse\User\Driver $driver = null) { public function __construct(\JKingWeb\Arsse\User\Driver $driver = null) {

View file

@ -26,7 +26,7 @@ class Driver implements \JKingWeb\Arsse\User\Driver {
} catch (Exception $e) { } catch (Exception $e) {
return false; return false;
} }
if ($password==="" && $hash==="") { if ($password === "" && $hash === "") {
return true; return true;
} }
return password_verify($password, $hash); return password_verify($password, $hash);

View file

@ -163,10 +163,10 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
// FIXME: Phake is somehow unable to mock the User class correctly, so we use PHPUnit's mocks instead // FIXME: Phake is somehow unable to mock the User class correctly, so we use PHPUnit's mocks instead
Arsse::$user = $this->createMock(User::class); Arsse::$user = $this->createMock(User::class);
Arsse::$user->method("auth")->will($this->returnCallback(function($user, $pass) { Arsse::$user->method("auth")->will($this->returnCallback(function($user, $pass) {
return ( return
($user === "john.doe@example.com" && $pass === "secret") || ($user === "john.doe@example.com" && $pass === "secret") ||
($user === "jane.doe@example.com" && $pass === "superman") ($user === "jane.doe@example.com" && $pass === "superman")
); ;
})); }));
$fever = \Phake::mock(FeverUser::class); $fever = \Phake::mock(FeverUser::class);
\Phake::when($fever)->authenticate->thenReturn(false); \Phake::when($fever)->authenticate->thenReturn(false);

View file

@ -47,7 +47,7 @@ trait SeriesArticle {
[11,"http://example.com/11", "Feed 11"], [11,"http://example.com/11", "Feed 11"],
[12,"http://example.com/12", "Feed 12"], [12,"http://example.com/12", "Feed 12"],
[13,"http://example.com/13", "Feed 13"], [13,"http://example.com/13", "Feed 13"],
] ],
], ],
'arsse_folders' => [ 'arsse_folders' => [
'columns' => [ 'columns' => [
@ -66,7 +66,7 @@ trait SeriesArticle {
[7, "john.doe@example.net", null, "Technology"], [7, "john.doe@example.net", null, "Technology"],
[8, "john.doe@example.net", 7, "Software"], [8, "john.doe@example.net", 7, "Software"],
[9, "john.doe@example.net", null, "Politics"], [9, "john.doe@example.net", null, "Politics"],
] ],
], ],
'arsse_tags' => [ 'arsse_tags' => [
'columns' => [ 'columns' => [
@ -83,7 +83,7 @@ trait SeriesArticle {
[6, "john.doe@example.net", "Technology"], [6, "john.doe@example.net", "Technology"],
[7, "john.doe@example.net", "Software"], [7, "john.doe@example.net", "Software"],
[8, "john.doe@example.net", "Politics"], [8, "john.doe@example.net", "Politics"],
] ],
], ],
'arsse_subscriptions' => [ 'arsse_subscriptions' => [
'columns' => [ 'columns' => [
@ -108,7 +108,7 @@ trait SeriesArticle {
[12,"john.doe@example.net",2, 9,null], [12,"john.doe@example.net",2, 9,null],
[13,"john.doe@example.net",3, 8,"Subscription 13"], [13,"john.doe@example.net",3, 8,"Subscription 13"],
[14,"john.doe@example.net",4, 7,null], [14,"john.doe@example.net",4, 7,null],
] ],
], ],
'arsse_tag_members' => [ 'arsse_tag_members' => [
'columns' => [ 'columns' => [
@ -171,7 +171,7 @@ trait SeriesArticle {
[103,12,'http://example.com/3','Article title 3','','2000-01-03 00:00:00','2000-01-03 00:00:03','<p>Article content 3</p>','31a6594500a48b59fcc8a075ce82b946c9c3c782460d088bd7b8ef3ede97ad92','f74b06b240bd08abf4d3fdfc20dba6a6f6eb8b4f1a00e9a617efd63a87180a4b','b278380e984cefe63f0e412b88ffc9cb0befdfa06fdc00bace1da99a8daff406','ad622b31e739cd3a3f3c788991082cf4d2f7a8773773008e75f0572e58cd373b','2000-01-03 03:00:00'], [103,12,'http://example.com/3','Article title 3','','2000-01-03 00:00:00','2000-01-03 00:00:03','<p>Article content 3</p>','31a6594500a48b59fcc8a075ce82b946c9c3c782460d088bd7b8ef3ede97ad92','f74b06b240bd08abf4d3fdfc20dba6a6f6eb8b4f1a00e9a617efd63a87180a4b','b278380e984cefe63f0e412b88ffc9cb0befdfa06fdc00bace1da99a8daff406','ad622b31e739cd3a3f3c788991082cf4d2f7a8773773008e75f0572e58cd373b','2000-01-03 03:00:00'],
[104,12,'http://example.com/4','Article title 4','','2000-01-04 00:00:00','2000-01-04 00:00:04','<p>Article content 4</p>','804e517d623390e71497982c77cf6823180342ebcd2e7d5e32da1e55b09dd180','f3615c7f16336d3ea242d35cf3fc17dbc4ee3afb78376bf49da2dd7a5a25dec8','f11c2b4046f207579aeb9c69a8c20ca5461cef49756ccfa5ba5e2344266da3b3','ab2da63276acce431250b18d3d49b988b226a99c7faadf275c90b751aee05be9','2000-01-04 04:00:00'], [104,12,'http://example.com/4','Article title 4','','2000-01-04 00:00:00','2000-01-04 00:00:04','<p>Article content 4</p>','804e517d623390e71497982c77cf6823180342ebcd2e7d5e32da1e55b09dd180','f3615c7f16336d3ea242d35cf3fc17dbc4ee3afb78376bf49da2dd7a5a25dec8','f11c2b4046f207579aeb9c69a8c20ca5461cef49756ccfa5ba5e2344266da3b3','ab2da63276acce431250b18d3d49b988b226a99c7faadf275c90b751aee05be9','2000-01-04 04:00:00'],
[105,13,'http://example.com/5','Article title 5','','2000-01-05 00:00:00','2000-01-05 00:00:05','<p>Article content 5</p>','db3e736c2c492f5def5c5da33ddcbea1824040e9ced2142069276b0a6e291a41','d40da96e39eea6c55948ccbe9b3d275b5f931298288dbe953990c5f496097022','834240f84501b5341d375414718204ec421561f3825d34c22bf9182203e42900','43b970ac6ec5f8a9647b2c7e4eed8b1d7f62e154a95eed748b0294c1256764ba','2000-01-05 05:00:00'], [105,13,'http://example.com/5','Article title 5','','2000-01-05 00:00:00','2000-01-05 00:00:05','<p>Article content 5</p>','db3e736c2c492f5def5c5da33ddcbea1824040e9ced2142069276b0a6e291a41','d40da96e39eea6c55948ccbe9b3d275b5f931298288dbe953990c5f496097022','834240f84501b5341d375414718204ec421561f3825d34c22bf9182203e42900','43b970ac6ec5f8a9647b2c7e4eed8b1d7f62e154a95eed748b0294c1256764ba','2000-01-05 05:00:00'],
] ],
], ],
'arsse_enclosures' => [ 'arsse_enclosures' => [
'columns' => [ 'columns' => [
@ -185,7 +185,7 @@ trait SeriesArticle {
[104,"http://example.com/image","image/svg+xml"], [104,"http://example.com/image","image/svg+xml"],
[105,"http://example.com/audio","audio/ogg"], [105,"http://example.com/audio","audio/ogg"],
] ],
], ],
'arsse_editions' => [ 'arsse_editions' => [
'columns' => [ 'columns' => [
@ -224,7 +224,7 @@ trait SeriesArticle {
[205,105], [205,105],
[305,105], [305,105],
[1001,20], [1001,20],
] ],
], ],
'arsse_marks' => [ 'arsse_marks' => [
'columns' => [ 'columns' => [
@ -249,7 +249,7 @@ trait SeriesArticle {
[12, 3,0,1,'2017-01-01 00:00:00','ack'], [12, 3,0,1,'2017-01-01 00:00:00','ack'],
[12, 4,1,1,'2017-01-01 00:00:00','ach'], [12, 4,1,1,'2017-01-01 00:00:00','ach'],
[1, 2,0,0,'2010-01-01 00:00:00','Some Note'], [1, 2,0,0,'2010-01-01 00:00:00','Some Note'],
] ],
], ],
'arsse_categories' => [ // author-supplied categories 'arsse_categories' => [ // author-supplied categories
'columns' => [ 'columns' => [
@ -404,7 +404,7 @@ trait SeriesArticle {
"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";
} }
@ -606,7 +606,7 @@ trait SeriesArticle {
} }
public function testMarkAllArticlesUnread(): void { public function testMarkAllArticlesUnread(): void {
Arsse::$db->articleMark($this->user, ['read'=>false]); Arsse::$db->articleMark($this->user, ['read' => false]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][9][2] = 0; $state['arsse_marks']['rows'][9][2] = 0;
@ -617,7 +617,7 @@ trait SeriesArticle {
} }
public function testMarkAllArticlesRead(): void { public function testMarkAllArticlesRead(): void {
Arsse::$db->articleMark($this->user, ['read'=>true]); Arsse::$db->articleMark($this->user, ['read' => true]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][8][2] = 1; $state['arsse_marks']['rows'][8][2] = 1;
@ -632,7 +632,7 @@ trait SeriesArticle {
} }
public function testMarkAllArticlesUnstarred(): void { public function testMarkAllArticlesUnstarred(): void {
Arsse::$db->articleMark($this->user, ['starred'=>false]); Arsse::$db->articleMark($this->user, ['starred' => false]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][10][3] = 0; $state['arsse_marks']['rows'][10][3] = 0;
@ -643,7 +643,7 @@ trait SeriesArticle {
} }
public function testMarkAllArticlesStarred(): void { public function testMarkAllArticlesStarred(): void {
Arsse::$db->articleMark($this->user, ['starred'=>true]); Arsse::$db->articleMark($this->user, ['starred' => true]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][8][3] = 1; $state['arsse_marks']['rows'][8][3] = 1;
@ -658,7 +658,7 @@ trait SeriesArticle {
} }
public function testMarkAllArticlesUnreadAndUnstarred(): void { public function testMarkAllArticlesUnreadAndUnstarred(): void {
Arsse::$db->articleMark($this->user, ['read'=>false,'starred'=>false]); Arsse::$db->articleMark($this->user, ['read' => false,'starred' => false]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][9][2] = 0; $state['arsse_marks']['rows'][9][2] = 0;
@ -672,7 +672,7 @@ trait SeriesArticle {
} }
public function testMarkAllArticlesReadAndStarred(): void { public function testMarkAllArticlesReadAndStarred(): void {
Arsse::$db->articleMark($this->user, ['read'=>true,'starred'=>true]); Arsse::$db->articleMark($this->user, ['read' => true,'starred' => true]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][8][2] = 1; $state['arsse_marks']['rows'][8][2] = 1;
@ -690,7 +690,7 @@ trait SeriesArticle {
} }
public function testMarkAllArticlesUnreadAndStarred(): void { public function testMarkAllArticlesUnreadAndStarred(): void {
Arsse::$db->articleMark($this->user, ['read'=>false,'starred'=>true]); Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][8][3] = 1; $state['arsse_marks']['rows'][8][3] = 1;
@ -708,7 +708,7 @@ trait SeriesArticle {
} }
public function testMarkAllArticlesReadAndUnstarred(): void { public function testMarkAllArticlesReadAndUnstarred(): void {
Arsse::$db->articleMark($this->user, ['read'=>true,'starred'=>false]); Arsse::$db->articleMark($this->user, ['read' => true,'starred' => false]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][8][2] = 1; $state['arsse_marks']['rows'][8][2] = 1;
@ -726,7 +726,7 @@ trait SeriesArticle {
} }
public function testSetNoteForAllArticles(): void { public function testSetNoteForAllArticles(): void {
Arsse::$db->articleMark($this->user, ['note'=>"New note"]); Arsse::$db->articleMark($this->user, ['note' => "New note"]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][8][5] = "New note"; $state['arsse_marks']['rows'][8][5] = "New note";
@ -745,7 +745,7 @@ trait SeriesArticle {
} }
public function testMarkATreeFolder(): void { public function testMarkATreeFolder(): void {
Arsse::$db->articleMark($this->user, ['read'=>true], (new Context)->folder(7)); Arsse::$db->articleMark($this->user, ['read' => true], (new Context)->folder(7));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][] = [13,5,1,0,$now,'']; $state['arsse_marks']['rows'][] = [13,5,1,0,$now,''];
@ -756,7 +756,7 @@ trait SeriesArticle {
} }
public function testMarkALeafFolder(): void { public function testMarkALeafFolder(): void {
Arsse::$db->articleMark($this->user, ['read'=>true], (new Context)->folder(8)); Arsse::$db->articleMark($this->user, ['read' => true], (new Context)->folder(8));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][] = [13,5,1,0,$now,'']; $state['arsse_marks']['rows'][] = [13,5,1,0,$now,''];
@ -766,11 +766,11 @@ trait SeriesArticle {
public function testMarkAMissingFolder(): void { public function testMarkAMissingFolder(): void {
$this->assertException("idMissing", "Db", "ExceptionInput"); $this->assertException("idMissing", "Db", "ExceptionInput");
Arsse::$db->articleMark($this->user, ['read'=>true], (new Context)->folder(42)); Arsse::$db->articleMark($this->user, ['read' => true], (new Context)->folder(42));
} }
public function testMarkASubscription(): void { public function testMarkASubscription(): void {
Arsse::$db->articleMark($this->user, ['read'=>true], (new Context)->subscription(13)); Arsse::$db->articleMark($this->user, ['read' => true], (new Context)->subscription(13));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][] = [13,5,1,0,$now,'']; $state['arsse_marks']['rows'][] = [13,5,1,0,$now,''];
@ -780,11 +780,11 @@ trait SeriesArticle {
public function testMarkAMissingSubscription(): void { public function testMarkAMissingSubscription(): void {
$this->assertException("idMissing", "Db", "ExceptionInput"); $this->assertException("idMissing", "Db", "ExceptionInput");
Arsse::$db->articleMark($this->user, ['read'=>true], (new Context)->folder(2112)); Arsse::$db->articleMark($this->user, ['read' => true], (new Context)->folder(2112));
} }
public function testMarkAnArticle(): void { public function testMarkAnArticle(): void {
Arsse::$db->articleMark($this->user, ['starred'=>true], (new Context)->article(20)); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->article(20));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][9][3] = 1; $state['arsse_marks']['rows'][9][3] = 1;
@ -793,7 +793,7 @@ trait SeriesArticle {
} }
public function testMarkMultipleArticles(): void { public function testMarkMultipleArticles(): void {
Arsse::$db->articleMark($this->user, ['starred'=>true], (new Context)->articles([2,4,7,20])); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->articles([2,4,7,20]));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][9][3] = 1; $state['arsse_marks']['rows'][9][3] = 1;
@ -803,7 +803,7 @@ trait SeriesArticle {
} }
public function testMarkMultipleArticlessUnreadAndStarred(): void { public function testMarkMultipleArticlessUnreadAndStarred(): void {
Arsse::$db->articleMark($this->user, ['read'=>false,'starred'=>true], (new Context)->articles([2,4,7,20])); Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true], (new Context)->articles([2,4,7,20]));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][9][2] = 0; $state['arsse_marks']['rows'][9][2] = 0;
@ -816,16 +816,16 @@ trait SeriesArticle {
} }
public function testMarkTooManyMultipleArticles(): void { public function testMarkTooManyMultipleArticles(): void {
$this->assertSame(7, Arsse::$db->articleMark($this->user, ['read'=>false,'starred'=>true], (new Context)->articles(range(1, Database::LIMIT_SET_SIZE * 3)))); $this->assertSame(7, Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true], (new Context)->articles(range(1, Database::LIMIT_SET_SIZE * 3))));
} }
public function testMarkAMissingArticle(): void { public function testMarkAMissingArticle(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->articleMark($this->user, ['starred'=>true], (new Context)->article(1)); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->article(1));
} }
public function testMarkAnEdition(): void { public function testMarkAnEdition(): void {
Arsse::$db->articleMark($this->user, ['starred'=>true], (new Context)->edition(1001)); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->edition(1001));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][9][3] = 1; $state['arsse_marks']['rows'][9][3] = 1;
@ -834,7 +834,7 @@ trait SeriesArticle {
} }
public function testMarkMultipleEditions(): void { public function testMarkMultipleEditions(): void {
Arsse::$db->articleMark($this->user, ['starred'=>true], (new Context)->editions([2,4,7,20])); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->editions([2,4,7,20]));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][9][3] = 1; $state['arsse_marks']['rows'][9][3] = 1;
@ -844,13 +844,13 @@ trait SeriesArticle {
} }
public function testMarkMultipleMissingEditions(): void { public function testMarkMultipleMissingEditions(): void {
$this->assertSame(0, Arsse::$db->articleMark($this->user, ['starred'=>true], (new Context)->editions([500,501]))); $this->assertSame(0, Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->editions([500,501])));
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
public function testMarkMultipleEditionsUnread(): void { public function testMarkMultipleEditionsUnread(): void {
Arsse::$db->articleMark($this->user, ['read'=>false], (new Context)->editions([2,4,7,1001])); Arsse::$db->articleMark($this->user, ['read' => false], (new Context)->editions([2,4,7,1001]));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][9][2] = 0; $state['arsse_marks']['rows'][9][2] = 0;
@ -861,7 +861,7 @@ trait SeriesArticle {
} }
public function testMarkMultipleEditionsUnreadWithStale(): void { public function testMarkMultipleEditionsUnreadWithStale(): void {
Arsse::$db->articleMark($this->user, ['read'=>false], (new Context)->editions([2,4,7,20])); Arsse::$db->articleMark($this->user, ['read' => false], (new Context)->editions([2,4,7,20]));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][11][2] = 0; $state['arsse_marks']['rows'][11][2] = 0;
@ -870,7 +870,7 @@ trait SeriesArticle {
} }
public function testMarkMultipleEditionsUnreadAndStarredWithStale(): void { public function testMarkMultipleEditionsUnreadAndStarredWithStale(): void {
Arsse::$db->articleMark($this->user, ['read'=>false,'starred'=>true], (new Context)->editions([2,4,7,20])); Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true], (new Context)->editions([2,4,7,20]));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][9][3] = 1; $state['arsse_marks']['rows'][9][3] = 1;
@ -882,17 +882,17 @@ trait SeriesArticle {
} }
public function testMarkTooManyMultipleEditions(): void { public function testMarkTooManyMultipleEditions(): void {
$this->assertSame(7, Arsse::$db->articleMark($this->user, ['read'=>false,'starred'=>true], (new Context)->editions(range(1, 51)))); $this->assertSame(7, Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true], (new Context)->editions(range(1, 51))));
} }
public function testMarkAStaleEditionUnread(): void { public function testMarkAStaleEditionUnread(): void {
Arsse::$db->articleMark($this->user, ['read'=>false], (new Context)->edition(20)); // no changes occur Arsse::$db->articleMark($this->user, ['read' => false], (new Context)->edition(20)); // no changes occur
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
public function testMarkAStaleEditionStarred(): void { public function testMarkAStaleEditionStarred(): void {
Arsse::$db->articleMark($this->user, ['starred'=>true], (new Context)->edition(20)); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->edition(20));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][9][3] = 1; $state['arsse_marks']['rows'][9][3] = 1;
@ -901,7 +901,7 @@ trait SeriesArticle {
} }
public function testMarkAStaleEditionUnreadAndStarred(): void { public function testMarkAStaleEditionUnreadAndStarred(): void {
Arsse::$db->articleMark($this->user, ['read'=>false,'starred'=>true], (new Context)->edition(20)); // only starred is changed Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true], (new Context)->edition(20)); // only starred is changed
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][9][3] = 1; $state['arsse_marks']['rows'][9][3] = 1;
@ -910,18 +910,18 @@ trait SeriesArticle {
} }
public function testMarkAStaleEditionUnreadAndUnstarred(): void { public function testMarkAStaleEditionUnreadAndUnstarred(): void {
Arsse::$db->articleMark($this->user, ['read'=>false,'starred'=>false], (new Context)->edition(20)); // no changes occur Arsse::$db->articleMark($this->user, ['read' => false,'starred' => false], (new Context)->edition(20)); // no changes occur
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
public function testMarkAMissingEdition(): void { public function testMarkAMissingEdition(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->articleMark($this->user, ['starred'=>true], (new Context)->edition(2)); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->edition(2));
} }
public function testMarkByOldestEdition(): void { public function testMarkByOldestEdition(): void {
Arsse::$db->articleMark($this->user, ['starred'=>true], (new Context)->oldestEdition(19)); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->oldestEdition(19));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][8][3] = 1; $state['arsse_marks']['rows'][8][3] = 1;
@ -932,7 +932,7 @@ trait SeriesArticle {
} }
public function testMarkByLatestEdition(): void { public function testMarkByLatestEdition(): void {
Arsse::$db->articleMark($this->user, ['starred'=>true], (new Context)->latestEdition(20)); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->latestEdition(20));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][8][3] = 1; $state['arsse_marks']['rows'][8][3] = 1;
@ -945,7 +945,7 @@ trait SeriesArticle {
} }
public function testMarkByLastMarked(): void { public function testMarkByLastMarked(): void {
Arsse::$db->articleMark($this->user, ['starred'=>true], (new Context)->markedSince('2017-01-01T00:00:00Z')); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->markedSince('2017-01-01T00:00:00Z'));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][8][3] = 1; $state['arsse_marks']['rows'][8][3] = 1;
@ -956,7 +956,7 @@ trait SeriesArticle {
} }
public function testMarkByNotLastMarked(): void { public function testMarkByNotLastMarked(): void {
Arsse::$db->articleMark($this->user, ['starred'=>true], (new Context)->notMarkedSince('2000-01-01T00:00:00Z')); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->notMarkedSince('2000-01-01T00:00:00Z'));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$state['arsse_marks']['rows'][] = [13,5,0,1,$now,'']; $state['arsse_marks']['rows'][] = [13,5,0,1,$now,''];
@ -967,7 +967,7 @@ trait SeriesArticle {
public function testMarkArticlesWithoutAuthority(): void { public function testMarkArticlesWithoutAuthority(): void {
\Phake::when(Arsse::$user)->authorize->thenReturn(false); \Phake::when(Arsse::$user)->authorize->thenReturn(false);
$this->assertException("notAuthorized", "User", "ExceptionAuthz"); $this->assertException("notAuthorized", "User", "ExceptionAuthz");
Arsse::$db->articleMark($this->user, ['read'=>false]); Arsse::$db->articleMark($this->user, ['read' => false]);
} }
public function testCountArticles(): void { public function testCountArticles(): void {

View file

@ -76,7 +76,7 @@ trait SeriesCleanup {
[2,"http://example.com/2","",$yesterday,0], [2,"http://example.com/2","",$yesterday,0],
[3,"http://example.com/3","",null,0], [3,"http://example.com/3","",null,0],
[4,"http://example.com/4","",$nowish,0], [4,"http://example.com/4","",$nowish,0],
] ],
], ],
'arsse_subscriptions' => [ 'arsse_subscriptions' => [
'columns' => [ 'columns' => [
@ -89,7 +89,7 @@ trait SeriesCleanup {
[1,'jane.doe@example.com',1], [1,'jane.doe@example.com',1],
// other subscriptions exist for article cleanup tests // other subscriptions exist for article cleanup tests
[2,'john.doe@example.com',1], [2,'john.doe@example.com',1],
] ],
], ],
'arsse_articles' => [ 'arsse_articles' => [
'columns' => [ 'columns' => [
@ -110,7 +110,7 @@ trait SeriesCleanup {
[7,1,"","","",$weeksago], // meets the unread threshold without marks, thus is deleted [7,1,"","","",$weeksago], // meets the unread threshold without marks, thus is deleted
[8,1,"","","",$weeksago], // meets the unread threshold even with marks, thus is deleted [8,1,"","","",$weeksago], // meets the unread threshold even with marks, thus is deleted
[9,1,"","","",$weeksago], // meets the read threshold, thus is deleted [9,1,"","","",$weeksago], // meets the read threshold, thus is deleted
] ],
], ],
'arsse_editions' => [ 'arsse_editions' => [
'columns' => [ 'columns' => [
@ -124,7 +124,7 @@ trait SeriesCleanup {
[4,4], [4,4],
[201,1], [201,1],
[102,2], [102,2],
] ],
], ],
'arsse_marks' => [ 'arsse_marks' => [
'columns' => [ 'columns' => [
@ -142,7 +142,7 @@ trait SeriesCleanup {
[8,1,1,0,$weeksago], [8,1,1,0,$weeksago],
[9,1,1,0,$daysago], [9,1,1,0,$daysago],
[9,2,1,0,$daysago], [9,2,1,0,$daysago],
] ],
], ],
]; ];
} }
@ -155,7 +155,7 @@ trait SeriesCleanup {
Arsse::$db->feedCleanup(); Arsse::$db->feedCleanup();
$now = gmdate("Y-m-d H:i:s"); $now = gmdate("Y-m-d H:i:s");
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
'arsse_feeds' => ["id","orphaned"] 'arsse_feeds' => ["id","orphaned"],
]); ]);
$state['arsse_feeds']['rows'][0][1] = null; $state['arsse_feeds']['rows'][0][1] = null;
unset($state['arsse_feeds']['rows'][1]); unset($state['arsse_feeds']['rows'][1]);
@ -170,7 +170,7 @@ trait SeriesCleanup {
Arsse::$db->feedCleanup(); Arsse::$db->feedCleanup();
$now = gmdate("Y-m-d H:i:s"); $now = gmdate("Y-m-d H:i:s");
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
'arsse_feeds' => ["id","orphaned"] 'arsse_feeds' => ["id","orphaned"],
]); ]);
$state['arsse_feeds']['rows'][0][1] = null; $state['arsse_feeds']['rows'][0][1] = null;
$state['arsse_feeds']['rows'][2][1] = $now; $state['arsse_feeds']['rows'][2][1] = $now;
@ -180,7 +180,7 @@ trait SeriesCleanup {
public function testCleanUpOldArticlesWithStandardRetention(): void { public function testCleanUpOldArticlesWithStandardRetention(): void {
Arsse::$db->articleCleanup(); Arsse::$db->articleCleanup();
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
'arsse_articles' => ["id"] 'arsse_articles' => ["id"],
]); ]);
foreach ([7,8,9] as $id) { foreach ([7,8,9] as $id) {
unset($state['arsse_articles']['rows'][$id - 1]); unset($state['arsse_articles']['rows'][$id - 1]);
@ -194,7 +194,7 @@ trait SeriesCleanup {
]); ]);
Arsse::$db->articleCleanup(); Arsse::$db->articleCleanup();
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
'arsse_articles' => ["id"] 'arsse_articles' => ["id"],
]); ]);
foreach ([7,8] as $id) { foreach ([7,8] as $id) {
unset($state['arsse_articles']['rows'][$id - 1]); unset($state['arsse_articles']['rows'][$id - 1]);
@ -208,7 +208,7 @@ trait SeriesCleanup {
]); ]);
Arsse::$db->articleCleanup(); Arsse::$db->articleCleanup();
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
'arsse_articles' => ["id"] 'arsse_articles' => ["id"],
]); ]);
foreach ([9] as $id) { foreach ([9] as $id) {
unset($state['arsse_articles']['rows'][$id - 1]); unset($state['arsse_articles']['rows'][$id - 1]);
@ -223,7 +223,7 @@ trait SeriesCleanup {
]); ]);
Arsse::$db->articleCleanup(); Arsse::$db->articleCleanup();
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
'arsse_articles' => ["id"] 'arsse_articles' => ["id"],
]); ]);
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
@ -231,7 +231,7 @@ trait SeriesCleanup {
public function testCleanUpExpiredSessions(): void { public function testCleanUpExpiredSessions(): void {
Arsse::$db->sessionCleanup(); Arsse::$db->sessionCleanup();
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
'arsse_sessions' => ["id"] 'arsse_sessions' => ["id"],
]); ]);
foreach ([3,4,5] as $id) { foreach ([3,4,5] as $id) {
unset($state['arsse_sessions']['rows'][$id - 1]); unset($state['arsse_sessions']['rows'][$id - 1]);
@ -242,7 +242,7 @@ trait SeriesCleanup {
public function testCleanUpExpiredTokens(): void { public function testCleanUpExpiredTokens(): void {
Arsse::$db->tokenCleanup(); Arsse::$db->tokenCleanup();
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
'arsse_tokens' => ["id", "class"] 'arsse_tokens' => ["id", "class"],
]); ]);
foreach ([2] as $id) { foreach ([2] as $id) {
unset($state['arsse_tokens']['rows'][$id - 1]); unset($state['arsse_tokens']['rows'][$id - 1]);

View file

@ -42,7 +42,7 @@ trait SeriesFeed {
[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],
[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],
[5,"http://localhost:8000/Feed/Parsing/Valid","Ooook",0,"",$past,$future,0], [5,"http://localhost:8000/Feed/Parsing/Valid","Ooook",0,"",$past,$future,0],
] ],
], ],
'arsse_subscriptions' => [ 'arsse_subscriptions' => [
'columns' => [ 'columns' => [
@ -57,7 +57,7 @@ trait SeriesFeed {
[4,'john.doe@example.com',4], [4,'john.doe@example.com',4],
[5,'john.doe@example.com',5], [5,'john.doe@example.com',5],
[6,'jane.doe@example.com',1], [6,'jane.doe@example.com',1],
] ],
], ],
'arsse_articles' => [ 'arsse_articles' => [
'columns' => [ 'columns' => [
@ -82,8 +82,8 @@ trait SeriesFeed {
[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], [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], [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], [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], [7,5,'', '', '','2000-01-01 00:00:00','2000-01-01 00:00:00','', '205e986f4f8b3acfa281227beadb14f5e8c32c8dae4737f888c94c0df49c56f8','', '', '', $past],
] ],
], ],
'arsse_editions' => [ 'arsse_editions' => [
'columns' => [ 'columns' => [
@ -97,7 +97,7 @@ trait SeriesFeed {
[3,3,$past], [3,3,$past],
[4,4,$past], [4,4,$past],
[5,5,$past], [5,5,$past],
] ],
], ],
'arsse_marks' => [ 'arsse_marks' => [
'columns' => [ 'columns' => [
@ -118,7 +118,7 @@ trait SeriesFeed {
[1,1,1,0,$past], [1,1,1,0,$past],
[3,1,1,0,$past], [3,1,1,0,$past],
[4,1,0,1,$past], [4,1,0,1,$past],
] ],
], ],
'arsse_enclosures' => [ 'arsse_enclosures' => [
'columns' => [ 'columns' => [
@ -128,7 +128,7 @@ trait SeriesFeed {
], ],
'rows' => [ 'rows' => [
[7,'http://example.com/png','image/png'], [7,'http://example.com/png','image/png'],
] ],
], ],
'arsse_categories' => [ 'arsse_categories' => [
'columns' => [ 'columns' => [
@ -136,8 +136,8 @@ trait SeriesFeed {
'name' => "str", 'name' => "str",
], ],
'rows' => [ 'rows' => [
[7,'Syrinx'] [7,'Syrinx'],
] ],
], ],
]; ];
$this->matches = [ $this->matches = [

View file

@ -45,7 +45,7 @@ trait SeriesFolder {
[4, "jane.doe@example.com", null, "Politics"], [4, "jane.doe@example.com", null, "Politics"],
[5, "john.doe@example.com", null, "Politics"], [5, "john.doe@example.com", null, "Politics"],
[6, "john.doe@example.com", 2, "Politics"], [6, "john.doe@example.com", 2, "Politics"],
] ],
], ],
'arsse_feeds' => [ 'arsse_feeds' => [
'columns' => [ 'columns' => [
@ -67,7 +67,7 @@ trait SeriesFolder {
[11,"http://example.com/11", "Feed 11"], [11,"http://example.com/11", "Feed 11"],
[12,"http://example.com/12", "Feed 12"], [12,"http://example.com/12", "Feed 12"],
[13,"http://example.com/13", "Feed 13"], [13,"http://example.com/13", "Feed 13"],
] ],
], ],
'arsse_subscriptions' => [ 'arsse_subscriptions' => [
'columns' => [ 'columns' => [
@ -88,7 +88,7 @@ trait SeriesFolder {
[9, "jane.doe@example.com",2, 4], [9, "jane.doe@example.com",2, 4],
[10,"jane.doe@example.com",3, 4], [10,"jane.doe@example.com",3, 4],
[11,"jane.doe@example.com",4, 4], [11,"jane.doe@example.com",4, 4],
] ],
], ],
]; ];
} }

View file

@ -42,7 +42,7 @@ trait SeriesLabel {
[7, "john.doe@example.net", null, "Technology"], [7, "john.doe@example.net", null, "Technology"],
[8, "john.doe@example.net", 7, "Software"], [8, "john.doe@example.net", 7, "Software"],
[9, "john.doe@example.net", null, "Politics"], [9, "john.doe@example.net", null, "Politics"],
] ],
], ],
'arsse_feeds' => [ 'arsse_feeds' => [
'columns' => [ 'columns' => [
@ -63,7 +63,7 @@ trait SeriesLabel {
[11,"http://example.com/11"], [11,"http://example.com/11"],
[12,"http://example.com/12"], [12,"http://example.com/12"],
[13,"http://example.com/13"], [13,"http://example.com/13"],
] ],
], ],
'arsse_subscriptions' => [ 'arsse_subscriptions' => [
'columns' => [ 'columns' => [
@ -87,7 +87,7 @@ trait SeriesLabel {
[12,"john.doe@example.net",2,9], [12,"john.doe@example.net",2,9],
[13,"john.doe@example.net",3,8], [13,"john.doe@example.net",3,8],
[14,"john.doe@example.net",4,7], [14,"john.doe@example.net",4,7],
] ],
], ],
'arsse_articles' => [ 'arsse_articles' => [
'columns' => [ 'columns' => [
@ -131,7 +131,7 @@ trait SeriesLabel {
[103,12,'http://example.com/3','Article title 3','','2000-01-03 00:00:00','2000-01-03 00:00:03','<p>Article content 3</p>','31a6594500a48b59fcc8a075ce82b946c9c3c782460d088bd7b8ef3ede97ad92','f74b06b240bd08abf4d3fdfc20dba6a6f6eb8b4f1a00e9a617efd63a87180a4b','b278380e984cefe63f0e412b88ffc9cb0befdfa06fdc00bace1da99a8daff406','ad622b31e739cd3a3f3c788991082cf4d2f7a8773773008e75f0572e58cd373b','2000-01-03 03:00:00'], [103,12,'http://example.com/3','Article title 3','','2000-01-03 00:00:00','2000-01-03 00:00:03','<p>Article content 3</p>','31a6594500a48b59fcc8a075ce82b946c9c3c782460d088bd7b8ef3ede97ad92','f74b06b240bd08abf4d3fdfc20dba6a6f6eb8b4f1a00e9a617efd63a87180a4b','b278380e984cefe63f0e412b88ffc9cb0befdfa06fdc00bace1da99a8daff406','ad622b31e739cd3a3f3c788991082cf4d2f7a8773773008e75f0572e58cd373b','2000-01-03 03:00:00'],
[104,12,'http://example.com/4','Article title 4','','2000-01-04 00:00:00','2000-01-04 00:00:04','<p>Article content 4</p>','804e517d623390e71497982c77cf6823180342ebcd2e7d5e32da1e55b09dd180','f3615c7f16336d3ea242d35cf3fc17dbc4ee3afb78376bf49da2dd7a5a25dec8','f11c2b4046f207579aeb9c69a8c20ca5461cef49756ccfa5ba5e2344266da3b3','ab2da63276acce431250b18d3d49b988b226a99c7faadf275c90b751aee05be9','2000-01-04 04:00:00'], [104,12,'http://example.com/4','Article title 4','','2000-01-04 00:00:00','2000-01-04 00:00:04','<p>Article content 4</p>','804e517d623390e71497982c77cf6823180342ebcd2e7d5e32da1e55b09dd180','f3615c7f16336d3ea242d35cf3fc17dbc4ee3afb78376bf49da2dd7a5a25dec8','f11c2b4046f207579aeb9c69a8c20ca5461cef49756ccfa5ba5e2344266da3b3','ab2da63276acce431250b18d3d49b988b226a99c7faadf275c90b751aee05be9','2000-01-04 04:00:00'],
[105,13,'http://example.com/5','Article title 5','','2000-01-05 00:00:00','2000-01-05 00:00:05','<p>Article content 5</p>','db3e736c2c492f5def5c5da33ddcbea1824040e9ced2142069276b0a6e291a41','d40da96e39eea6c55948ccbe9b3d275b5f931298288dbe953990c5f496097022','834240f84501b5341d375414718204ec421561f3825d34c22bf9182203e42900','43b970ac6ec5f8a9647b2c7e4eed8b1d7f62e154a95eed748b0294c1256764ba','2000-01-05 05:00:00'], [105,13,'http://example.com/5','Article title 5','','2000-01-05 00:00:00','2000-01-05 00:00:05','<p>Article content 5</p>','db3e736c2c492f5def5c5da33ddcbea1824040e9ced2142069276b0a6e291a41','d40da96e39eea6c55948ccbe9b3d275b5f931298288dbe953990c5f496097022','834240f84501b5341d375414718204ec421561f3825d34c22bf9182203e42900','43b970ac6ec5f8a9647b2c7e4eed8b1d7f62e154a95eed748b0294c1256764ba','2000-01-05 05:00:00'],
] ],
], ],
'arsse_enclosures' => [ 'arsse_enclosures' => [
'columns' => [ 'columns' => [
@ -145,7 +145,7 @@ trait SeriesLabel {
[104,"http://example.com/image","image/svg+xml"], [104,"http://example.com/image","image/svg+xml"],
[105,"http://example.com/audio","audio/ogg"], [105,"http://example.com/audio","audio/ogg"],
] ],
], ],
'arsse_editions' => [ 'arsse_editions' => [
'columns' => [ 'columns' => [
@ -184,7 +184,7 @@ trait SeriesLabel {
[205,105], [205,105],
[305,105], [305,105],
[1001,20], [1001,20],
] ],
], ],
'arsse_marks' => [ 'arsse_marks' => [
'columns' => [ 'columns' => [
@ -192,7 +192,7 @@ trait SeriesLabel {
'article' => "int", 'article' => "int",
'read' => "bool", 'read' => "bool",
'starred' => "bool", 'starred' => "bool",
'modified' => "datetime" 'modified' => "datetime",
], ],
'rows' => [ 'rows' => [
[1, 1,1,1,'2000-01-01 00:00:00'], [1, 1,1,1,'2000-01-01 00:00:00'],
@ -207,7 +207,7 @@ trait SeriesLabel {
[11, 20,1,0,'2017-01-01 00:00:00'], [11, 20,1,0,'2017-01-01 00:00:00'],
[12, 3,0,1,'2017-01-01 00:00:00'], [12, 3,0,1,'2017-01-01 00:00:00'],
[12, 4,1,1,'2017-01-01 00:00:00'], [12, 4,1,1,'2017-01-01 00:00:00'],
] ],
], ],
'arsse_labels' => [ 'arsse_labels' => [
'columns' => [ 'columns' => [

View file

@ -56,11 +56,11 @@ trait SeriesSession {
public function testResumeAValidSession(): void { public function testResumeAValidSession(): void {
$exp1 = [ $exp1 = [
'id' => "80fa94c1a11f11e78667001e673b2560", 'id' => "80fa94c1a11f11e78667001e673b2560",
'user' => "jane.doe@example.com" 'user' => "jane.doe@example.com",
]; ];
$exp2 = [ $exp2 = [
'id' => "da772f8fa13c11e78667001e673b2560", 'id' => "da772f8fa13c11e78667001e673b2560",
'user' => "john.doe@example.com" 'user' => "john.doe@example.com",
]; ];
$this->assertArraySubset($exp1, Arsse::$db->sessionResume("80fa94c1a11f11e78667001e673b2560")); $this->assertArraySubset($exp1, Arsse::$db->sessionResume("80fa94c1a11f11e78667001e673b2560"));
$this->assertArraySubset($exp2, Arsse::$db->sessionResume("da772f8fa13c11e78667001e673b2560")); $this->assertArraySubset($exp2, Arsse::$db->sessionResume("da772f8fa13c11e78667001e673b2560"));

View file

@ -38,7 +38,7 @@ trait SeriesSubscription {
[4, "jane.doe@example.com", null, "Politics"], [4, "jane.doe@example.com", null, "Politics"],
[5, "john.doe@example.com", null, "Politics"], [5, "john.doe@example.com", null, "Politics"],
[6, "john.doe@example.com", 2, "Politics"], [6, "john.doe@example.com", 2, "Politics"],
] ],
], ],
'arsse_feeds' => [ 'arsse_feeds' => [
'columns' => [ 'columns' => [
@ -51,7 +51,7 @@ trait SeriesSubscription {
'next_fetch' => "datetime", 'next_fetch' => "datetime",
'favicon' => "str", 'favicon' => "str",
], ],
'rows' => [] // filled in the series setup 'rows' => [], // filled in the series setup
], ],
'arsse_subscriptions' => [ 'arsse_subscriptions' => [
'columns' => [ 'columns' => [
@ -67,7 +67,7 @@ trait SeriesSubscription {
[1,"john.doe@example.com",2,null,null,1,2], [1,"john.doe@example.com",2,null,null,1,2],
[2,"jane.doe@example.com",2,null,null,0,0], [2,"jane.doe@example.com",2,null,null,0,0],
[3,"john.doe@example.com",3,"Ook",2,0,1], [3,"john.doe@example.com",3,"Ook",2,0,1],
] ],
], ],
'arsse_tags' => [ 'arsse_tags' => [
'columns' => [ 'columns' => [
@ -113,7 +113,7 @@ trait SeriesSubscription {
[6,3,"","",""], [6,3,"","",""],
[7,3,"","",""], [7,3,"","",""],
[8,3,"","",""], [8,3,"","",""],
] ],
], ],
'arsse_marks' => [ 'arsse_marks' => [
'columns' => [ 'columns' => [
@ -131,7 +131,7 @@ trait SeriesSubscription {
[1,1,1,0], [1,1,1,0],
[7,3,1,0], [7,3,1,0],
[8,3,0,0], [8,3,0,0],
] ],
], ],
]; ];
$this->data['arsse_feeds']['rows'] = [ $this->data['arsse_feeds']['rows'] = [

View file

@ -44,7 +44,7 @@ trait SeriesTag {
[11,"http://example.com/11",""], [11,"http://example.com/11",""],
[12,"http://example.com/12",""], [12,"http://example.com/12",""],
[13,"http://example.com/13",""], [13,"http://example.com/13",""],
] ],
], ],
'arsse_subscriptions' => [ 'arsse_subscriptions' => [
'columns' => [ 'columns' => [
@ -68,7 +68,7 @@ trait SeriesTag {
[12,"john.doe@example.net", 2,null], [12,"john.doe@example.net", 2,null],
[13,"john.doe@example.net", 3,null], [13,"john.doe@example.net", 3,null],
[14,"john.doe@example.net", 4,null], [14,"john.doe@example.net", 4,null],
] ],
], ],
'arsse_tags' => [ 'arsse_tags' => [
'columns' => [ 'columns' => [

View file

@ -51,17 +51,17 @@ trait SeriesToken {
$exp1 = [ $exp1 = [
'id' => "80fa94c1a11f11e78667001e673b2560", 'id' => "80fa94c1a11f11e78667001e673b2560",
'class' => "fever.login", 'class' => "fever.login",
'user' => "jane.doe@example.com" 'user' => "jane.doe@example.com",
]; ];
$exp2 = [ $exp2 = [
'id' => "da772f8fa13c11e78667001e673b2560", 'id' => "da772f8fa13c11e78667001e673b2560",
'class' => "class.class", 'class' => "class.class",
'user' => "john.doe@example.com" 'user' => "john.doe@example.com",
]; ];
$exp3 = [ $exp3 = [
'id' => "ab3b3eb8a13311e78667001e673b2560", 'id' => "ab3b3eb8a13311e78667001e673b2560",
'class' => "class.class", 'class' => "class.class",
'user' => "jane.doe@example.com" 'user' => "jane.doe@example.com",
]; ];
$this->assertArraySubset($exp1, Arsse::$db->tokenLookup("fever.login", "80fa94c1a11f11e78667001e673b2560")); $this->assertArraySubset($exp1, Arsse::$db->tokenLookup("fever.login", "80fa94c1a11f11e78667001e673b2560"));
$this->assertArraySubset($exp2, Arsse::$db->tokenLookup("class.class", "da772f8fa13c11e78667001e673b2560")); $this->assertArraySubset($exp2, Arsse::$db->tokenLookup("class.class", "da772f8fa13c11e78667001e673b2560"));

View file

@ -49,7 +49,7 @@ class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest {
["?,?", [null, null], [null, null], "str"], ["?,?", [null, null], [null, null], "str"],
["null", [], array_fill(0, $l, null), "str"], ["null", [], array_fill(0, $l, null), "str"],
["$intList", [], $ints, "int"], ["$intList", [], $ints, "int"],
["$intList,".($l+1), [], array_merge($ints, [$l+1]), "int"], ["$intList,".($l + 1), [], array_merge($ints, [$l + 1]), "int"],
["$intList,0", [], array_merge($ints, ["OOK"]), "int"], ["$intList,0", [], array_merge($ints, ["OOK"]), "int"],
["$intList", [], array_merge($ints, [null]), "int"], ["$intList", [], array_merge($ints, [null]), "int"],
["$stringList,''", [], array_merge($strings, [""]), "str"], ["$stringList,''", [], array_merge($strings, [""]), "str"],

View file

@ -265,7 +265,7 @@ abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest {
'DateTimeImmutable as strict datetime' => [$dateImmutable, "strict datetime", "'".$dateUTC->format("Y-m-d H:i:s")."'"], 'DateTimeImmutable as strict datetime' => [$dateImmutable, "strict datetime", "'".$dateUTC->format("Y-m-d H:i:s")."'"],
'DateTimeImmutable as strict boolean' => [$dateImmutable, "strict boolean", "1"], 'DateTimeImmutable as strict boolean' => [$dateImmutable, "strict boolean", "1"],
]; ];
foreach ($tests as $index => list($value, $type, $exp)) { foreach ($tests as $index => [$value, $type, $exp]) {
$t = preg_replace("<^strict >", "", $type); $t = preg_replace("<^strict >", "", $type);
$exp = ($exp === "null") ? $exp : $this->decorateTypeSyntax($exp, $t); $exp = ($exp === "null") ? $exp : $this->decorateTypeSyntax($exp, $t);
yield $index => [$value, $type, $exp]; yield $index => [$value, $type, $exp];
@ -316,7 +316,7 @@ abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest {
'DateTimeImmutable as binary' => [$dateImmutable, "binary", "x'".bin2hex($dateUTC->format("Y-m-d H:i:s"))."'"], 'DateTimeImmutable as binary' => [$dateImmutable, "binary", "x'".bin2hex($dateUTC->format("Y-m-d H:i:s"))."'"],
'DateTimeImmutable as strict binary' => [$dateImmutable, "strict binary", "x'".bin2hex($dateUTC->format("Y-m-d H:i:s"))."'"], 'DateTimeImmutable as strict binary' => [$dateImmutable, "strict binary", "x'".bin2hex($dateUTC->format("Y-m-d H:i:s"))."'"],
]; ];
foreach ($tests as $index => list($value, $type, $exp)) { foreach ($tests as $index => [$value, $type, $exp]) {
$t = preg_replace("<^strict >", "", $type); $t = preg_replace("<^strict >", "", $type);
$exp = ($exp === "null") ? $exp : $this->decorateTypeSyntax($exp, $t); $exp = ($exp === "null") ? $exp : $this->decorateTypeSyntax($exp, $t);
yield $index => [$value, $type, $exp]; yield $index => [$value, $type, $exp];

View file

@ -130,7 +130,7 @@ class TestException extends \JKingWeb\Arsse\Test\AbstractTest {
408 => "timeout", 408 => "timeout",
410 => "invalidUrl", 410 => "invalidUrl",
414 => "invalidUrl", 414 => "invalidUrl",
451 => "invalidUrl" 451 => "invalidUrl",
]; ];
$out = array_fill(400, (600 - 400), "transmissionError"); $out = array_fill(400, (600 - 400), "transmissionError");
foreach ($specials as $k => $t) { foreach ($specials as $k => $t) {

View file

@ -7,7 +7,6 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Misc; namespace JKingWeb\Arsse\TestCase\Misc;
use JKingWeb\Arsse\Misc\HTTP; use JKingWeb\Arsse\Misc\HTTP;
use Psr\Http\Message\ResponseInterface;
/** @covers \JKingWeb\Arsse\Misc\HTTP */ /** @covers \JKingWeb\Arsse\Misc\HTTP */
class TestHTTP extends \JKingWeb\Arsse\Test\AbstractTest { class TestHTTP extends \JKingWeb\Arsse\Test\AbstractTest {

View file

@ -7,7 +7,6 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Misc; namespace JKingWeb\Arsse\TestCase\Misc;
use JKingWeb\Arsse\Misc\Query; use JKingWeb\Arsse\Misc\Query;
use JKingWeb\Arsse\Misc\ValueInfo;
/** @covers \JKingWeb\Arsse\Misc\Query */ /** @covers \JKingWeb\Arsse\Misc\Query */
class TestQuery extends \JKingWeb\Arsse\Test\AbstractTest { class TestQuery extends \JKingWeb\Arsse\Test\AbstractTest {

View file

@ -87,7 +87,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[" 1 ", I::VALID], [" 1 ", I::VALID],
]; ];
foreach ($tests as $test) { foreach ($tests as $test) {
list($value, $exp) = $test; [$value, $exp] = $test;
$this->assertSame($exp, I::int($value), "Test returned ".decbin(I::int($value))." for value: ".var_export($value, true)); $this->assertSame($exp, I::int($value), "Test returned ".decbin(I::int($value))." for value: ".var_export($value, true));
} }
} }
@ -157,7 +157,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[new StrClass(" "), I::VALID | I::WHITE], [new StrClass(" "), I::VALID | I::WHITE],
]; ];
foreach ($tests as $test) { foreach ($tests as $test) {
list($value, $exp) = $test; [$value, $exp] = $test;
$this->assertSame($exp, I::str($value), "Test returned ".decbin(I::str($value))." for value: ".var_export($value, true)); $this->assertSame($exp, I::str($value), "Test returned ".decbin(I::str($value))." for value: ".var_export($value, true));
} }
} }
@ -228,7 +228,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[new StrClass(" "), false, false], [new StrClass(" "), false, false],
]; ];
foreach ($tests as $test) { foreach ($tests as $test) {
list($value, $exp, $expNull) = $test; [$value, $exp, $expNull] = $test;
$this->assertSame($exp, I::id($value), "Non-null test failed for value: ".var_export($value, true)); $this->assertSame($exp, I::id($value), "Non-null test failed for value: ".var_export($value, true));
$this->assertSame($expNull, I::id($value, true), "Null test failed for value: ".var_export($value, true)); $this->assertSame($expNull, I::id($value, true), "Null test failed for value: ".var_export($value, true));
} }
@ -300,7 +300,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[new StrClass(" "), null], [new StrClass(" "), null],
]; ];
foreach ($tests as $test) { foreach ($tests as $test) {
list($value, $exp) = $test; [$value, $exp] = $test;
$this->assertSame($exp, I::bool($value), "Null Test failed for value: ".var_export($value, true)); $this->assertSame($exp, I::bool($value), "Null Test failed for value: ".var_export($value, true));
if (is_null($exp)) { if (is_null($exp)) {
$this->assertTrue(I::bool($value, true), "True Test failed for value: ".var_export($value, true)); $this->assertTrue(I::bool($value, true), "True Test failed for value: ".var_export($value, true));
@ -407,7 +407,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[I::T_STRING | I::M_STRICT, "Bare string", ["Bare string"]], [I::T_STRING | I::M_STRICT, "Bare string", ["Bare string"]],
]; ];
foreach ($tests as $index => $test) { foreach ($tests as $index => $test) {
list($type, $value, $exp) = $test; [$type, $value, $exp] = $test;
$this->assertEquals($exp, I::normalize($value, $type | I::M_ARRAY, "iso8601"), "Failed test #$index"); $this->assertEquals($exp, I::normalize($value, $type | I::M_ARRAY, "iso8601"), "Failed test #$index");
} }
// Date-to-string format tests // Date-to-string format tests
@ -525,15 +525,15 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[$this->d("2010-01-01T00:00:00", 0, 1), [null,true], [true, false], [1262304000, false], [1262304000.0, false], ["2010-01-01T00:00:00Z",true], [[$this->d("2010-01-01T00:00:00", 0, 1)],false], [null, false]], [$this->d("2010-01-01T00:00:00", 0, 1), [null,true], [true, false], [1262304000, false], [1262304000.0, false], ["2010-01-01T00:00:00Z",true], [[$this->d("2010-01-01T00:00:00", 0, 1)],false], [null, false]],
[$this->d("2010-01-01T00:00:00", 1, 0), [null,true], [true, false], [1262322000, false], [1262322000.0, false], ["2010-01-01T05:00:00Z",true], [[$this->d("2010-01-01T00:00:00", 1, 0)],false], [null, false]], [$this->d("2010-01-01T00:00:00", 1, 0), [null,true], [true, false], [1262322000, false], [1262322000.0, false], ["2010-01-01T05:00:00Z",true], [[$this->d("2010-01-01T00:00:00", 1, 0)],false], [null, false]],
[$this->d("2010-01-01T00:00:00", 1, 1), [null,true], [true, false], [1262322000, false], [1262322000.0, false], ["2010-01-01T05:00:00Z",true], [[$this->d("2010-01-01T00:00:00", 1, 1)],false], [null, false]], [$this->d("2010-01-01T00:00:00", 1, 1), [null,true], [true, false], [1262322000, false], [1262322000.0, false], ["2010-01-01T05:00:00Z",true], [[$this->d("2010-01-01T00:00:00", 1, 1)],false], [null, false]],
[1e14, [null,true], [true, false], [pow(10, 14), true], [1e14, true], ["100000000000000", true], [[1e14], false], [$this->i("P1157407407DT9H46M40S"), false]], [1e14, [null,true], [true, false], [10 ** 14, true], [1e14, true], ["100000000000000", true], [[1e14], false], [$this->i("P1157407407DT9H46M40S"), false]],
[1e-6, [null,true], [true, false], [0, false], [1e-6, true], ["0.000001", true], [[1e-6], false], [$this->i("PT0S", 1e-6), false]], [1e-6, [null,true], [true, false], [0, false], [1e-6, true], ["0.000001", true], [[1e-6], false], [$this->i("PT0S", 1e-6), false]],
[[1,2,3], [null,true], [true, false], [0, false], [0.0, false], ["", false], [[1,2,3], true], [null, false]], [[1,2,3], [null,true], [true, false], [0, false], [0.0, false], ["", false], [[1,2,3], true], [null, false]],
[['a'=>1,'b'=>2], [null,true], [true, false], [0, false], [0.0, false], ["", false], [['a'=>1,'b'=>2], true], [null, false]], [['a' => 1,'b' => 2], [null,true], [true, false], [0, false], [0.0, false], ["", false], [['a' => 1,'b' => 2], true], [null, false]],
[new Result([['a'=>1,'b'=>2]]), [null,true], [true, false], [0, false], [0.0, false], ["", false], [[['a'=>1,'b'=>2]], true], [null, false]], [new Result([['a' => 1,'b' => 2]]), [null,true], [true, false], [0, false], [0.0, false], ["", false], [[['a' => 1,'b' => 2]], true], [null, false]],
[$this->i("PT1H"), [null,true], [true, false], [60*60, false], [60.0*60.0, false], ["PT1H", true], [[$this->i("PT1H")], false], [$this->i("PT1H"), true]], [$this->i("PT1H"), [null,true], [true, false], [60 * 60, false], [60.0 * 60.0, false], ["PT1H", true], [[$this->i("PT1H")], false], [$this->i("PT1H"), true]],
[$this->i("P2DT1H"), [null,true], [true, false], [(48+1)*60*60, false], [1.0*(48+1)*60*60, false], ["P2DT1H", true], [[$this->i("P2DT1H")], false], [$this->i("P2DT1H"), true]], [$this->i("P2DT1H"), [null,true], [true, false], [(48 + 1) * 60 * 60, false], [1.0 * (48 + 1) * 60 * 60, false], ["P2DT1H", true], [[$this->i("P2DT1H")], false], [$this->i("P2DT1H"), true]],
[$this->i("PT0H"), [null,true], [true, false], [0, false], [0.0, false], ["PT0S", true], [[$this->i("PT0H")], false], [$this->i("PT0H"), true]], [$this->i("PT0H"), [null,true], [true, false], [0, false], [0.0, false], ["PT0S", true], [[$this->i("PT0H")], false], [$this->i("PT0H"), true]],
[$dateDiff, [null,true], [true, false], [366*24*60*60, false], [1.0*366*24*60*60, false], ["P366D", true], [[$dateDiff], false], [$dateNorm, true]], [$dateDiff, [null,true], [true, false], [366 * 24 * 60 * 60, false], [1.0 * 366 * 24 * 60 * 60, false], ["P366D", true], [[$dateDiff], false], [$dateNorm, true]],
["1 year, 2 days", [null,true], [true, false], [0, false], [0.0, false], ["1 year, 2 days", true], [["1 year, 2 days"], false], [$this->i("P1Y2D"), false]], ["1 year, 2 days", [null,true], [true, false], [0, false], [0.0, false], ["1 year, 2 days", true], [["1 year, 2 days"], false], [$this->i("P1Y2D"), false]],
["P1Y2D", [null,true], [true, false], [0, false], [0.0, false], ["P1Y2D", true], [["P1Y2D"], false], [$this->i("P1Y2D"), true]], ["P1Y2D", [null,true], [true, false], [0, false], [0.0, false], ["P1Y2D", true], [["P1Y2D"], false], [$this->i("P1Y2D"), true]],
] as $set) { ] as $set) {
@ -542,14 +542,14 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
// shift a mixed-type passthrough test onto the set // shift a mixed-type passthrough test onto the set
array_unshift($set, [$input, true]); array_unshift($set, [$input, true]);
// generate a set of tests for each target data type // generate a set of tests for each target data type
foreach ($set as $type => list($exp, $pass)) { foreach ($set as $type => [$exp, $pass]) {
// emit one test each for loose mode, strict mode, drop mode, and strict+drop mode // emit one test each for loose mode, strict mode, drop mode, and strict+drop mode
foreach ([ foreach ([
[false, false], [false, false],
[true, false], [true, false],
[false, true], [false, true],
[true, true], [true, true],
] as list($strict, $drop)) { ] as [$strict, $drop]) {
yield [$input, $types[$type], $exp, $pass, $strict, $drop]; yield [$input, $types[$type], $exp, $pass, $strict, $drop];
} }
} }
@ -572,37 +572,37 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
foreach ([ foreach ([
/* Input value microtime iso8601 iso8601m http sql date time unix float '!M j, Y (D)' *strtotime* (null) */ /* Input value microtime iso8601 iso8601m http sql date time unix float '!M j, Y (D)' *strtotime* (null) */
[null, null, null, null, null, null, null, null, null, null, null, null, ], [null, null, null, null, null, null, null, null, null, null, null, null],
[INF, null, null, null, null, null, null, null, null, null, null, null, ], [INF, null, null, null, null, null, null, null, null, null, null, null],
[NAN, null, null, null, null, null, null, null, null, null, null, null, ], [NAN, null, null, null, null, null, null, null, null, null, null, null],
[$this->d("2010-01-01T00:00:00", 0, 0), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), ], [$this->d("2010-01-01T00:00:00", 0, 0), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000)],
[$this->d("2010-01-01T00:00:00", 0, 1), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), ], [$this->d("2010-01-01T00:00:00", 0, 1), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000)],
[$this->d("2010-01-01T00:00:00", 1, 0), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), ], [$this->d("2010-01-01T00:00:00", 1, 0), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000)],
[$this->d("2010-01-01T00:00:00", 1, 1), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), ], [$this->d("2010-01-01T00:00:00", 1, 1), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000), $this->t(1262322000)],
[1262304000, $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), ], [1262304000, $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000), $this->t(1262304000)],
[1262304000.123456, $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), ], [1262304000.123456, $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456), $this->t(1262304000.123456)],
[1262304000.42, $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), ], [1262304000.42, $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42), $this->t(1262304000.42)],
["0.12345600 1262304000", $this->t(1262304000.123456), null, null, null, null, null, null, null, null, null, null, ], ["0.12345600 1262304000", $this->t(1262304000.123456), null, null, null, null, null, null, null, null, null, null],
["0.42 1262304000", null, null, null, null, null, null, null, null, null, null, null, ], ["0.42 1262304000", null, null, null, null, null, null, null, null, null, null, null],
["2010-01-01T00:00:00", null, $this->t(1262304000), $this->t(1262304000), null, null, null, null, null, null, null, $this->t(1262304000), ], ["2010-01-01T00:00:00", null, $this->t(1262304000), $this->t(1262304000), null, null, null, null, null, null, null, $this->t(1262304000)],
["2010-01-01T00:00:00Z", null, $this->t(1262304000), $this->t(1262304000), null, null, null, null, null, null, null, $this->t(1262304000), ], ["2010-01-01T00:00:00Z", null, $this->t(1262304000), $this->t(1262304000), null, null, null, null, null, null, null, $this->t(1262304000)],
["2010-01-01T00:00:00+0000", null, $this->t(1262304000), $this->t(1262304000), null, null, null, null, null, null, null, $this->t(1262304000), ], ["2010-01-01T00:00:00+0000", null, $this->t(1262304000), $this->t(1262304000), null, null, null, null, null, null, null, $this->t(1262304000)],
["2010-01-01T00:00:00-0000", null, $this->t(1262304000), $this->t(1262304000), null, null, null, null, null, null, null, $this->t(1262304000), ], ["2010-01-01T00:00:00-0000", null, $this->t(1262304000), $this->t(1262304000), null, null, null, null, null, null, null, $this->t(1262304000)],
["2010-01-01T00:00:00+00:00", null, $this->t(1262304000), $this->t(1262304000), null, null, null, null, null, null, null, $this->t(1262304000), ], ["2010-01-01T00:00:00+00:00", null, $this->t(1262304000), $this->t(1262304000), null, null, null, null, null, null, null, $this->t(1262304000)],
["2010-01-01T00:00:00-05:00", null, $this->t(1262322000), $this->t(1262322000), null, null, null, null, null, null, null, $this->t(1262322000), ], ["2010-01-01T00:00:00-05:00", null, $this->t(1262322000), $this->t(1262322000), null, null, null, null, null, null, null, $this->t(1262322000)],
["2010-01-01T00:00:00.123456Z", null, null, $this->t(1262304000.123456), null, null, null, null, null, null, null, $this->t(1262304000.123456), ], ["2010-01-01T00:00:00.123456Z", null, null, $this->t(1262304000.123456), null, null, null, null, null, null, null, $this->t(1262304000.123456)],
["Fri, 01 Jan 2010 00:00:00 GMT", null, null, null, $this->t(1262304000), null, null, null, null, null, null, $this->t(1262304000), ], ["Fri, 01 Jan 2010 00:00:00 GMT", null, null, null, $this->t(1262304000), null, null, null, null, null, null, $this->t(1262304000)],
["2010-01-01 00:00:00", null, null, null, null, $this->t(1262304000), null, null, null, null, null, $this->t(1262304000), ], ["2010-01-01 00:00:00", null, null, null, null, $this->t(1262304000), null, null, null, null, null, $this->t(1262304000)],
["2010-01-01", null, null, null, null, null, $this->t(1262304000), null, null, null, null, $this->t(1262304000), ], ["2010-01-01", null, null, null, null, null, $this->t(1262304000), null, null, null, null, $this->t(1262304000)],
["12:34:56", null, null, null, null, null, null, $this->t(45296), null, null, null, $this->t(date_create("today", new \DateTimezone("UTC"))->getTimestamp()+45296), ], ["12:34:56", null, null, null, null, null, null, $this->t(45296), null, null, null, $this->t(date_create("today", new \DateTimezone("UTC"))->getTimestamp() + 45296)],
["1262304000", null, null, null, null, null, null, null, $this->t(1262304000), null, null, null, ], ["1262304000", null, null, null, null, null, null, null, $this->t(1262304000), null, null, null],
["1262304000.123456", null, null, null, null, null, null, null, null, $this->t(1262304000.123456), null, null, ], ["1262304000.123456", null, null, null, null, null, null, null, null, $this->t(1262304000.123456), null, null],
["1262304000.42", null, null, null, null, null, null, null, null, $this->t(1262304000.42), null, null, ], ["1262304000.42", null, null, null, null, null, null, null, null, $this->t(1262304000.42), null, null],
["Jan 1, 2010 (Fri)", null, null, null, null, null, null, null, null, null, $this->t(1262304000), null, ], ["Jan 1, 2010 (Fri)", null, null, null, null, null, null, null, null, null, $this->t(1262304000), null],
["First day of Jan 2010 12AM", null, null, null, null, null, null, null, null, null, null, $this->t(1262304000), ], ["First day of Jan 2010 12AM", null, null, null, null, null, null, null, null, null, null, $this->t(1262304000)],
[[], null, null, null, null, null, null, null, null, null, null, null, ], [[], null, null, null, null, null, null, null, null, null, null, null],
[$this->i("P1Y2D"), null, null, null, null, null, null, null, null, null, null, null, ], [$this->i("P1Y2D"), null, null, null, null, null, null, null, null, null, null, null],
["P1Y2D", null, null, null, null, null, null, null, null, null, null, null, ], ["P1Y2D", null, null, null, null, null, null, null, null, null, null, null],
] as $set) { ] as $set) {
// shift the input value off the set // shift the input value off the set
$input = array_shift($set); $input = array_shift($set);
@ -614,7 +614,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[true, false], [true, false],
[false, true], [false, true],
[true, true], [true, true],
] as list($strict, $drop)) { ] as [$strict, $drop]) {
yield [$input, $formats[$format], $exp, $strict, $drop]; yield [$input, $formats[$format], $exp, $strict, $drop];
} }
} }

View file

@ -334,21 +334,15 @@ class TestAPI extends \JKingWeb\Arsse\Test\AbstractTest {
$unread = [['id' => 4],['id' => 5],['id' => 6]]; $unread = [['id' => 4],['id' => 5],['id' => 6]];
\Phake::when(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->starred(true))->thenReturn(new Result($saved)); \Phake::when(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->starred(true))->thenReturn(new Result($saved));
\Phake::when(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->unread(true))->thenReturn(new Result($unread)); \Phake::when(Arsse::$db)->articleList(Arsse::$user->id, (new Context)->unread(true))->thenReturn(new Result($unread));
$exp = new JsonResponse([ $exp = new JsonResponse(['saved_item_ids' => "1,2,3"]);
'saved_item_ids' => "1,2,3"
]);
$this->assertMessage($exp, $this->h->dispatch($this->req("api&saved_item_ids"))); $this->assertMessage($exp, $this->h->dispatch($this->req("api&saved_item_ids")));
$exp = new JsonResponse([ $exp = new JsonResponse(['unread_item_ids' => "4,5,6"]);
'unread_item_ids' => "4,5,6"
]);
$this->assertMessage($exp, $this->h->dispatch($this->req("api&unread_item_ids"))); $this->assertMessage($exp, $this->h->dispatch($this->req("api&unread_item_ids")));
} }
public function testListHotLinks(): void { public function testListHotLinks(): void {
// hot links are not actually implemented, so an empty array should be all we get // hot links are not actually implemented, so an empty array should be all we get
$exp = new JsonResponse([ $exp = new JsonResponse(['links' => []]);
'links' => []
]);
$this->assertMessage($exp, $this->h->dispatch($this->req("api&links"))); $this->assertMessage($exp, $this->h->dispatch($this->req("api&links")));
} }

View file

@ -430,10 +430,10 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
public function provideFolderCreations(): array { public function provideFolderCreations(): array {
return [ return [
[['name' => "Software"], true, 1, new Response(['folders' => [['id'=> 1, 'name' => "Software"]]])], [['name' => "Software"], true, 1, new Response(['folders' => [['id' => 1, 'name' => "Software"]]])],
[['name' => "Software"], false, 1, new Response(['folders' => [['id'=> 1, 'name' => "Software"]]])], [['name' => "Software"], false, 1, new Response(['folders' => [['id' => 1, 'name' => "Software"]]])],
[['name' => "Hardware"], true, "2", new Response(['folders' => [['id'=> 2, 'name' => "Hardware"]]])], [['name' => "Hardware"], true, "2", new Response(['folders' => [['id' => 2, 'name' => "Hardware"]]])],
[['name' => "Hardware"], false, "2", new Response(['folders' => [['id'=> 2, 'name' => "Hardware"]]])], [['name' => "Hardware"], false, "2", new Response(['folders' => [['id' => 2, 'name' => "Hardware"]]])],
[['name' => "Software"], true, new ExceptionInput("constraintViolation"), new EmptyResponse(409)], [['name' => "Software"], true, new ExceptionInput("constraintViolation"), new EmptyResponse(409)],
[['name' => ""], true, new ExceptionInput("whitespace"), new EmptyResponse(422)], [['name' => ""], true, new ExceptionInput("whitespace"), new EmptyResponse(422)],
[['name' => " "], true, new ExceptionInput("whitespace"), new EmptyResponse(422)], [['name' => " "], true, new ExceptionInput("whitespace"), new EmptyResponse(422)],
@ -839,7 +839,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
'warnings' => [ 'warnings' => [
'improperlyConfiguredCron' => false, 'improperlyConfiguredCron' => false,
'incorrectDbCharset' => false, 'incorrectDbCharset' => false,
] ],
]; ];
$arr2['warnings']['improperlyConfiguredCron'] = true; $arr2['warnings']['improperlyConfiguredCron'] = true;
$arr2['warnings']['incorrectDbCharset'] = true; $arr2['warnings']['incorrectDbCharset'] = true;

View file

@ -8,7 +8,6 @@ namespace JKingWeb\Arsse\TestCase\REST\NextcloudNews;
use JKingWeb\Arsse\REST\NextcloudNews\Versions; use JKingWeb\Arsse\REST\NextcloudNews\Versions;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Laminas\Diactoros\ServerRequest;
use Laminas\Diactoros\Response\JsonResponse as Response; use Laminas\Diactoros\Response\JsonResponse as Response;
use Laminas\Diactoros\Response\EmptyResponse; use Laminas\Diactoros\Response\EmptyResponse;

View file

@ -222,7 +222,7 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
["OPTIONS", ['Origin' => "http://example"], [], [ ["OPTIONS", ['Origin' => "http://example"], [], [
'Access-Control-Allow-Origin' => "http://example", 'Access-Control-Allow-Origin' => "http://example",
'Access-Control-Allow-Credentials' => "true", 'Access-Control-Allow-Credentials' => "true",
'Access-Control-Max-Age' => (string) (60 *60 *24), 'Access-Control-Max-Age' => (string) (60 * 60 * 24),
'Vary' => "Origin", 'Vary' => "Origin",
]], ]],
["OPTIONS", ['Origin' => "http://example"], ['Allow' => "GET, PUT, HEAD, OPTIONS"], [ ["OPTIONS", ['Origin' => "http://example"], ['Allow' => "GET, PUT, HEAD, OPTIONS"], [
@ -230,21 +230,21 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
'Access-Control-Allow-Origin' => "http://example", 'Access-Control-Allow-Origin' => "http://example",
'Access-Control-Allow-Credentials' => "true", 'Access-Control-Allow-Credentials' => "true",
'Access-Control-Allow-Methods' => "GET, PUT, HEAD, OPTIONS", 'Access-Control-Allow-Methods' => "GET, PUT, HEAD, OPTIONS",
'Access-Control-Max-Age' => (string) (60 *60 *24), 'Access-Control-Max-Age' => (string) (60 * 60 * 24),
'Vary' => "Origin", 'Vary' => "Origin",
]], ]],
["OPTIONS", ['Origin' => "http://example", 'Access-Control-Request-Headers' => "Content-Type, If-None-Match"], [], [ ["OPTIONS", ['Origin' => "http://example", 'Access-Control-Request-Headers' => "Content-Type, If-None-Match"], [], [
'Access-Control-Allow-Origin' => "http://example", 'Access-Control-Allow-Origin' => "http://example",
'Access-Control-Allow-Credentials' => "true", 'Access-Control-Allow-Credentials' => "true",
'Access-Control-Allow-Headers' => "Content-Type, If-None-Match", 'Access-Control-Allow-Headers' => "Content-Type, If-None-Match",
'Access-Control-Max-Age' => (string) (60 *60 *24), 'Access-Control-Max-Age' => (string) (60 * 60 * 24),
'Vary' => "Origin", 'Vary' => "Origin",
]], ]],
["OPTIONS", ['Origin' => "http://example", 'Access-Control-Request-Headers' => ["Content-Type", "If-None-Match"]], [], [ ["OPTIONS", ['Origin' => "http://example", 'Access-Control-Request-Headers' => ["Content-Type", "If-None-Match"]], [], [
'Access-Control-Allow-Origin' => "http://example", 'Access-Control-Allow-Origin' => "http://example",
'Access-Control-Allow-Credentials' => "true", 'Access-Control-Allow-Credentials' => "true",
'Access-Control-Allow-Headers' => "Content-Type,If-None-Match", 'Access-Control-Allow-Headers' => "Content-Type,If-None-Match",
'Access-Control-Max-Age' => (string) (60 *60 *24), 'Access-Control-Max-Age' => (string) (60 * 60 * 24),
'Vary' => "Origin", 'Vary' => "Origin",
]], ]],
]; ];
@ -295,7 +295,7 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
} }
/** @dataProvider provideMockRequests */ /** @dataProvider provideMockRequests */
public function testDispatchRequests(ServerRequest $req, string $method, bool $called, string $class = "", string $target =""): void { public function testDispatchRequests(ServerRequest $req, string $method, bool $called, string $class = "", string $target = ""): void {
$r = \Phake::partialMock(REST::class); $r = \Phake::partialMock(REST::class);
\Phake::when($r)->normalizeResponse->thenReturnCallback(function($res) { \Phake::when($r)->normalizeResponse->thenReturnCallback(function($res) {
return $res; return $res;

View file

@ -17,7 +17,6 @@ use JKingWeb\Arsse\Db\ExceptionInput;
use JKingWeb\Arsse\Db\Transaction; use JKingWeb\Arsse\Db\Transaction;
use JKingWeb\Arsse\REST\TinyTinyRSS\API; use JKingWeb\Arsse\REST\TinyTinyRSS\API;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Laminas\Diactoros\ServerRequest;
use Laminas\Diactoros\Response\JsonResponse as Response; use Laminas\Diactoros\Response\JsonResponse as Response;
use Laminas\Diactoros\Response\EmptyResponse; use Laminas\Diactoros\Response\EmptyResponse;
@ -984,7 +983,7 @@ LONG_STRING;
public function testAddALabel(): void { public function testAddALabel(): void {
$in = [ $in = [
['op' => "addLabel", 'sid' => "PriestsOfSyrinx", 'caption' => "Software"], ['op' => "addLabel", 'sid' => "PriestsOfSyrinx", 'caption' => "Software"],
['op' => "addLabel", 'sid' => "PriestsOfSyrinx", 'caption' => "Hardware",], ['op' => "addLabel", 'sid' => "PriestsOfSyrinx", 'caption' => "Hardware"],
['op' => "addLabel", 'sid' => "PriestsOfSyrinx"], ['op' => "addLabel", 'sid' => "PriestsOfSyrinx"],
['op' => "addLabel", 'sid' => "PriestsOfSyrinx", 'caption' => ""], ['op' => "addLabel", 'sid' => "PriestsOfSyrinx", 'caption' => ""],
['op' => "addLabel", 'sid' => "PriestsOfSyrinx", 'caption' => " "], ['op' => "addLabel", 'sid' => "PriestsOfSyrinx", 'caption' => " "],
@ -1301,9 +1300,9 @@ LONG_STRING;
\Phake::when(Arsse::$db)->articleCount($this->anything(), $this->equalTo((new Context)->unread(true)->modifiedSince(Date::sub("PT24H")), 2))->thenReturn(7); \Phake::when(Arsse::$db)->articleCount($this->anything(), $this->equalTo((new Context)->unread(true)->modifiedSince(Date::sub("PT24H")), 2))->thenReturn(7);
\Phake::when(Arsse::$db)->articleStarred($this->anything())->thenReturn($this->v($this->starred)); \Phake::when(Arsse::$db)->articleStarred($this->anything())->thenReturn($this->v($this->starred));
// the expectations are packed tightly since they're very verbose; one can use var_export() (or convert to JSON) to pretty-print them // the expectations are packed tightly since they're very verbose; one can use var_export() (or convert to JSON) to pretty-print them
$exp = ['categories'=>['identifier'=>'id','label'=>'name','items'=>[['name'=>'Special','id'=>'CAT:-1','bare_id'=>-1,'type'=>'category','unread'=>0,'items'=>[['name'=>'All articles','id'=>'FEED:-4','bare_id'=>-4,'icon'=>'images/folder.png','unread'=>35,'type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'',],['name'=>'Fresh articles','id'=>'FEED:-3','bare_id'=>-3,'icon'=>'images/fresh.png','unread'=>7,'type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'',],['name'=>'Starred articles','id'=>'FEED:-1','bare_id'=>-1,'icon'=>'images/star.png','unread'=>4,'type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'',],['name'=>'Published articles','id'=>'FEED:-2','bare_id'=>-2,'icon'=>'images/feed.png','unread'=>0,'type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'',],['name'=>'Archived articles','id'=>'FEED:0','bare_id'=>0,'icon'=>'images/archive.png','unread'=>0,'type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'',],['name'=>'Recently read','id'=>'FEED:-6','bare_id'=>-6,'icon'=>'images/time.png','unread'=>0,'type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'',],],],['name'=>'Labels','id'=>'CAT:-2','bare_id'=>-2,'type'=>'category','unread'=>6,'items'=>[['name'=>'Fascinating','id'=>'FEED:-1027','bare_id'=>-1027,'unread'=>0,'icon'=>'images/label.png','type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'','fg_color'=>'','bg_color'=>'',],['name'=>'Interesting','id'=>'FEED:-1029','bare_id'=>-1029,'unread'=>0,'icon'=>'images/label.png','type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'','fg_color'=>'','bg_color'=>'',],['name'=>'Logical','id'=>'FEED:-1025','bare_id'=>-1025,'unread'=>0,'icon'=>'images/label.png','type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'','fg_color'=>'','bg_color'=>'',],],],['name'=>'Photography','id'=>'CAT:4','bare_id'=>4,'parent_id'=>null,'type'=>'category','auxcounter'=>0,'unread'=>0,'child_unread'=>0,'checkbox'=>false,'param'=>'(0 feeds)','items'=>[],],['name'=>'Politics','id'=>'CAT:3','bare_id'=>3,'parent_id'=>null,'type'=>'category','auxcounter'=>0,'unread'=>0,'child_unread'=>0,'checkbox'=>false,'param'=>'(3 feeds)','items'=>[['name'=>'Local','id'=>'CAT:5','bare_id'=>5,'parent_id'=>3,'type'=>'category','auxcounter'=>0,'unread'=>0,'child_unread'=>0,'checkbox'=>false,'param'=>'(1 feed)','items'=>[['name'=>'Toronto Star','id'=>'FEED:2','bare_id'=>2,'icon'=>'feed-icons/2.ico','error'=>'oops','param'=>'2011-11-11T11:11:11Z','unread'=>0,'auxcounter'=>0,'checkbox'=>false,],],],['name'=>'National','id'=>'CAT:6','bare_id'=>6,'parent_id'=>3,'type'=>'category','auxcounter'=>0,'unread'=>0,'child_unread'=>0,'checkbox'=>false,'param'=>'(2 feeds)','items'=>[['name'=>'CBC News','id'=>'FEED:4','bare_id'=>4,'icon'=>'feed-icons/4.ico','error'=>'','param'=>'2017-10-09T15:58:34Z','unread'=>0,'auxcounter'=>0,'checkbox'=>false,],['name'=>'Ottawa Citizen','id'=>'FEED:5','bare_id'=>5,'icon'=>false,'error'=>'','param'=>'2017-07-07T17:07:17Z','unread'=>0,'auxcounter'=>0,'checkbox'=>false,],],],],],['name'=>'Science','id'=>'CAT:1','bare_id'=>1,'parent_id'=>null,'type'=>'category','auxcounter'=>0,'unread'=>0,'child_unread'=>0,'checkbox'=>false,'param'=>'(2 feeds)','items'=>[['name'=>'Rocketry','id'=>'CAT:2','bare_id'=>2,'parent_id'=>1,'type'=>'category','auxcounter'=>0,'unread'=>0,'child_unread'=>0,'checkbox'=>false,'param'=>'(1 feed)','items'=>[['name'=>'NASA JPL','id'=>'FEED:1','bare_id'=>1,'icon'=>false,'error'=>'','param'=>'2017-09-15T22:54:16Z','unread'=>0,'auxcounter'=>0,'checkbox'=>false,],],],['name'=>'Ars Technica','id'=>'FEED:3','bare_id'=>3,'icon'=>'feed-icons/3.ico','error'=>'argh','param'=>'2016-05-23T06:40:02Z','unread'=>0,'auxcounter'=>0,'checkbox'=>false,],],],['name'=>'Uncategorized','id'=>'CAT:0','bare_id'=>0,'type'=>'category','auxcounter'=>0,'unread'=>0,'child_unread'=>0,'checkbox'=>false,'parent_id'=>null,'param'=>'(1 feed)','items'=>[['name'=>'Eurogamer','id'=>'FEED:6','bare_id'=>6,'icon'=>'feed-icons/6.ico','error'=>'','param'=>'2010-02-12T20:08:47Z','unread'=>0,'auxcounter'=>0,'checkbox'=>false,],],],],],]; $exp = ['categories' => ['identifier' => 'id','label' => 'name','items' => [['name' => 'Special','id' => 'CAT:-1','bare_id' => -1,'type' => 'category','unread' => 0,'items' => [['name' => 'All articles','id' => 'FEED:-4','bare_id' => -4,'icon' => 'images/folder.png','unread' => 35,'type' => 'feed','auxcounter' => 0,'error' => '','updated' => ''],['name' => 'Fresh articles','id' => 'FEED:-3','bare_id' => -3,'icon' => 'images/fresh.png','unread' => 7,'type' => 'feed','auxcounter' => 0,'error' => '','updated' => ''],['name' => 'Starred articles','id' => 'FEED:-1','bare_id' => -1,'icon' => 'images/star.png','unread' => 4,'type' => 'feed','auxcounter' => 0,'error' => '','updated' => ''],['name' => 'Published articles','id' => 'FEED:-2','bare_id' => -2,'icon' => 'images/feed.png','unread' => 0,'type' => 'feed','auxcounter' => 0,'error' => '','updated' => ''],['name' => 'Archived articles','id' => 'FEED:0','bare_id' => 0,'icon' => 'images/archive.png','unread' => 0,'type' => 'feed','auxcounter' => 0,'error' => '','updated' => ''],['name' => 'Recently read','id' => 'FEED:-6','bare_id' => -6,'icon' => 'images/time.png','unread' => 0,'type' => 'feed','auxcounter' => 0,'error' => '','updated' => '']]],['name' => 'Labels','id' => 'CAT:-2','bare_id' => -2,'type' => 'category','unread' => 6,'items' => [['name' => 'Fascinating','id' => 'FEED:-1027','bare_id' => -1027,'unread' => 0,'icon' => 'images/label.png','type' => 'feed','auxcounter' => 0,'error' => '','updated' => '','fg_color' => '','bg_color' => ''],['name' => 'Interesting','id' => 'FEED:-1029','bare_id' => -1029,'unread' => 0,'icon' => 'images/label.png','type' => 'feed','auxcounter' => 0,'error' => '','updated' => '','fg_color' => '','bg_color' => ''],['name' => 'Logical','id' => 'FEED:-1025','bare_id' => -1025,'unread' => 0,'icon' => 'images/label.png','type' => 'feed','auxcounter' => 0,'error' => '','updated' => '','fg_color' => '','bg_color' => '']]],['name' => 'Photography','id' => 'CAT:4','bare_id' => 4,'parent_id' => null,'type' => 'category','auxcounter' => 0,'unread' => 0,'child_unread' => 0,'checkbox' => false,'param' => '(0 feeds)','items' => []],['name' => 'Politics','id' => 'CAT:3','bare_id' => 3,'parent_id' => null,'type' => 'category','auxcounter' => 0,'unread' => 0,'child_unread' => 0,'checkbox' => false,'param' => '(3 feeds)','items' => [['name' => 'Local','id' => 'CAT:5','bare_id' => 5,'parent_id' => 3,'type' => 'category','auxcounter' => 0,'unread' => 0,'child_unread' => 0,'checkbox' => false,'param' => '(1 feed)','items' => [['name' => 'Toronto Star','id' => 'FEED:2','bare_id' => 2,'icon' => 'feed-icons/2.ico','error' => 'oops','param' => '2011-11-11T11:11:11Z','unread' => 0,'auxcounter' => 0,'checkbox' => false]]],['name' => 'National','id' => 'CAT:6','bare_id' => 6,'parent_id' => 3,'type' => 'category','auxcounter' => 0,'unread' => 0,'child_unread' => 0,'checkbox' => false,'param' => '(2 feeds)','items' => [['name' => 'CBC News','id' => 'FEED:4','bare_id' => 4,'icon' => 'feed-icons/4.ico','error' => '','param' => '2017-10-09T15:58:34Z','unread' => 0,'auxcounter' => 0,'checkbox' => false],['name' => 'Ottawa Citizen','id' => 'FEED:5','bare_id' => 5,'icon' => false,'error' => '','param' => '2017-07-07T17:07:17Z','unread' => 0,'auxcounter' => 0,'checkbox' => false]]]]],['name' => 'Science','id' => 'CAT:1','bare_id' => 1,'parent_id' => null,'type' => 'category','auxcounter' => 0,'unread' => 0,'child_unread' => 0,'checkbox' => false,'param' => '(2 feeds)','items' => [['name' => 'Rocketry','id' => 'CAT:2','bare_id' => 2,'parent_id' => 1,'type' => 'category','auxcounter' => 0,'unread' => 0,'child_unread' => 0,'checkbox' => false,'param' => '(1 feed)','items' => [['name' => 'NASA JPL','id' => 'FEED:1','bare_id' => 1,'icon' => false,'error' => '','param' => '2017-09-15T22:54:16Z','unread' => 0,'auxcounter' => 0,'checkbox' => false]]],['name' => 'Ars Technica','id' => 'FEED:3','bare_id' => 3,'icon' => 'feed-icons/3.ico','error' => 'argh','param' => '2016-05-23T06:40:02Z','unread' => 0,'auxcounter' => 0,'checkbox' => false]]],['name' => 'Uncategorized','id' => 'CAT:0','bare_id' => 0,'type' => 'category','auxcounter' => 0,'unread' => 0,'child_unread' => 0,'checkbox' => false,'parent_id' => null,'param' => '(1 feed)','items' => [['name' => 'Eurogamer','id' => 'FEED:6','bare_id' => 6,'icon' => 'feed-icons/6.ico','error' => '','param' => '2010-02-12T20:08:47Z','unread' => 0,'auxcounter' => 0,'checkbox' => false]]]]]];
$this->assertMessage($this->respGood($exp), $this->req($in[0])); $this->assertMessage($this->respGood($exp), $this->req($in[0]));
$exp = ['categories'=>['identifier'=>'id','label'=>'name','items'=>[['name'=>'Special','id'=>'CAT:-1','bare_id'=>-1,'type'=>'category','unread'=>0,'items'=>[['name'=>'All articles','id'=>'FEED:-4','bare_id'=>-4,'icon'=>'images/folder.png','unread'=>35,'type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'',],['name'=>'Fresh articles','id'=>'FEED:-3','bare_id'=>-3,'icon'=>'images/fresh.png','unread'=>7,'type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'',],['name'=>'Starred articles','id'=>'FEED:-1','bare_id'=>-1,'icon'=>'images/star.png','unread'=>4,'type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'',],['name'=>'Published articles','id'=>'FEED:-2','bare_id'=>-2,'icon'=>'images/feed.png','unread'=>0,'type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'',],['name'=>'Archived articles','id'=>'FEED:0','bare_id'=>0,'icon'=>'images/archive.png','unread'=>0,'type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'',],['name'=>'Recently read','id'=>'FEED:-6','bare_id'=>-6,'icon'=>'images/time.png','unread'=>0,'type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'',],],],['name'=>'Labels','id'=>'CAT:-2','bare_id'=>-2,'type'=>'category','unread'=>6,'items'=>[['name'=>'Fascinating','id'=>'FEED:-1027','bare_id'=>-1027,'unread'=>0,'icon'=>'images/label.png','type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'','fg_color'=>'','bg_color'=>'',],['name'=>'Interesting','id'=>'FEED:-1029','bare_id'=>-1029,'unread'=>0,'icon'=>'images/label.png','type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'','fg_color'=>'','bg_color'=>'',],['name'=>'Logical','id'=>'FEED:-1025','bare_id'=>-1025,'unread'=>0,'icon'=>'images/label.png','type'=>'feed','auxcounter'=>0,'error'=>'','updated'=>'','fg_color'=>'','bg_color'=>'',],],],['name'=>'Politics','id'=>'CAT:3','bare_id'=>3,'parent_id'=>null,'type'=>'category','auxcounter'=>0,'unread'=>0,'child_unread'=>0,'checkbox'=>false,'param'=>'(3 feeds)','items'=>[['name'=>'Local','id'=>'CAT:5','bare_id'=>5,'parent_id'=>3,'type'=>'category','auxcounter'=>0,'unread'=>0,'child_unread'=>0,'checkbox'=>false,'param'=>'(1 feed)','items'=>[['name'=>'Toronto Star','id'=>'FEED:2','bare_id'=>2,'icon'=>'feed-icons/2.ico','error'=>'oops','param'=>'2011-11-11T11:11:11Z','unread'=>0,'auxcounter'=>0,'checkbox'=>false,],],],['name'=>'National','id'=>'CAT:6','bare_id'=>6,'parent_id'=>3,'type'=>'category','auxcounter'=>0,'unread'=>0,'child_unread'=>0,'checkbox'=>false,'param'=>'(2 feeds)','items'=>[['name'=>'CBC News','id'=>'FEED:4','bare_id'=>4,'icon'=>'feed-icons/4.ico','error'=>'','param'=>'2017-10-09T15:58:34Z','unread'=>0,'auxcounter'=>0,'checkbox'=>false,],['name'=>'Ottawa Citizen','id'=>'FEED:5','bare_id'=>5,'icon'=>false,'error'=>'','param'=>'2017-07-07T17:07:17Z','unread'=>0,'auxcounter'=>0,'checkbox'=>false,],],],],],['name'=>'Science','id'=>'CAT:1','bare_id'=>1,'parent_id'=>null,'type'=>'category','auxcounter'=>0,'unread'=>0,'child_unread'=>0,'checkbox'=>false,'param'=>'(2 feeds)','items'=>[['name'=>'Rocketry','id'=>'CAT:2','bare_id'=>2,'parent_id'=>1,'type'=>'category','auxcounter'=>0,'unread'=>0,'child_unread'=>0,'checkbox'=>false,'param'=>'(1 feed)','items'=>[['name'=>'NASA JPL','id'=>'FEED:1','bare_id'=>1,'icon'=>false,'error'=>'','param'=>'2017-09-15T22:54:16Z','unread'=>0,'auxcounter'=>0,'checkbox'=>false,],],],['name'=>'Ars Technica','id'=>'FEED:3','bare_id'=>3,'icon'=>'feed-icons/3.ico','error'=>'argh','param'=>'2016-05-23T06:40:02Z','unread'=>0,'auxcounter'=>0,'checkbox'=>false,],],],['name'=>'Uncategorized','id'=>'CAT:0','bare_id'=>0,'type'=>'category','auxcounter'=>0,'unread'=>0,'child_unread'=>0,'checkbox'=>false,'parent_id'=>null,'param'=>'(1 feed)','items'=>[['name'=>'Eurogamer','id'=>'FEED:6','bare_id'=>6,'icon'=>'feed-icons/6.ico','error'=>'','param'=>'2010-02-12T20:08:47Z','unread'=>0,'auxcounter'=>0,'checkbox'=>false,],],],],],]; $exp = ['categories' => ['identifier' => 'id','label' => 'name','items' => [['name' => 'Special','id' => 'CAT:-1','bare_id' => -1,'type' => 'category','unread' => 0,'items' => [['name' => 'All articles','id' => 'FEED:-4','bare_id' => -4,'icon' => 'images/folder.png','unread' => 35,'type' => 'feed','auxcounter' => 0,'error' => '','updated' => ''],['name' => 'Fresh articles','id' => 'FEED:-3','bare_id' => -3,'icon' => 'images/fresh.png','unread' => 7,'type' => 'feed','auxcounter' => 0,'error' => '','updated' => ''],['name' => 'Starred articles','id' => 'FEED:-1','bare_id' => -1,'icon' => 'images/star.png','unread' => 4,'type' => 'feed','auxcounter' => 0,'error' => '','updated' => ''],['name' => 'Published articles','id' => 'FEED:-2','bare_id' => -2,'icon' => 'images/feed.png','unread' => 0,'type' => 'feed','auxcounter' => 0,'error' => '','updated' => ''],['name' => 'Archived articles','id' => 'FEED:0','bare_id' => 0,'icon' => 'images/archive.png','unread' => 0,'type' => 'feed','auxcounter' => 0,'error' => '','updated' => ''],['name' => 'Recently read','id' => 'FEED:-6','bare_id' => -6,'icon' => 'images/time.png','unread' => 0,'type' => 'feed','auxcounter' => 0,'error' => '','updated' => '']]],['name' => 'Labels','id' => 'CAT:-2','bare_id' => -2,'type' => 'category','unread' => 6,'items' => [['name' => 'Fascinating','id' => 'FEED:-1027','bare_id' => -1027,'unread' => 0,'icon' => 'images/label.png','type' => 'feed','auxcounter' => 0,'error' => '','updated' => '','fg_color' => '','bg_color' => ''],['name' => 'Interesting','id' => 'FEED:-1029','bare_id' => -1029,'unread' => 0,'icon' => 'images/label.png','type' => 'feed','auxcounter' => 0,'error' => '','updated' => '','fg_color' => '','bg_color' => ''],['name' => 'Logical','id' => 'FEED:-1025','bare_id' => -1025,'unread' => 0,'icon' => 'images/label.png','type' => 'feed','auxcounter' => 0,'error' => '','updated' => '','fg_color' => '','bg_color' => '']]],['name' => 'Politics','id' => 'CAT:3','bare_id' => 3,'parent_id' => null,'type' => 'category','auxcounter' => 0,'unread' => 0,'child_unread' => 0,'checkbox' => false,'param' => '(3 feeds)','items' => [['name' => 'Local','id' => 'CAT:5','bare_id' => 5,'parent_id' => 3,'type' => 'category','auxcounter' => 0,'unread' => 0,'child_unread' => 0,'checkbox' => false,'param' => '(1 feed)','items' => [['name' => 'Toronto Star','id' => 'FEED:2','bare_id' => 2,'icon' => 'feed-icons/2.ico','error' => 'oops','param' => '2011-11-11T11:11:11Z','unread' => 0,'auxcounter' => 0,'checkbox' => false]]],['name' => 'National','id' => 'CAT:6','bare_id' => 6,'parent_id' => 3,'type' => 'category','auxcounter' => 0,'unread' => 0,'child_unread' => 0,'checkbox' => false,'param' => '(2 feeds)','items' => [['name' => 'CBC News','id' => 'FEED:4','bare_id' => 4,'icon' => 'feed-icons/4.ico','error' => '','param' => '2017-10-09T15:58:34Z','unread' => 0,'auxcounter' => 0,'checkbox' => false],['name' => 'Ottawa Citizen','id' => 'FEED:5','bare_id' => 5,'icon' => false,'error' => '','param' => '2017-07-07T17:07:17Z','unread' => 0,'auxcounter' => 0,'checkbox' => false]]]]],['name' => 'Science','id' => 'CAT:1','bare_id' => 1,'parent_id' => null,'type' => 'category','auxcounter' => 0,'unread' => 0,'child_unread' => 0,'checkbox' => false,'param' => '(2 feeds)','items' => [['name' => 'Rocketry','id' => 'CAT:2','bare_id' => 2,'parent_id' => 1,'type' => 'category','auxcounter' => 0,'unread' => 0,'child_unread' => 0,'checkbox' => false,'param' => '(1 feed)','items' => [['name' => 'NASA JPL','id' => 'FEED:1','bare_id' => 1,'icon' => false,'error' => '','param' => '2017-09-15T22:54:16Z','unread' => 0,'auxcounter' => 0,'checkbox' => false]]],['name' => 'Ars Technica','id' => 'FEED:3','bare_id' => 3,'icon' => 'feed-icons/3.ico','error' => 'argh','param' => '2016-05-23T06:40:02Z','unread' => 0,'auxcounter' => 0,'checkbox' => false]]],['name' => 'Uncategorized','id' => 'CAT:0','bare_id' => 0,'type' => 'category','auxcounter' => 0,'unread' => 0,'child_unread' => 0,'checkbox' => false,'parent_id' => null,'param' => '(1 feed)','items' => [['name' => 'Eurogamer','id' => 'FEED:6','bare_id' => 6,'icon' => 'feed-icons/6.ico','error' => '','param' => '2010-02-12T20:08:47Z','unread' => 0,'auxcounter' => 0,'checkbox' => false]]]]]];
$this->assertMessage($this->respGood($exp), $this->req($in[1])); $this->assertMessage($this->respGood($exp), $this->req($in[1]));
} }
@ -1507,7 +1506,7 @@ LONG_STRING;
}); });
} }
protected function reduceFolders(int $id = null) : int { protected function reduceFolders(int $id = null): int {
$out = 0; $out = 0;
foreach ($this->filterFolders($id) as $f) { foreach ($this->filterFolders($id) as $f) {
$out += $this->reduceFolders($f['id']); $out += $this->reduceFolders($f['id']);

View file

@ -11,7 +11,6 @@ use JKingWeb\Arsse\User;
use JKingWeb\Arsse\Database; use JKingWeb\Arsse\Database;
use JKingWeb\Arsse\REST\TinyTinyRSS\Icon; use JKingWeb\Arsse\REST\TinyTinyRSS\Icon;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Laminas\Diactoros\ServerRequest;
use Laminas\Diactoros\Response\EmptyResponse as Response; use Laminas\Diactoros\Response\EmptyResponse as Response;
/** @covers \JKingWeb\Arsse\REST\TinyTinyRSS\Icon<extended> */ /** @covers \JKingWeb\Arsse\REST\TinyTinyRSS\Icon<extended> */

View file

@ -7,7 +7,6 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Service; namespace JKingWeb\Arsse\TestCase\Service;
use JKingWeb\Arsse\Arsse; use JKingWeb\Arsse\Arsse;
use JKingWeb\Arsse\Database;
use JKingWeb\Arsse\Service\Driver as DriverInterface; use JKingWeb\Arsse\Service\Driver as DriverInterface;
use JKingWeb\Arsse\Service\Subprocess\Driver; use JKingWeb\Arsse\Service\Subprocess\Driver;

View file

@ -11,7 +11,6 @@ use JKingWeb\Arsse\Conf;
use JKingWeb\Arsse\Lang; use JKingWeb\Arsse\Lang;
use JKingWeb\Arsse\User; use JKingWeb\Arsse\User;
use JKingWeb\Arsse\Database; use JKingWeb\Arsse\Database;
use JKingWeb\Arsse\Service;
/** @covers \JKingWeb\Arsse\Arsse */ /** @covers \JKingWeb\Arsse\Arsse */
class TestArsse extends \JKingWeb\Arsse\Test\AbstractTest { class TestArsse extends \JKingWeb\Arsse\Test\AbstractTest {

View file

@ -14,7 +14,7 @@ if (
} else { } else {
return [ return [
'code' => 304, 'code' => 304,
'lastMod' => random_int(0, 2^31), 'lastMod' => random_int(0, 2 ^ 31),
'fields' => [ 'fields' => [
"ETag: ".bin2hex(random_bytes(8)), "ETag: ".bin2hex(random_bytes(8)),
], ],

View file

@ -1,6 +1,6 @@
<?php return [ <?php return [
'code' => 304, 'code' => 304,
'lastMod' => random_int(0, 2^31), 'lastMod' => random_int(0, 2 ^ 31),
'fields' => [ 'fields' => [
"ETag: ".bin2hex(random_bytes(8)), "ETag: ".bin2hex(random_bytes(8)),
], ],

View file

@ -3,5 +3,5 @@
'cache' => false, 'cache' => false,
'fields' => [ 'fields' => [
'Location: http://localhost:'.$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI']."0", 'Location: http://localhost:'.$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI']."0",
] ],
]; ];

View file

@ -109,7 +109,7 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
$req = $req->withAttribute("authenticationFailed", true); $req = $req->withAttribute("authenticationFailed", true);
} }
} }
if (strlen($type) &&strlen($body ?? "")) { if (strlen($type) && strlen($body ?? "")) {
$req = $req->withHeader("Content-Type", $type); $req = $req->withHeader("Content-Type", $type);
} }
foreach ($headers as $key => $value) { foreach ($headers as $key => $value) {
@ -135,8 +135,8 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
$this->expectException(get_class($msg)); $this->expectException(get_class($msg));
$this->expectExceptionCode($msg->getCode()); $this->expectExceptionCode($msg->getCode());
} else { } else {
$class = \JKingWeb\Arsse\NS_BASE . ($prefix !== "" ? str_replace("/", "\\", $prefix) . "\\" : "") . $type; $class = \JKingWeb\Arsse\NS_BASE.($prefix !== "" ? str_replace("/", "\\", $prefix)."\\" : "").$type;
$msgID = ($prefix !== "" ? $prefix . "/" : "") . $type. ".$msg"; $msgID = ($prefix !== "" ? $prefix."/" : "").$type.".$msg";
if (array_key_exists($msgID, Exception::CODES)) { if (array_key_exists($msgID, Exception::CODES)) {
$code = Exception::CODES[$msgID]; $code = Exception::CODES[$msgID];
} else { } else {
@ -260,7 +260,7 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
break; break;
} }
} }
if ($row===$test) { if ($row === $test) {
$data[$index] = $test; $data[$index] = $test;
break; break;
} }

View file

@ -7,7 +7,6 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\Test\DatabaseDrivers; namespace JKingWeb\Arsse\Test\DatabaseDrivers;
use JKingWeb\Arsse\Arsse; use JKingWeb\Arsse\Arsse;
use JKingWeb\Arsse\Db\Driver;
trait MySQLPDO { trait MySQLPDO {
protected static $implementation = "PDO MySQL"; protected static $implementation = "PDO MySQL";

View file

@ -29,7 +29,6 @@ which include the following data:
*/ */
ignore_user_abort(false); ignore_user_abort(false);
ob_start(); ob_start();
$defaults = [ // default values for response $defaults = [ // default values for response