diff --git a/lib/REST/TinyTinyRSS/API.php b/lib/REST/TinyTinyRSS/API.php index 11b983d..3732623 100644 --- a/lib/REST/TinyTinyRSS/API.php +++ b/lib/REST/TinyTinyRSS/API.php @@ -947,7 +947,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler { throw new Exception("INCORRECT_USAGE"); } try { - Arsse::$db->feedUpdate(Arsse::$db->subscriptionPropertiesGet(Arsse::$user->id, $data['feed_id'])['feed']); + Arsse::$db->feedUpdate((int) Arsse::$db->subscriptionPropertiesGet(Arsse::$user->id, $data['feed_id'])['feed']); } catch (ExceptionInput $e) { throw new Exception("FEED_NOT_FOUND"); } @@ -973,7 +973,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler { // this function doesn't complain about invalid article IDs $article = V::id($data['article_id']) ? $data['article_id'] : 0; try { - $list = $article ? Arsse::$db->articleLabelsGet(Arsse::$user->id, $article) : []; + $list = $article ? Arsse::$db->articleLabelsGet(Arsse::$user->id, (int) $article) : []; } catch (ExceptionInput $e) { $list = []; } diff --git a/lib/User/Driver.php b/lib/User/Driver.php index 8766879..fcf2010 100644 --- a/lib/User/Driver.php +++ b/lib/User/Driver.php @@ -7,8 +7,6 @@ declare(strict_types=1); namespace JKingWeb\Arsse\User; interface Driver { - public function __construct(); - /** Returns a human-friendly name for the driver (for display in installer, for example) */ public static function driverName(): string; diff --git a/tests/lib/AbstractTest.php b/tests/lib/AbstractTest.php index 5d9eb5e..3ed6fc4 100644 --- a/tests/lib/AbstractTest.php +++ b/tests/lib/AbstractTest.php @@ -226,7 +226,7 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase { } foreach ($value as $k => $v) { if (is_array($v)) { - $value[$k] = $this->v($v); + $value[$k] = $this->stringify($v); } elseif (is_int($v) || is_float($v)) { $value[$k] = (string) $v; } @@ -324,6 +324,10 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase { } public function assertResult(array $expected, Result $data): void { + // stringify our expectations if necessary + if (static::$stringOutput ?? false) { + $expected = $this->stringify($expected); + } $data = $data->getAll(); $this->assertCount(sizeof($expected), $data, "Number of result rows (".sizeof($data).") differs from number of expected rows (".sizeof($expected).")"); if (sizeof($expected)) { @@ -337,12 +341,19 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase { } // filter the result set to contain just the desired keys (we don't care if the result has extra keys) $rows = []; + $keys = array_keys($keys); foreach ($data as $row) { - $rows[] = array_intersect_key($row, $keys); + $r = []; + foreach ($keys as $k) { + if (array_key_exists($k, $row)) { + $r[$k] = $row[$k]; + } + } + $rows[] = $r; } // compare the result set to the expectations foreach ($rows as $row) { - $this->assertEquals($row, $expected, "Result set contains unexpected record."); + $this->assertContains($row, $expected, "Result set contains unexpected record.\n".var_export($expected, true)); $found = array_search($row, $expected); unset($expected[$found]); }