mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-31 21:12:41 +00:00
Fix strict comparison failures
This commit is contained in:
parent
ed285ee28b
commit
64ca5f1be0
3 changed files with 16 additions and 7 deletions
|
@ -947,7 +947,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
throw new Exception("INCORRECT_USAGE");
|
throw new Exception("INCORRECT_USAGE");
|
||||||
}
|
}
|
||||||
try {
|
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) {
|
} catch (ExceptionInput $e) {
|
||||||
throw new Exception("FEED_NOT_FOUND");
|
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
|
// this function doesn't complain about invalid article IDs
|
||||||
$article = V::id($data['article_id']) ? $data['article_id'] : 0;
|
$article = V::id($data['article_id']) ? $data['article_id'] : 0;
|
||||||
try {
|
try {
|
||||||
$list = $article ? Arsse::$db->articleLabelsGet(Arsse::$user->id, $article) : [];
|
$list = $article ? Arsse::$db->articleLabelsGet(Arsse::$user->id, (int) $article) : [];
|
||||||
} catch (ExceptionInput $e) {
|
} catch (ExceptionInput $e) {
|
||||||
$list = [];
|
$list = [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,6 @@ declare(strict_types=1);
|
||||||
namespace JKingWeb\Arsse\User;
|
namespace JKingWeb\Arsse\User;
|
||||||
|
|
||||||
interface Driver {
|
interface Driver {
|
||||||
public function __construct();
|
|
||||||
|
|
||||||
/** Returns a human-friendly name for the driver (for display in installer, for example) */
|
/** Returns a human-friendly name for the driver (for display in installer, for example) */
|
||||||
public static function driverName(): string;
|
public static function driverName(): string;
|
||||||
|
|
||||||
|
|
|
@ -226,7 +226,7 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
|
||||||
}
|
}
|
||||||
foreach ($value as $k => $v) {
|
foreach ($value as $k => $v) {
|
||||||
if (is_array($v)) {
|
if (is_array($v)) {
|
||||||
$value[$k] = $this->v($v);
|
$value[$k] = $this->stringify($v);
|
||||||
} elseif (is_int($v) || is_float($v)) {
|
} elseif (is_int($v) || is_float($v)) {
|
||||||
$value[$k] = (string) $v;
|
$value[$k] = (string) $v;
|
||||||
}
|
}
|
||||||
|
@ -324,6 +324,10 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function assertResult(array $expected, Result $data): void {
|
public function assertResult(array $expected, Result $data): void {
|
||||||
|
// stringify our expectations if necessary
|
||||||
|
if (static::$stringOutput ?? false) {
|
||||||
|
$expected = $this->stringify($expected);
|
||||||
|
}
|
||||||
$data = $data->getAll();
|
$data = $data->getAll();
|
||||||
$this->assertCount(sizeof($expected), $data, "Number of result rows (".sizeof($data).") differs from number of expected rows (".sizeof($expected).")");
|
$this->assertCount(sizeof($expected), $data, "Number of result rows (".sizeof($data).") differs from number of expected rows (".sizeof($expected).")");
|
||||||
if (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)
|
// filter the result set to contain just the desired keys (we don't care if the result has extra keys)
|
||||||
$rows = [];
|
$rows = [];
|
||||||
|
$keys = array_keys($keys);
|
||||||
foreach ($data as $row) {
|
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
|
// compare the result set to the expectations
|
||||||
foreach ($rows as $row) {
|
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);
|
$found = array_search($row, $expected);
|
||||||
unset($expected[$found]);
|
unset($expected[$found]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue