1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2025-01-03 14:32:40 +00:00

Upgrade to PHPUnit 11

Deprecated annotations still need to be addressed
This commit is contained in:
J. King 2024-12-27 19:58:07 -05:00
parent 835f6fb998
commit ba42b7b0c1
43 changed files with 862 additions and 886 deletions

View file

@ -129,24 +129,29 @@ class RoboFile extends \Robo\Tasks {
protected function runTests(string $executor, string $set, array $args): Result {
switch ($set) {
case "typical":
$set = ["--exclude-group", "optional"];
$exc = ["optional"];
break;
case "quick":
$set = ["--exclude-group", "optional,slow"];
$exc = ["optional", "slow"];
break;
case "coverage":
$set = ["--exclude-group", "optional,coverageOptional"];
$exc = ["optional", "coverageOptional"];
break;
case "full":
$set = [];
$exc = [];
break;
default:
throw new \Exception;
}
$extra = ["--display-phpunit-deprecations"];
foreach ($exc as $group) {
$extra[] = "--exclude-group";
$extra[] = $group;
}
$execpath = norm(BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit");
$confpath = realpath(BASE_TEST."phpunit.dist.xml") ?: norm(BASE_TEST."phpunit.xml");
$this->taskServer(8000)->host("localhost")->dir(BASE_TEST."docroot")->rawArg("-n")->arg(BASE_TEST."server.php")->rawArg($this->blackhole())->background()->run();
return $this->taskExec($executor)->option("-d", "zend.assertions=1")->arg($execpath)->option("-c", $confpath)->args(array_merge($set, $args))->run();
return $this->taskExec($executor)->option("-d", "zend.assertions=1")->arg($execpath)->option("-c", $confpath)->args(array_merge($extra, $args))->run();
}
/** Returns a Git version string for a given Git tree-ish ID

View file

@ -53,7 +53,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify($this->cli, \Phake::never())->loadConf();
}
public function provideHelpText(): iterable {
public static function provideHelpText(): iterable {
return [
["arsse.php --help", "arsse.php"],
["arsse --help", "arsse"],
@ -125,7 +125,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify(Arsse::$db)->feedUpdate(\Phake::anyParameters());
}
public function provideFeedUpdates(): iterable {
public static function provideFeedUpdates(): iterable {
return [
["arsse.php feed refresh 1", 0, ""],
["arsse.php feed refresh 2", 10502, ""],
@ -144,7 +144,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify($conf)->exportFile($file, true);
}
public function provideDefaultConfigurationSaves(): iterable {
public static function provideDefaultConfigurationSaves(): iterable {
return [
["arsse.php conf save-defaults", 0, "php://output"],
["arsse.php conf save-defaults -", 0, "php://output"],
@ -160,7 +160,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertConsole($cmd, $exitStatus, $output);
}
public function provideUserList(): iterable {
public static function provideUserList(): iterable {
$list = ["john.doe@example.com", "jane.doe@example.com"];
$str = implode(PHP_EOL, $list);
return [
@ -182,7 +182,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertConsole($cmd, $exitStatus, $output);
}
public function provideUserAdditions(): iterable {
public static function provideUserAdditions(): iterable {
return [
["arsse.php user add john.doe@example.com", 10403, ""],
["arsse.php user add jane.doe@example.com", 0, "random password"],
@ -213,7 +213,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertConsole($cmd, $exitStatus, $output);
}
public function provideUserAuthentication(): iterable {
public static function provideUserAuthentication(): iterable {
$l = new \JKingWeb\Arsse\Lang;
$success = $l("CLI.Auth.Success");
$failure = $l("CLI.Auth.Failure");
@ -237,7 +237,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertConsole($cmd, $exitStatus, $output);
}
public function provideUserRemovals(): iterable {
public static function provideUserRemovals(): iterable {
return [
["arsse.php user remove john.doe@example.com", 0, ""],
["arsse.php user remove jane.doe@example.com", 10402, ""],
@ -262,7 +262,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertConsole($cmd, $exitStatus, $output);
}
public function provideUserPasswordChanges(): iterable {
public static function provideUserPasswordChanges(): iterable {
return [
["arsse.php user set-pass john.doe@example.com", 0, "random password"],
["arsse.php user set-pass john.doe@example.com superman", 0, ""],
@ -291,7 +291,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertConsole($cmd, $exitStatus, $output);
}
public function provideUserPasswordClearings(): iterable {
public static function provideUserPasswordClearings(): iterable {
return [
["arsse.php user unset-pass john.doe@example.com", 0, ""],
["arsse.php user unset-pass jane.doe@example.com", 10402, ""],
@ -312,7 +312,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify($opml)->exportFile($file, $user, $flat);
}
public function provideOpmlExports(): iterable {
public static function provideOpmlExports(): iterable {
return [
["arsse.php export john.doe@example.com", 0, "php://output", "john.doe@example.com", false],
["arsse.php export john.doe@example.com -", 0, "php://output", "john.doe@example.com", false],
@ -353,7 +353,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify($opml)->importFile($file, $user, $flat, $replace);
}
public function provideOpmlImports(): iterable {
public static function provideOpmlImports(): iterable {
return [
["arsse.php import john.doe@example.com", 0, "php://input", "john.doe@example.com", false, false],
["arsse.php import john.doe@example.com -", 0, "php://input", "john.doe@example.com", false, false],
@ -433,7 +433,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify(Arsse::$user)->propertiesSet($user, $in);
}
public function provideMetadataChanges(): iterable {
public static function provideMetadataChanges(): iterable {
return [
["arsse.php user set john admin true", "john", ['admin' => "true"], ['admin' => "true"], 0],
["arsse.php user set john bogus 1", "john", ['bogus' => "1"], [], 1],

View file

@ -69,7 +69,7 @@ abstract class AbstractTest extends \JKingWeb\Arsse\Test\AbstractTest {
public function setUp(): void {
// get the name of the test's test series
$this->series = $this->findTraitofTest($this->getName(false));
$this->series = $this->findTraitofTest($this->name());
static::clearData();
static::setConf();
if (strlen(static::$failureReason)) {
@ -90,7 +90,7 @@ abstract class AbstractTest extends \JKingWeb\Arsse\Test\AbstractTest {
public function tearDown(): void {
// call the series-specific teardown method
$this->series = $this->findTraitofTest($this->getName(false));
$this->series = $this->findTraitofTest($this->name());
$tearDown = "tearDown".$this->series;
$this->$tearDown();
// clean up

View file

@ -443,7 +443,7 @@ trait SeriesArticle {
$this->assertEquals($exp, $ids);
}
public function provideContextMatches(): iterable {
public static function provideContextMatches(): iterable {
$setSize = (new \ReflectionClassConstant(Database::class, "LIMIT_SET_SIZE"))->getValue();
return [
'Blank context' => [new Context, [1,2,3,4,5,6,7,8,19,20]],
@ -661,7 +661,7 @@ trait SeriesArticle {
$this->assertSame($exp, $act);
}
public function provideOrderedLists(): iterable {
public static function provideOrderedLists(): iterable {
return [
[["id"], [1,2,3,4,5,6,7,8,19,20]],
[["id asc"], [1,2,3,4,5,6,7,8,19,20]],
@ -1400,7 +1400,7 @@ trait SeriesArticle {
Arsse::$db->articleList($this->user, (new Context)->$option([]));
}
public function provideArrayContextOptions(): iterable {
public static function provideArrayContextOptions(): iterable {
foreach ([
"articles", "editions",
"subscriptions", "foldersShallow", "folders",

View file

@ -217,7 +217,7 @@ trait SeriesFeed {
$this->assertSame($exp, Arsse::$db->feedRulesGet($in));
}
public function provideFilterRules(): iterable {
public static function provideFilterRules(): iterable {
return [
[1, ['jane.doe@example.com' => ['keep' => "`^(?i)[a-z]+`u", 'block' => "`3|6`u"], 'john.doe@example.com' => ['keep' => "", 'block' => "`^Sport$`u"]]],
[2, []],

View file

@ -539,7 +539,7 @@ trait SeriesSubscription {
Arsse::$db->subscriptionPropertiesSet($this->user, 1, $data);
}
public function provideInvalidSubscriptionProperties(): iterable {
public static function provideInvalidSubscriptionProperties(): iterable {
return [
'Empty title' => [['title' => ""], "missing"],
'Whitespace title' => [['title' => " "], "whitespace"],

View file

@ -135,7 +135,7 @@ trait SeriesUser {
$this->assertSame($exp, Arsse::$db->userPropertiesGet($user, $includeLarge));
}
public function provideMetadata(): iterable {
public static function provideMetadata(): iterable {
return [
["admin@example.net", true, ['num' => 1, 'admin' => 1, 'lang' => "en", 'sort_asc' => "0", 'tz' => "America/Toronto"]],
["jane.doe@example.com", true, ['num' => 2, 'admin' => 0, 'lang' => "fr", 'sort_asc' => "1", 'tz' => "Asia/Kuala_Lumpur"]],

View file

@ -45,7 +45,7 @@ class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame($exp, $this->invoke("generateIn", $inV, $inT));
}
public function provideInClauses(): iterable {
public static function provideInClauses(): iterable {
$l = (new \ReflectionClassConstant(Database::class, "LIMIT_SET_SIZE"))->getValue() + 1;
$strings = array_fill(0, $l, "");
$ints = range(1, $l);
@ -83,7 +83,7 @@ class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame($exp, $this->invoke("generateSearch", $inV, $inC, $inAny));
}
public function provideSearchClauses(): iterable {
public static function provideSearchClauses(): iterable {
$setSize = (new \ReflectionClassConstant(Database::class, "LIMIT_SET_SIZE"))->getValue();
$terms = array_fill(0, $setSize + 1, "a");
$clause = array_fill(0, $setSize + 1, "test like '%a%' escape '^'");

View file

@ -14,7 +14,7 @@ abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest {
protected $statementClass;
abstract protected function makeStatement(string $q, array $types = []): array;
abstract protected function decorateTypeSyntax(string $value, string $type): string;
abstract protected static function decorateTypeSyntax(string $value, string $type): string;
public static function setUpBeforeClass(): void {
// establish a clean baseline
@ -121,7 +121,7 @@ abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest {
$s->runArray(['ook', 'eek']);
}
public function provideBindings(): iterable {
public static function provideBindings(): iterable {
$dateMutable = new \DateTime("Noon Today", new \DateTimezone("America/Toronto"));
$dateImmutable = new \DateTimeImmutable("Noon Today", new \DateTimezone("America/Toronto"));
$dateUTC = new \DateTime("@".$dateMutable->getTimestamp(), new \DateTimezone("UTC"));
@ -259,12 +259,12 @@ abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest {
];
foreach ($tests as $index => [$value, $type, $exp]) {
$t = preg_replace("<^strict >", "", $type);
$exp = ($exp === "null") ? $exp : $this->decorateTypeSyntax($exp, $t);
$exp = ($exp === "null") ? $exp : static::decorateTypeSyntax($exp, $t);
yield $index => [$value, $type, $exp];
}
}
public function provideBinaryBindings(): iterable {
public static function provideBinaryBindings(): iterable {
$dateMutable = new \DateTime("Noon Today", new \DateTimezone("America/Toronto"));
$dateImmutable = new \DateTimeImmutable("Noon Today", new \DateTimezone("America/Toronto"));
$dateUTC = new \DateTime("@".$dateMutable->getTimestamp(), new \DateTimezone("UTC"));
@ -308,7 +308,7 @@ abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest {
];
foreach ($tests as $index => [$value, $type, $exp]) {
$t = preg_replace("<^strict >", "", $type);
$exp = ($exp === "null") ? $exp : $this->decorateTypeSyntax($exp, $t);
$exp = ($exp === "null") ? $exp : static::decorateTypeSyntax($exp, $t);
yield $index => [$value, $type, $exp];
}
}

View file

@ -19,7 +19,7 @@ class TestStatement extends \JKingWeb\Arsse\TestCase\Db\BaseStatement {
return [static::$interface, $q, $types];
}
protected function decorateTypeSyntax(string $value, string $type): string {
protected static function decorateTypeSyntax(string $value, string $type): string {
switch ($type) {
case "float":
return (substr($value, -2) === ".0") ? "'".substr($value, 0, strlen($value) - 2)."'" : "'$value'";

View file

@ -20,7 +20,7 @@ class TestStatement extends \JKingWeb\Arsse\TestCase\Db\BaseStatement {
return [static::$interface, $q, $types];
}
protected function decorateTypeSyntax(string $value, string $type): string {
protected static function decorateTypeSyntax(string $value, string $type): string {
switch ($type) {
case "float":
return (substr($value, -2) === ".0") ? "'".substr($value, 0, strlen($value) - 2)."'" : "'$value'";

View file

@ -36,7 +36,7 @@ class TestCreation extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideConnectionStrings(): iterable {
public static function provideConnectionStrings(): iterable {
return [
[false, "arsse", "secret", "arsse", "", 5432, "", "dbname='arsse' password='secret' user='arsse'"],
[false, "arsse", "p word", "arsse", "", 5432, "", "dbname='arsse' password='p word' user='arsse'"],

View file

@ -19,7 +19,7 @@ class TestStatement extends \JKingWeb\Arsse\TestCase\Db\BaseStatement {
return [static::$interface, $q, $types];
}
protected function decorateTypeSyntax(string $value, string $type): string {
protected static function decorateTypeSyntax(string $value, string $type): string {
switch ($type) {
case "float":
return (substr($value, -2) === ".0") ? "'".substr($value, 0, strlen($value) - 2)."'" : "'$value'";

View file

@ -36,7 +36,7 @@ class TestCreation extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideConnectionStrings(): iterable {
public static function provideConnectionStrings(): iterable {
return [
[false, "arsse", "secret", "arsse", "", 5432, "", "dbname='arsse' password='secret' user='arsse'"],
[false, "arsse", "p word", "arsse", "", 5432, "", "dbname='arsse' password='p word' user='arsse'"],

View file

@ -19,7 +19,7 @@ class TestStatement extends \JKingWeb\Arsse\TestCase\Db\BaseStatement {
return [static::$interface, $q, $types];
}
protected function decorateTypeSyntax(string $value, string $type): string {
protected static function decorateTypeSyntax(string $value, string $type): string {
switch ($type) {
case "float":
return (substr($value, -2) === ".0") ? "'".substr($value, 0, strlen($value) - 2)."'" : "'$value'";

View file

@ -25,7 +25,7 @@ class TestStatement extends \JKingWeb\Arsse\TestCase\Db\BaseStatement {
return [static::$interface, $q, $types];
}
protected function decorateTypeSyntax(string $value, string $type): string {
protected static function decorateTypeSyntax(string $value, string $type): string {
return $value;
}
}

View file

@ -18,7 +18,7 @@ class TestStatement extends \JKingWeb\Arsse\TestCase\Db\BaseStatement {
return [static::$interface, $q, $types];
}
protected function decorateTypeSyntax(string $value, string $type): string {
protected static function decorateTypeSyntax(string $value, string $type): string {
if ($type === "float") {
return (substr($value, -2) === ".0") ? "'".substr($value, 0, strlen($value) - 2)."'" : "'$value'";
} else {

View file

@ -24,7 +24,7 @@ class TestException extends \JKingWeb\Arsse\Test\AbstractTest {
throw new FeedException("", ['url' => "https://example.com/"], $e);
}
public function provideCurlErrors() {
public static function provideCurlErrors() {
return [
'CURLE_UNSUPPORTED_PROTOCOL' => [1, "invalidUrl"],
'CURLE_FAILED_INIT' => [2, "internalError"],
@ -123,7 +123,7 @@ class TestException extends \JKingWeb\Arsse\Test\AbstractTest {
throw new FeedException("", ['url' => "https://example.com/"], $e);
}
public function provideHTTPErrors() {
public static function provideHTTPErrors() {
$specials = [
401 => "unauthorized",
403 => "forbidden",
@ -149,7 +149,7 @@ class TestException extends \JKingWeb\Arsse\Test\AbstractTest {
throw new FeedException("", ['url' => "https://example.com/"], $e);
}
public function providePicoFeedException() {
public static function providePicoFeedException() {
return [
'Failed feed discovery' => [new \PicoFeed\Reader\SubscriptionNotFoundException(), "subscriptionNotFound"],
'Unsupported format' => [new \PicoFeed\Reader\UnsupportedFeedFormatException(), "unsupportedFeedFormat"],

View file

@ -234,7 +234,7 @@ class TestFeed extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame($e, $f->etag);
}
public function provide304ResponseURLs() {
public static function provide304ResponseURLs() {
return [
'Control' => ["Caching/304Conditional"],
'Random last-mod and ETag' => ["Caching/304Random"],
@ -292,7 +292,7 @@ class TestFeed extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertTime($exp, $f->nextFetch);
}
public function provide304Timestamps(): iterable {
public static function provide304Timestamps(): iterable {
return [
'less than half an hour 1' => ["now", "now + 15 minutes"],
'less than half an hour 2' => ["now - 29 minutes", "now + 15 minutes"],

View file

@ -61,7 +61,7 @@ class TestFile extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideFileExports(): iterable {
public static function provideFileExports(): iterable {
$createException = new Exception("fileUncreatable");
$writeException = new Exception("fileUnwritable");
return [
@ -99,7 +99,7 @@ class TestFile extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideFileImports(): iterable {
public static function provideFileImports(): iterable {
$missingException = new Exception("fileMissing");
$permissionException = new Exception("fileUnreadable");
return [

View file

@ -119,7 +119,7 @@ OPML_EXPORT_SERIALIZATION;
}
}
public function provideParserData(): iterable {
public static function provideParserData(): iterable {
return [
["BrokenXML.opml", false, new Exception("invalidSyntax")],
["BrokenOPML.1.opml", false, new Exception("invalidSemantics")],

View file

@ -58,7 +58,7 @@ class TestContext extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertFalse($c->$method(), "Context method did not return false after clearing");
}
public function provideContextOptions(): iterable {
public static function provideContextOptions(): iterable {
$tests = [
'limit' => [[10], 10],
'offset' => [[5], 5],

View file

@ -22,7 +22,7 @@ class TestHTTP extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame($exp, HTTP::matchType($msg, ...$types));
}
public function provideMediaTypes(): array {
public static function provideMediaTypes(): array {
return [
["application/json", ["application/json"], true],
["APPLICATION/JSON", ["application/json"], true],
@ -42,7 +42,7 @@ class TestHTTP extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertMessage($exp, $act);
}
public function provideTypedMessages(): iterable {
public static function provideTypedMessages(): iterable {
return [
["respEmpty", [422, ['Content-Length' => "0"]], new Response(422, ['Content-Length' => "0"])],
["respText", ["OOK"], new Response(200, ['Content-Type' => "text/plain; charset=UTF-8"], "OOK")],

View file

@ -35,7 +35,7 @@ class TestRule extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame($exp, Rule::apply($keepRule, $blockRule, $title, $categories));
}
public function provideApplications(): iterable {
public static function provideApplications(): iterable {
return [
["", "", "Title", ["Dummy", "Category"], true],
["^Title$", "", "Title", ["Dummy", "Category"], true],

View file

@ -16,7 +16,7 @@ class TestURL extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame($exp, URL::normalize($url, $user, $pass));
}
public function provideNormalizations(): iterable {
public static function provideNormalizations(): iterable {
return [
["http://example.com/", "http://example.com/"],
["HTTP://example.com/", "http://example.com/"],
@ -78,7 +78,7 @@ class TestURL extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame($exp, URL::queryAppend($url, $query));
}
public function provideQueries(): iterable {
public static function provideQueries(): iterable {
return [
["/", "ook=eek", "/?ook=eek"],
["/?", "ook=eek", "/?ook=eek"],
@ -94,7 +94,7 @@ class TestURL extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame($exp, URL::absolute($url));
}
public function provideAbsolutes(): array {
public static function provideAbsolutes(): array {
return [
[true, "http://example.com/"],
[true, "HTTP://example.com/"],

View file

@ -425,7 +425,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideSimpleNormalizationValues(): iterable {
public static function provideSimpleNormalizationValues(): iterable {
$types = [
"Mixed",
"Null",
@ -458,9 +458,9 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
/* Input value null bool int float string array interval */
[null, [null,true], [false,false], [0, false], [0.0, false], ["", false], [[], false], [null, false]],
["", [null,true], [false,true], [0, false], [0.0, false], ["", true], [[""], false], [null, false]],
[1, [null,true], [true, true], [1, true], [1.0, true], ["1", true], [[1], false], [$this->i("PT1S"), false]],
[PHP_INT_MAX, [null,true], [true, false], [PHP_INT_MAX, true], [(float) PHP_INT_MAX, true], [(string) PHP_INT_MAX, true], [[PHP_INT_MAX], false], [$this->i("P292471208677Y195DT15H30M7S"), false]],
[1.0, [null,true], [true, true], [1, true], [1.0, true], ["1", true], [[1.0], false], [$this->i("PT1S"), false]],
[1, [null,true], [true, true], [1, true], [1.0, true], ["1", true], [[1], false], [self::i("PT1S"), false]],
[PHP_INT_MAX, [null,true], [true, false], [PHP_INT_MAX, true], [(float) PHP_INT_MAX, true], [(string) PHP_INT_MAX, true], [[PHP_INT_MAX], false], [self::i("P292471208677Y195DT15H30M7S"), false]],
[1.0, [null,true], [true, true], [1, true], [1.0, true], ["1", true], [[1.0], false], [self::i("PT1S"), false]],
["1.0", [null,true], [true, true], [1, true], [1.0, true], ["1.0", true], [["1.0"], false], [null, false]],
["001.0", [null,true], [true, true], [1, true], [1.0, true], ["001.0", true], [["001.0"], false], [null, false]],
["1.0e2", [null,true], [true, false], [100, true], [100.0, true], ["1.0e2", true], [["1.0e2"], false], [null, false]],
@ -473,28 +473,28 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
["+1", [null,true], [true, true], [1, true], [1.0, true], ["+1", true], [["+1"], false], [null, false]],
["+001", [null,true], [true, true], [1, true], [1.0, true], ["+001", true], [["+001"], false], [null, false]],
["+1e2", [null,true], [true, false], [100, true], [100.0, true], ["+1e2", true], [["+1e2"], false], [null, false]],
[0, [null,true], [false,true], [0, true], [0.0, true], ["0", true], [[0], false], [$this->i("PT0S"), false]],
[0, [null,true], [false,true], [0, true], [0.0, true], ["0", true], [[0], false], [self::i("PT0S"), false]],
["0", [null,true], [false,true], [0, true], [0.0, true], ["0", true], [["0"], false], [null, false]],
["000", [null,true], [false,true], [0, true], [0.0, true], ["000", true], [["000"], false], [null, false]],
[0.0, [null,true], [false,true], [0, true], [0.0, true], ["0", true], [[0.0], false], [$this->i("PT0S"), false]],
[0.0, [null,true], [false,true], [0, true], [0.0, true], ["0", true], [[0.0], false], [self::i("PT0S"), false]],
["0.0", [null,true], [false,true], [0, true], [0.0, true], ["0.0", true], [["0.0"], false], [null, false]],
["000.000", [null,true], [false,true], [0, true], [0.0, true], ["000.000", true], [["000.000"], false], [null, false]],
["+0", [null,true], [false,true], [0, true], [0.0, true], ["+0", true], [["+0"], false], [null, false]],
["+000", [null,true], [false,true], [0, true], [0.0, true], ["+000", true], [["+000"], false], [null, false]],
["+0.0", [null,true], [false,true], [0, true], [0.0, true], ["+0.0", true], [["+0.0"], false], [null, false]],
["+000.000", [null,true], [false,true], [0, true], [0.0, true], ["+000.000", true], [["+000.000"], false], [null, false]],
[-1, [null,true], [true, false], [-1, true], [-1.0, true], ["-1", true], [[-1], false], [$this->i("PT1S"), false]],
[-1.0, [null,true], [true, false], [-1, true], [-1.0, true], ["-1", true], [[-1.0], false], [$this->i("PT1S"), false]],
[-1, [null,true], [true, false], [-1, true], [-1.0, true], ["-1", true], [[-1], false], [self::i("PT1S"), false]],
[-1.0, [null,true], [true, false], [-1, true], [-1.0, true], ["-1", true], [[-1.0], false], [self::i("PT1S"), false]],
["-1.0", [null,true], [true, false], [-1, true], [-1.0, true], ["-1.0", true], [["-1.0"], false], [null, false]],
["-001.0", [null,true], [true, false], [-1, true], [-1.0, true], ["-001.0", true], [["-001.0"], false], [null, false]],
["-1.0e2", [null,true], [true, false], [-100, true], [-100.0, true], ["-1.0e2", true], [["-1.0e2"], false], [null, false]],
["-1", [null,true], [true, false], [-1, true], [-1.0, true], ["-1", true], [["-1"], false], [null, false]],
["-001", [null,true], [true, false], [-1, true], [-1.0, true], ["-001", true], [["-001"], false], [null, false]],
["-1e2", [null,true], [true, false], [-100, true], [-100.0, true], ["-1e2", true], [["-1e2"], false], [null, false]],
[-0, [null,true], [false,true], [0, true], [0.0, true], ["0", true], [[-0], false], [$this->i("PT0S"), false]],
[-0, [null,true], [false,true], [0, true], [0.0, true], ["0", true], [[-0], false], [self::i("PT0S"), false]],
["-0", [null,true], [false,true], [0, true], [-0.0, true], ["-0", true], [["-0"], false], [null, false]],
["-000", [null,true], [false,true], [0, true], [-0.0, true], ["-000", true], [["-000"], false], [null, false]],
[-0.0, [null,true], [false,true], [0, true], [-0.0, true], ["-0", true], [[-0.0], false], [$this->i("PT0S"), false]],
[-0.0, [null,true], [false,true], [0, true], [-0.0, true], ["-0", true], [[-0.0], false], [self::i("PT0S"), false]],
["-0.0", [null,true], [false,true], [0, true], [-0.0, true], ["-0.0", true], [["-0.0"], false], [null, false]],
["-000.000", [null,true], [false,true], [0, true], [-0.0, true], ["-000.000", true], [["-000.000"], false], [null, false]],
[false, [null,true], [false,true], [0, false], [0.0, false], ["", false], [[false], false], [null, false]],
@ -518,25 +518,25 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[new StrClass("-1"), [null,true], [true, false], [-1, true], [-1.0, true], ["-1", true], [[new StrClass("-1")], false], [null, false]],
[new StrClass("Msg"), [null,true], [true, false], [0, false], [0.0, false], ["Msg", true], [[new StrClass("Msg")], false], [null, false]],
[new StrClass(" "), [null,true], [true, false], [0, false], [0.0, false], [" ", true], [[new StrClass(" ")], false], [null, false]],
[2.5, [null,true], [true, false], [2, false], [2.5, true], ["2.5", true], [[2.5], false], [$this->i("PT2S", 0.5), false]],
[0.5, [null,true], [true, false], [0, false], [0.5, true], ["0.5", true], [[0.5], false], [$this->i("PT0S", 0.5), false]],
[2.5, [null,true], [true, false], [2, false], [2.5, true], ["2.5", true], [[2.5], false], [self::i("PT2S", 0.5), false]],
[0.5, [null,true], [true, false], [0, false], [0.5, true], ["0.5", true], [[0.5], false], [self::i("PT0S", 0.5), false]],
["2.5", [null,true], [true, false], [2, false], [2.5, true], ["2.5", true], [["2.5"], false], [null, false]],
["0.5", [null,true], [true, false], [0, false], [0.5, true], ["0.5", true], [["0.5"], false], [null, false]],
[$this->d("2010-01-01T00:00:00", 0, 0), [null,true], [true, false], [1262304000, false], [1262304000.0, false], ["2010-01-01T00:00:00Z",true], [[$this->d("2010-01-01T00:00:00", 0, 0)],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, 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], [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]],
[self::d("2010-01-01T00:00:00", 0, 0), [null,true], [true, false], [1262304000, false], [1262304000.0, false], ["2010-01-01T00:00:00Z",true], [[self::d("2010-01-01T00:00:00", 0, 0)],false], [null, false]],
[self::d("2010-01-01T00:00:00", 0, 1), [null,true], [true, false], [1262304000, false], [1262304000.0, false], ["2010-01-01T00:00:00Z",true], [[self::d("2010-01-01T00:00:00", 0, 1)],false], [null, false]],
[self::d("2010-01-01T00:00:00", 1, 0), [null,true], [true, false], [1262322000, false], [1262322000.0, false], ["2010-01-01T05:00:00Z",true], [[self::d("2010-01-01T00:00:00", 1, 0)],false], [null, false]],
[self::d("2010-01-01T00:00:00", 1, 1), [null,true], [true, false], [1262322000, false], [1262322000.0, false], ["2010-01-01T05:00:00Z",true], [[self::d("2010-01-01T00:00:00", 1, 1)],false], [null, false]],
[1e14, [null,true], [true, false], [10 ** 14, true], [1e14, true], ["100000000000000", true], [[1e14], false], [self::i("P1157407407DT9H46M40S"), false]],
[1e-6, [null,true], [true, false], [0, false], [1e-6, true], ["0.000001", true], [[1e-6], false], [self::i("PT0S", 1e-6), 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]],
[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("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]],
[self::i("PT1H"), [null,true], [true, false], [60 * 60, false], [60.0 * 60.0, false], ["PT1H", true], [[self::i("PT1H")], false], [self::i("PT1H"), true]],
[self::i("P2DT1H"), [null,true], [true, false], [(48 + 1) * 60 * 60, false], [1.0 * (48 + 1) * 60 * 60, false], ["P2DT1H", true], [[self::i("P2DT1H")], false], [self::i("P2DT1H"), true]],
[self::i("PT0H"), [null,true], [true, false], [0, false], [0.0, false], ["PT0S", true], [[self::i("PT0H")], false], [self::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]],
["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]],
["1 year, 2 days", [null,true], [true, false], [0, false], [0.0, false], ["1 year, 2 days", true], [["1 year, 2 days"], false], [self::i("P1Y2D"), false]],
["P1Y2D", [null,true], [true, false], [0, false], [0.0, false], ["P1Y2D", true], [["P1Y2D"], false], [self::i("P1Y2D"), true]],
] as $set) {
// shift the input value off the set
$input = array_shift($set);
@ -557,7 +557,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideDateNormalizationValues(): iterable {
public static function provideDateNormalizationValues(): iterable {
$formats = [
"microtime",
"iso8601",
@ -576,33 +576,33 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[null, 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],
[$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", 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)],
[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.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],
[self::d("2010-01-01T00:00:00", 0, 0), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000)],
[self::d("2010-01-01T00:00:00", 0, 1), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000)],
[self::d("2010-01-01T00:00:00", 1, 0), self::t(1262322000), self::t(1262322000), self::t(1262322000), self::t(1262322000), self::t(1262322000), self::t(1262322000), self::t(1262322000), self::t(1262322000), self::t(1262322000), self::t(1262322000), self::t(1262322000)],
[self::d("2010-01-01T00:00:00", 1, 1), self::t(1262322000), self::t(1262322000), self::t(1262322000), self::t(1262322000), self::t(1262322000), self::t(1262322000), self::t(1262322000), self::t(1262322000), self::t(1262322000), self::t(1262322000), self::t(1262322000)],
[1262304000, self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000), self::t(1262304000)],
[1262304000.123456, self::t(1262304000.123456), self::t(1262304000.123456), self::t(1262304000.123456), self::t(1262304000.123456), self::t(1262304000.123456), self::t(1262304000.123456), self::t(1262304000.123456), self::t(1262304000.123456), self::t(1262304000.123456), self::t(1262304000.123456), self::t(1262304000.123456)],
[1262304000.42, self::t(1262304000.42), self::t(1262304000.42), self::t(1262304000.42), self::t(1262304000.42), self::t(1262304000.42), self::t(1262304000.42), self::t(1262304000.42), self::t(1262304000.42), self::t(1262304000.42), self::t(1262304000.42), self::t(1262304000.42)],
["0.12345600 1262304000", self::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],
["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: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-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)],
["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", 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)],
["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.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],
["First day of Jan 2010 12AM", null, null, null, null, null, null, null, null, null, null, $this->t(1262304000)],
["2010-01-01T00:00:00", null, self::t(1262304000), self::t(1262304000), null, null, null, null, null, null, null, self::t(1262304000)],
["2010-01-01T00:00:00Z", null, self::t(1262304000), self::t(1262304000), null, null, null, null, null, null, null, self::t(1262304000)],
["2010-01-01T00:00:00+0000", null, self::t(1262304000), self::t(1262304000), null, null, null, null, null, null, null, self::t(1262304000)],
["2010-01-01T00:00:00-0000", null, self::t(1262304000), self::t(1262304000), null, null, null, null, null, null, null, self::t(1262304000)],
["2010-01-01T00:00:00+00:00", null, self::t(1262304000), self::t(1262304000), null, null, null, null, null, null, null, self::t(1262304000)],
["2010-01-01T00:00:00-05:00", null, self::t(1262322000), self::t(1262322000), null, null, null, null, null, null, null, self::t(1262322000)],
["2010-01-01T00:00:00.123456Z", null, null, self::t(1262304000.123456), null, null, null, null, null, null, null, self::t(1262304000.123456)],
["Fri, 01 Jan 2010 00:00:00 GMT", null, null, null, self::t(1262304000), null, null, null, null, null, null, self::t(1262304000)],
["2010-01-01 00:00:00", null, null, null, null, self::t(1262304000), null, null, null, null, null, self::t(1262304000)],
["2010-01-01", null, null, null, null, null, self::t(1262304000), null, null, null, null, self::t(1262304000)],
["12:34:56", null, null, null, null, null, null, self::t(45296), null, null, null, self::t(date_create("today", new \DateTimezone("UTC"))->getTimestamp() + 45296)],
["1262304000", null, null, null, null, null, null, null, self::t(1262304000), null, null, null],
["1262304000.123456", null, null, null, null, null, null, null, null, self::t(1262304000.123456), null, null],
["1262304000.42", null, null, null, null, null, null, null, null, self::t(1262304000.42), null, null],
["Jan 1, 2010 (Fri)", null, null, null, null, null, null, null, null, null, self::t(1262304000), null],
["First day of Jan 2010 12AM", null, null, null, null, null, null, null, null, null, null, self::t(1262304000)],
[[], 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],
[self::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],
] as $k => $set) {
// shift the input value off the set
@ -622,7 +622,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
protected function d($spec, $local, $immutable): \DateTimeInterface {
protected static function d($spec, $local, $immutable): \DateTimeInterface {
$tz = $local ? new \DateTimeZone("America/Toronto") : new \DateTimeZone("UTC");
if ($immutable) {
return \DateTimeImmutable::createFromFormat("!Y-m-d\TH:i:s", $spec, $tz);
@ -631,11 +631,11 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
protected function t(float $spec): \DateTimeImmutable {
protected static function t(float $spec): \DateTimeImmutable {
return \DateTimeImmutable::createFromFormat("U.u", sprintf("%F", $spec), new \DateTimeZone("UTC"));
}
protected function i(string $spec, float $msec = 0.0): \DateInterval {
protected static function i(string $spec, float $msec = 0.0): \DateInterval {
$out = new \DateInterval($spec);
$out->f = $msec;
return $out;

View file

@ -141,7 +141,7 @@ class TestAPI extends \JKingWeb\Arsse\Test\AbstractTest {
],
];
protected function v($value) {
protected static function v($value) {
return $value;
}
@ -187,7 +187,7 @@ class TestAPI extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertMessage($exp, $this->req($dataGet, $dataPost, "POST", null, "", $httpUser));
}
public function provideTokenAuthenticationRequests(): iterable {
public static function provideTokenAuthenticationRequests(): iterable {
$success = HTTP::respJson(['auth' => 1]);
$failure = HTTP::respJson(['auth' => 0]);
$denied = HTTP::respEmpty(401);
@ -305,7 +305,7 @@ class TestAPI extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify(Arsse::$db)->articleList($this->userId, $this->equalTo($c), $fields, $order);
}
public function provideItemListContexts(): iterable {
public static function provideItemListContexts(): iterable {
$c = (new Context)->limit(50);
return [
["items", (clone $c)->hidden(false), false],
@ -372,7 +372,7 @@ class TestAPI extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideMarkingContexts(): iterable {
public static function provideMarkingContexts(): iterable {
$markRead = ['read' => true];
$markUnread = ['read' => false];
$markSaved = ['starred' => true];
@ -415,7 +415,7 @@ class TestAPI extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertMessage($exp, $this->req($get, $post, $method, $type));
}
public function provideInvalidRequests(): iterable {
public static function provideInvalidRequests(): iterable {
return [
'Not an API request' => ["", "", "POST", null, HTTP::respEmpty(404)],
'Wrong method' => ["api", "", "PUT", null, HTTP::respEmpty(405, ['Allow' => "OPTIONS,POST"])],
@ -476,7 +476,7 @@ class TestAPI extends \JKingWeb\Arsse\Test\AbstractTest {
public function testListFeedIcons(): void {
$iconType = (new \ReflectionClassConstant(API::class, "GENERIC_ICON_TYPE"))->getValue();
$iconData = (new \ReflectionClassConstant(API::class, "GENERIC_ICON_DATA"))->getValue();
\Phake::when(Arsse::$db)->iconList->thenReturn(new Result($this->v([
\Phake::when(Arsse::$db)->iconList->thenReturn(new Result(self::v([
['id' => 42, 'type' => "image/svg+xml", 'data' => "<svg/>"],
['id' => 44, 'type' => null, 'data' => "IMAGE DATA"],
['id' => 47, 'type' => null, 'data' => null],

View file

@ -53,7 +53,7 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function providePasswordCreations(): iterable {
public static function providePasswordCreations(): iterable {
return [
["jane.doe@example.com", "secret", "secret"],
["jane.doe@example.com", "superman", "superman"],
@ -81,7 +81,7 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame($exp, $this->h->authenticate($user, $password));
}
public function provideUserAuthenticationRequests(): iterable {
public static function provideUserAuthenticationRequests(): iterable {
return [
["jane.doe@example.com", "secret", true],
["jane.doe@example.com", "superman", false],

View file

@ -20,7 +20,7 @@ class TestStatus extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertMessage($exp, $act);
}
public function provideRequests(): iterable {
public static function provideRequests(): iterable {
return [
["/version", "GET", HTTP::respText(V1::VERSION)],
["/version", "POST", HTTP::respEmpty(405, ['Allow' => "HEAD, GET"])],

View file

@ -32,7 +32,7 @@ class TestToken extends \JKingWeb\Arsse\Test\AbstractTest {
$this->h = new Token;
}
protected function v($value) {
protected static function v($value) {
return $value;
}
@ -54,7 +54,7 @@ class TestToken extends \JKingWeb\Arsse\Test\AbstractTest {
['label' => "Eek", 'id' => "TOKEN 2"],
['label' => "Ack", 'id' => "TOKEN 3"],
];
\Phake::when(Arsse::$db)->tokenList->thenReturn(new Result($this->v($out)));
\Phake::when(Arsse::$db)->tokenList->thenReturn(new Result(self::v($out)));
\Phake::when(Arsse::$db)->userExists->thenReturn(true);
$this->assertSame($exp, $this->h->tokenList("john.doe@example.com"));
\Phake::verify(Arsse::$db)->tokenList("john.doe@example.com", "miniflux.login");

View file

@ -87,7 +87,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
$this->h = new V1();
}
protected function v($value) {
protected static function v($value) {
return $value;
}
@ -113,7 +113,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame($success ? $user : null, Arsse::$user->id);
}
public function provideAuthResponses(): iterable {
public static function provideAuthResponses(): iterable {
return [
[null, false, false],
[null, true, true],
@ -134,7 +134,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertMessage($exp, $this->req($method, $path));
}
public function provideInvalidPaths(): array {
public static function provideInvalidPaths(): array {
return [
["/", "GET", 404],
["/", "OPTIONS", 404],
@ -152,7 +152,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertMessage($exp, $this->req("OPTIONS", $url));
}
public function provideOptionsRequests(): array {
public static function provideOptionsRequests(): array {
return [
["/feeds", "HEAD, GET, POST", "application/json"],
["/feeds/2112", "HEAD, GET, PUT, DELETE", "application/json"],
@ -177,7 +177,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertMessage($exp, $this->req("POST", "/discover", ['url' => $in]));
}
public function provideDiscoveries(): iterable {
public static function provideDiscoveries(): iterable {
self::clearData();
$discovered = [
['title' => "Feed", 'type' => "rss", 'url' => "http://localhost:8000/Feed/Discovery/Feed"],
@ -212,7 +212,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertMessage($exp, $this->req("GET", $route, "", [], $user));
}
public function provideUserQueries(): iterable {
public static function provideUserQueries(): iterable {
self::clearData();
return [
[true, "/users", HTTP::respJson(self::USERS)],
@ -279,7 +279,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideUserModifications(): iterable {
public static function provideUserModifications(): iterable {
$out1 = ['num' => 2, 'admin' => false];
$out2 = ['num' => 1, 'admin' => false];
$resp1 = array_merge(self::USERS[1], ['username' => "john.doe@example.com"]);
@ -332,7 +332,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideUserAdditions(): iterable {
public static function provideUserAdditions(): iterable {
$resp1 = array_merge(self::USERS[1], ['username' => "ook", 'password' => "eek"]);
return [
[[], null, null, null, null, V1::respError(["MissingInputValue", 'field' => "username"], 422)],
@ -376,7 +376,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
}
public function testListCategories(): void {
\Phake::when(Arsse::$db)->folderList->thenReturn(new Result($this->v([
\Phake::when(Arsse::$db)->folderList->thenReturn(new Result(self::v([
['id' => 1, 'name' => "Science"],
['id' => 20, 'name' => "Technology"],
])));
@ -412,7 +412,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertMessage($exp, $this->req("POST", "/categories", ['title' => $title]));
}
public function provideCategoryAdditions(): iterable {
public static function provideCategoryAdditions(): iterable {
return [
["New", HTTP::respJson(['id' => 2112, 'title' => "New", 'user_id' => 42], 201)],
["Duplicate", V1::respError(["DuplicateCategory", 'title' => "Duplicate"], 409)],
@ -438,7 +438,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify(Arsse::$db, \Phake::times($times))->folderPropertiesSet("john.doe@example.com", $id - 1, ['name' => $title]);
}
public function provideCategoryUpdates(): iterable {
public static function provideCategoryUpdates(): iterable {
return [
[3, "New", "subjectMissing", V1::respError("404", 404)],
[2, "New", true, HTTP::respJson(['id' => 2, 'title' => "New", 'user_id' => 42], 201)],
@ -465,7 +465,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
}
public function testDeleteTheSpecialCategory(): void {
\Phake::when(Arsse::$db)->subscriptionList->thenReturn(new Result($this->v([
\Phake::when(Arsse::$db)->subscriptionList->thenReturn(new Result(self::v([
['id' => 1],
['id' => 47],
['id' => 2112],
@ -483,20 +483,20 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
}
public function testListFeeds(): void {
\Phake::when(Arsse::$db)->subscriptionList->thenReturn(new Result($this->v(self::FEEDS)));
\Phake::when(Arsse::$db)->subscriptionList->thenReturn(new Result(self::v(self::FEEDS)));
$exp = HTTP::respJson(self::FEEDS_OUT);
$this->assertMessage($exp, $this->req("GET", "/feeds"));
}
public function testListFeedsOfACategory(): void {
\Phake::when(Arsse::$db)->subscriptionList->thenReturn(new Result($this->v(self::FEEDS)));
\Phake::when(Arsse::$db)->subscriptionList->thenReturn(new Result(self::v(self::FEEDS)));
$exp = HTTP::respJson(self::FEEDS_OUT);
$this->assertMessage($exp, $this->req("GET", "/categories/2112/feeds"));
\Phake::verify(Arsse::$db)->subscriptionList(Arsse::$user->id, 2111, true);
}
public function testListFeedsOfTheRootCategory(): void {
\Phake::when(Arsse::$db)->subscriptionList->thenReturn(new Result($this->v(self::FEEDS)));
\Phake::when(Arsse::$db)->subscriptionList->thenReturn(new Result(self::v(self::FEEDS)));
$exp = HTTP::respJson(self::FEEDS_OUT);
$this->assertMessage($exp, $this->req("GET", "/categories/1/feeds"));
\Phake::verify(Arsse::$db)->subscriptionList(Arsse::$user->id, 0, false);
@ -510,7 +510,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
}
public function testGetAFeed(): void {
\Phake::when(Arsse::$db)->subscriptionPropertiesGet->thenReturn($this->v(self::FEEDS[0]))->thenReturn($this->v(self::FEEDS[1]));
\Phake::when(Arsse::$db)->subscriptionPropertiesGet->thenReturn(self::v(self::FEEDS[0]))->thenReturn(self::v(self::FEEDS[1]));
$this->assertMessage(HTTP::respJson(self::FEEDS_OUT[0]), $this->req("GET", "/feeds/1"));
$this->assertMessage(HTTP::respJson(self::FEEDS_OUT[1]), $this->req("GET", "/feeds/55"));
\Phake::when(Arsse::$db)->subscriptionPropertiesGet(Arsse::$user->id, 1);
@ -582,7 +582,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideFeedCreations(): iterable {
public static function provideFeedCreations(): iterable {
self::clearData();
return [
[['category_id' => 1], null, null, null, null, V1::respError(["MissingInputValue", 'field' => "feed_url"], 422)],
@ -627,7 +627,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify(Arsse::$db)->subscriptionPropertiesSet(Arsse::$user->id, 2112, $data);
}
public function provideFeedModifications(): iterable {
public static function provideFeedModifications(): iterable {
self::clearData();
$success = HTTP::respJson(self::FEEDS_OUT[0], 201);
return [
@ -669,13 +669,13 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
if ($out instanceof \Exception) {
\Phake::when(Arsse::$db)->subscriptionIcon->thenThrow($out);
} else {
\Phake::when(Arsse::$db)->subscriptionIcon->thenReturn($this->v($out));
\Phake::when(Arsse::$db)->subscriptionIcon->thenReturn(self::v($out));
}
$this->assertMessage($exp, $this->req("GET", "/feeds/2112/icon"));
\Phake::verify(Arsse::$db)->subscriptionIcon(Arsse::$user->id, 2112);
}
public function provideIcons(): iterable {
public static function provideIcons(): iterable {
return [
[['id' => 44, 'type' => "image/svg+xml", 'data' => "<svg/>"], HTTP::respJson(['id' => 44, 'data' => "image/svg+xml;base64,PHN2Zy8+", 'mime_type' => "image/svg+xml"])],
[['id' => 47, 'type' => "", 'data' => "<svg/>"], V1::respError("404", 404)],
@ -688,12 +688,12 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
/** @dataProvider provideEntryQueries */
public function testGetEntries(string $url, ?RootContext $c, ?array $order, $out, bool $count, ResponseInterface $exp): void {
\Phake::when(Arsse::$db)->subscriptionList->thenReturn(new Result($this->v(self::FEEDS)));
\Phake::when(Arsse::$db)->subscriptionList->thenReturn(new Result(self::v(self::FEEDS)));
\Phake::when(Arsse::$db)->articleCount->thenReturn(2112);
if ($out instanceof \Exception) {
\Phake::when(Arsse::$db)->articleList->thenThrow($out);
} else {
\Phake::when(Arsse::$db)->articleList->thenReturn(new Result($this->v($out)));
\Phake::when(Arsse::$db)->articleList->thenReturn(new Result(self::v($out)));
}
$this->assertMessage($exp, $this->req("GET", $url));
if ($c) {
@ -713,7 +713,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideEntryQueries(): iterable {
public static function provideEntryQueries(): iterable {
self::clearData();
$c = (new Context)->limit(100);
$o = ["modified_date"]; // the default sort order
@ -779,11 +779,11 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
/** @dataProvider provideSingleEntryQueries */
public function testGetASingleEntry(string $url, Context $c, $out, ResponseInterface $exp): void {
\Phake::when(Arsse::$db)->subscriptionPropertiesGet->thenReturn($this->v(self::FEEDS[1]));
\Phake::when(Arsse::$db)->subscriptionPropertiesGet->thenReturn(self::v(self::FEEDS[1]));
if ($out instanceof \Exception) {
\Phake::when(Arsse::$db)->articleList->thenThrow($out);
} else {
\Phake::when(Arsse::$db)->articleList->thenReturn(new Result($this->v($out)));
\Phake::when(Arsse::$db)->articleList->thenReturn(new Result(self::v($out)));
}
$this->assertMessage($exp, $this->req("GET", $url));
if ($c) {
@ -798,7 +798,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideSingleEntryQueries(): iterable {
public static function provideSingleEntryQueries(): iterable {
self::clearData();
$c = new Context;
return [
@ -827,7 +827,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideEntryMarkings(): iterable {
public static function provideEntryMarkings(): iterable {
self::clearData();
return [
[['status' => "read"], null, V1::respError(["MissingInputValue", 'field' => "entry_ids"], 422)],
@ -859,7 +859,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideMassMarkings(): iterable {
public static function provideMassMarkings(): iterable {
self::clearData();
$c = (new Context)->hidden(false);
return [
@ -900,7 +900,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideBookmarkTogglings(): iterable {
public static function provideBookmarkTogglings(): iterable {
self::clearData();
return [
[1, true, HTTP::respEmpty(204)],
@ -935,7 +935,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify($opml)->import(Arsse::$user->id, "IMPORT DATA");
}
public function provideImports(): iterable {
public static function provideImports(): iterable {
self::clearData();
return [
[new ImportException("invalidSyntax"), V1::respError("InvalidBodyXML", 400)],

View file

@ -24,7 +24,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
protected $h;
protected $transaction;
protected $userId;
protected $feeds = [ // expected sample output of a feed list from the database, and the resultant expected transformation by the REST handler
protected static $feeds = [ // expected sample output of a feed list from the database, and the resultant expected transformation by the REST handler
'db' => [
[
'id' => 2112,
@ -117,7 +117,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
],
],
];
protected $articles = [
protected static $articles = [
'db' => [
[
'id' => 101,
@ -328,7 +328,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
$this->h = new V1_2();
}
protected function v($value) {
protected static function v($value) {
return $value;
}
@ -343,7 +343,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertMessage($exp, $this->req($method, $path));
}
public function provideInvalidPaths(): array {
public static function provideInvalidPaths(): array {
return [
["/", "GET", 404],
["/", "POST", 404],
@ -387,7 +387,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertMessage($exp, $this->req("OPTIONS", $url));
}
public function provideOptionsRequests(): array {
public static function provideOptionsRequests(): array {
return [
["/feeds", "HEAD,GET,POST", "application/json"],
["/feeds/2112", "DELETE", "application/json"],
@ -404,7 +404,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
['id' => 1, 'name' => "Software"],
['id' => 12, 'name' => "Hardware"],
];
\Phake::when(Arsse::$db)->folderList($this->userId, null, false)->thenReturn(new Result($this->v($list)));
\Phake::when(Arsse::$db)->folderList($this->userId, null, false)->thenReturn(new Result(self::v($list)));
$exp = HTTP::respJson(['folders' => $out]);
$this->assertMessage($exp, $this->req("GET", "/folders"));
}
@ -415,7 +415,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::when(Arsse::$db)->folderAdd->thenThrow($output);
} else {
\Phake::when(Arsse::$db)->folderAdd->thenReturn($output);
\Phake::when(Arsse::$db)->folderPropertiesGet->thenReturn($this->v(['id' => $output, 'name' => $input['name'], 'parent' => null]));
\Phake::when(Arsse::$db)->folderPropertiesGet->thenReturn(self::v(['id' => $output, 'name' => $input['name'], 'parent' => null]));
}
$act = $this->req("POST", "/folders", $input, [], true, $body);
$this->assertMessage($exp, $act);
@ -427,7 +427,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideFolderCreations(): array {
public static function provideFolderCreations(): array {
return [
[['name' => "Software"], true, 1, HTTP::respJson(['folders' => [['id' => 1, 'name' => "Software"]]])],
[['name' => "Software"], false, 1, HTTP::respJson(['folders' => [['id' => 1, 'name' => "Software"]]])],
@ -462,7 +462,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify(Arsse::$db)->folderPropertiesSet($this->userId, $id, $input);
}
public function provideFolderRenamings(): array {
public static function provideFolderRenamings(): array {
return [
[['name' => "Software"], 1, true, HTTP::respEmpty(204)],
[['name' => "Software"], 2, new ExceptionInput("constraintViolation"), HTTP::respEmpty(409)],
@ -487,12 +487,12 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
'starredCount' => 0,
];
$exp2 = [
'feeds' => $this->feeds['rest'],
'feeds' => self::$feeds['rest'],
'starredCount' => 5,
'newestItemId' => 4758915,
];
\Phake::when(Arsse::$db)->subscriptionList($this->userId)->thenReturn(new Result([]))->thenReturn(new Result($this->v($this->feeds['db'])));
\Phake::when(Arsse::$db)->articleStarred($this->userId)->thenReturn($this->v(['total' => 0]))->thenReturn($this->v(['total' => 5]));
\Phake::when(Arsse::$db)->subscriptionList($this->userId)->thenReturn(new Result([]))->thenReturn(new Result(self::v(self::$feeds['db'])));
\Phake::when(Arsse::$db)->articleStarred($this->userId)->thenReturn(self::v(['total' => 0]))->thenReturn(self::v(['total' => 5]));
\Phake::when(Arsse::$db)->editionLatest($this->userId)->thenReturn(0)->thenReturn(4758915);
$exp = HTTP::respJson($exp1);
$this->assertMessage($exp, $this->req("GET", "/feeds"));
@ -512,7 +512,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
} else {
\Phake::when(Arsse::$db)->subscriptionPropertiesSet->thenReturn($moveOutcome);
}
\Phake::when(Arsse::$db)->subscriptionPropertiesGet->thenReturn($this->v($output));
\Phake::when(Arsse::$db)->subscriptionPropertiesGet->thenReturn(self::v($output));
\Phake::when(Arsse::$db)->editionLatest->thenReturn($latestEdition);
$act = $this->req("POST", "/feeds", $input);
$this->assertMessage($exp, $act);
@ -532,15 +532,15 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideNewSubscriptions(): array {
public static function provideNewSubscriptions(): array {
$feedException = new \JKingWeb\Arsse\Feed\Exception("", [], new \PicoFeed\Reader\SubscriptionNotFoundException);
return [
[['url' => "http://example.com/news.atom", 'folderId' => 3], 2112, 0, $this->feeds['db'][0], new ExceptionInput("idMissing"), HTTP::respJson(['feeds' => [$this->feeds['rest'][0]]])],
[['url' => "http://example.org/news.atom", 'folderId' => 8], 42, 4758915, $this->feeds['db'][1], true, HTTP::respJson(['feeds' => [$this->feeds['rest'][1]], 'newestItemId' => 4758915])],
[['url' => "http://example.com/news.atom", 'folderId' => 3], new ExceptionInput("constraintViolation"), 0, $this->feeds['db'][0], new ExceptionInput("idMissing"), HTTP::respEmpty(409)],
[['url' => "http://example.org/news.atom", 'folderId' => 8], new ExceptionInput("constraintViolation"), 4758915, $this->feeds['db'][1], true, HTTP::respEmpty(409)],
[['url' => "http://example.com/news.atom", 'folderId' => 3], 2112, 0, self::$feeds['db'][0], new ExceptionInput("idMissing"), HTTP::respJson(['feeds' => [self::$feeds['rest'][0]]])],
[['url' => "http://example.org/news.atom", 'folderId' => 8], 42, 4758915, self::$feeds['db'][1], true, HTTP::respJson(['feeds' => [self::$feeds['rest'][1]], 'newestItemId' => 4758915])],
[['url' => "http://example.com/news.atom", 'folderId' => 3], new ExceptionInput("constraintViolation"), 0, self::$feeds['db'][0], new ExceptionInput("idMissing"), HTTP::respEmpty(409)],
[['url' => "http://example.org/news.atom", 'folderId' => 8], new ExceptionInput("constraintViolation"), 4758915, self::$feeds['db'][1], true, HTTP::respEmpty(409)],
[[], $feedException, 0, [], false, HTTP::respEmpty(422)],
[['url' => "http://example.net/news.atom", 'folderId' => -1], 47, 2112, $this->feeds['db'][2], new ExceptionInput("typeViolation"), HTTP::respJson(['feeds' => [$this->feeds['rest'][2]], 'newestItemId' => 2112])],
[['url' => "http://example.net/news.atom", 'folderId' => -1], 47, 2112, self::$feeds['db'][2], new ExceptionInput("typeViolation"), HTTP::respJson(['feeds' => [self::$feeds['rest'][2]], 'newestItemId' => 2112])],
];
}
@ -623,7 +623,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
'userId' => "",
],
];
\Phake::when(Arsse::$db)->feedListStale->thenReturn($this->v(array_column($out, "id")));
\Phake::when(Arsse::$db)->feedListStale->thenReturn(self::v(array_column($out, "id")));
$exp = HTTP::respJson(['feeds' => $out]);
$this->assertMessage($exp, $this->req("GET", "/feeds/all"));
}
@ -676,11 +676,11 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify(Arsse::$db)->articleList($this->userId, $this->equalTo($c), $columns, [$order]);
}
public function provideArticleQueries(): iterable {
public static function provideArticleQueries(): iterable {
$c = (new Context)->hidden(false);
$t = Date::normalize(time());
$out = new Result($this->v($this->articles['db']));
$r200 = HTTP::respJson(['items' => $this->articles['rest']]);
$out = new Result(self::v(self::$articles['db']));
$r200 = HTTP::respJson(['items' => self::$articles['rest']]);
$r422 = HTTP::respEmpty(422);
return [
["/items", [], clone $c, $out, $r200],
@ -901,8 +901,8 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
$out2 = ['id' => 2, 'name' => "Hardware"];
\Phake::when(Arsse::$db)->folderAdd($this->anything(), $this->anything())->thenReturn(2);
\Phake::when(Arsse::$db)->folderAdd($this->anything(), $in)->thenReturn(1);
\Phake::when(Arsse::$db)->folderPropertiesGet($this->userId, 1)->thenReturn($this->v($out1));
\Phake::when(Arsse::$db)->folderPropertiesGet($this->userId, 2)->thenReturn($this->v($out2));
\Phake::when(Arsse::$db)->folderPropertiesGet($this->userId, 1)->thenReturn(self::v($out1));
\Phake::when(Arsse::$db)->folderPropertiesGet($this->userId, 2)->thenReturn(self::v($out2));
$exp = HTTP::respJson(['folders' => [$out1]]);
$this->assertMessage($exp, $this->req("POST", $url, json_encode($in)));
}

View file

@ -33,7 +33,7 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertEquals($exp, $out);
}
public function provideApiMatchData(): iterable {
public static function provideApiMatchData(): iterable {
$real = null;
$fake = [
'unstripped' => ['match' => "/full/url", 'strip' => "", 'class' => "UnstrippedProtocol"],
@ -78,7 +78,7 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertMessage($exp, $act);
}
public function provideAuthenticableRequests(): iterable {
public static function provideAuthenticableRequests(): iterable {
return [
[['PHP_AUTH_USER' => "john.doe@example.com", 'PHP_AUTH_PW' => "secret"], ['authenticated' => true, 'authenticatedUser' => "john.doe@example.com"]],
[['PHP_AUTH_USER' => "john.doe@example.com", 'PHP_AUTH_PW' => "secret", 'REMOTE_USER' => "jane.doe@example.com"], ['authenticated' => true, 'authenticatedUser' => "john.doe@example.com"]],
@ -110,7 +110,7 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame($exp, $act);
}
public function provideUnnormalizedOrigins(): iterable {
public static function provideUnnormalizedOrigins(): iterable {
return [
["null", "null"],
["http://example.com", "http://example.com"],
@ -159,7 +159,7 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame($exp, $act);
}
public function provideCorsNegotiations(): iterable {
public static function provideCorsNegotiations(): iterable {
return [
["http://example", true ],
["http://example", true, "http://example", "*" ],
@ -194,7 +194,7 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertMessage($exp, $act);
}
public function provideCorsHeaders(): iterable {
public static function provideCorsHeaders(): iterable {
return [
["GET", ['Origin' => "null"], [], [
'Access-Control-Allow-Origin' => "null",
@ -262,7 +262,7 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertMessage($exp, $act);
}
public function provideUnnormalizedResponses(): iterable {
public static function provideUnnormalizedResponses(): iterable {
$stream = fopen("php://memory", "w+b");
fwrite($stream, "ook");
return [
@ -312,7 +312,7 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify($rMock)->normalizeResponse(\Phake::anyParameters());
}
public function provideMockRequests(): iterable {
public static function provideMockRequests(): iterable {
return [
[new ServerRequest("GET", "/index.php/apps/news/api/v1-2/feeds"), "GET", true, NCN::class, "/feeds"],
[new ServerRequest("GET", "/index.php/apps/news/api/v1-2/feeds"), "GET", true, NCN::class, "/feeds"],

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,7 @@ use JKingWeb\Arsse\REST\TinyTinyRSS\Search;
/** @covers \JKingWeb\Arsse\REST\TinyTinyRSS\Search */
class TestSearch extends \JKingWeb\Arsse\Test\AbstractTest {
public function provideSearchStrings(): iterable {
public static function provideSearchStrings(): iterable {
return [
'Blank string' => ["", new Context],
'Whitespace only' => [" \n \t", new Context],

View file

@ -56,7 +56,7 @@ class TestDaemon extends \JKingWeb\Arsse\Test\AbstractTest {
$this->AssertSame($exp, $daemon->resolveRelativePath($path));
}
public function providePathResolutions(): iterable {
public static function providePathResolutions(): iterable {
return [
["/", "/home/me", "/"],
["/.", "/home/me", "/"],
@ -94,7 +94,7 @@ class TestDaemon extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function providePidFileChecks(): iterable {
public static function providePidFileChecks(): iterable {
return [
["ok/file", false, new Exception("pidDirUnresolvable")],
["not/found", true, new Exception("pidDirMissing")],
@ -136,7 +136,7 @@ class TestDaemon extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function providePidReadChecks(): iterable {
public static function providePidReadChecks(): iterable {
return [
["current", new Exception("pidDuplicate")],
["malformed1", new Exception("pidCorrupt")],
@ -190,7 +190,7 @@ class TestDaemon extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function providePidWriteChecks(): iterable {
public static function providePidWriteChecks(): iterable {
return [
["current", new Exception("pidDuplicate")],
["malformed1", new Exception("pidCorrupt")],

View file

@ -56,7 +56,7 @@ class TestArsse extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function provideExtensionChecks(): iterable {
public static function provideExtensionChecks(): iterable {
return [
[["pcre"], null],
[["foo", "bar", "baz"], new Exception("extMissing", ['first' => "foo", 'total' => 3])],

View file

@ -46,7 +46,7 @@ class TestInternal extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame($exp, $this->d->auth($user, $password));
}
public function provideAuthentication(): iterable {
public static function provideAuthentication(): iterable {
$john = "john.doe@example.com";
$jane = "jane.doe@example.com";
$owen = "owen.hardy@example.com";

View file

@ -71,7 +71,7 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify(Arsse::$db, \Phake::times($exp && $user === "jane.doe@example.com" ? 1 : 0))->userAdd($user, $password);
}
public function provideAuthentication(): iterable {
public static function provideAuthentication(): iterable {
$john = "john.doe@example.com";
$jane = "jane.doe@example.com";
return [
@ -163,7 +163,7 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
$u->add($user, "secret");
}
public function provideInvalidUserNames(): iterable {
public static function provideInvalidUserNames(): iterable {
// output names with control characters
foreach (array_merge(range(0x00, 0x1F), [0x7F]) as $ord) {
yield [chr($ord)];
@ -419,7 +419,7 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify(Arsse::$db)->userExists($user);
}
public function provideProperties(): iterable {
public static function provideProperties(): iterable {
$defaults = ['num' => 1, 'admin' => false, 'lang' => null, 'tz' => "Etc/UTC", 'sort_asc' => false];
return [
[$defaults, $defaults, []],
@ -499,7 +499,7 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
}
}
public function providePropertyChanges(): iterable {
public static function providePropertyChanges(): iterable {
return [
[['admin' => true], ['admin' => true]],
[['admin' => 2], new ExceptionInput("invalidValue")],

View file

@ -27,8 +27,6 @@ use GuzzleHttp\Psr7\ServerRequest;
/** @coversNothing */
abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
use \DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
public function setUp(): void {
self::clearData();
// create the object factory as a mock
@ -133,19 +131,24 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
return $req;
}
public static function assertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void {
if (method_exists(parent::class, "assertMatchesRegularExpression")) {
parent::assertMatchesRegularExpression($pattern, $string, $message);
public function assertArraySubset($expected, $actual, string $message = ''): void {
$this->assertIsArray($actual);
if (array_is_list($expected)) {
$missing = $actual;
$actual = [];
foreach ($expected as $k => $v) {
$found = array_search($v, $missing, true);
if ($found !== false) {
$actual[$k] = $missing[$found];
unset($missing[$found]);
}
}
$this->assertEquals($expected, $actual, $message ?: "Array subset does not match expectation.");
} else {
parent::assertRegExp($pattern, $string, $message);
}
}
public static function assertFileDoesNotExist(string $filename, string $message = ''): void {
if (method_exists(parent::class, "assertFileDoesNotExist")) {
parent::assertFileDoesNotExist($filename, $message);
} else {
parent::assertFileNotExists($filename, $message);
$actual = array_intersect_key($actual, $expected);
ksort($actual);
ksort($expected);
$this->assertEquals($expected, $actual, $message ?: "Array subset does not match expectation.");
}
}
@ -344,7 +347,7 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
$data = $this->stringify($data);
}
}
$this->assertCount(sizeof($expected), $data, "Number of result rows (".sizeof($data).") differs from number of expected rows (".sizeof($expected).")");
$this->assertSameSize($expected, $data, "Number of result rows (".sizeof($data).") differs from number of expected rows (".sizeof($expected).")");
if (sizeof($expected)) {
// make sure the expectations are consistent
foreach ($expected as $exp) {
@ -372,7 +375,7 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
$found = array_search($row, $expected);
unset($expected[$found]);
}
$this->assertArraySubset($expected, [], false, "Expectations not in result set.");
$this->assertEmpty($expected, "Expectations not in result set.");
}
}

View file

@ -8,13 +8,13 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\Test;
trait PDOTest {
protected function v($value) {
protected static function v($value) {
if (!is_array($value)) {
return $value;
}
foreach ($value as $k => $v) {
if (is_array($v)) {
$value[$k] = $this->v($v);
$value[$k] = self::v($v);
} elseif (is_int($v) || is_float($v)) {
$value[$k] = (string) $v;
}

View file

@ -1,10 +1,9 @@
{
"require-dev": {
"phpunit/phpunit": "^9.0",
"dms/phpunit-arraysubset-asserts": "^0.1 || ^0.2",
"phpunit/phpunit": "^11.0",
"clue/arguments": "^2.0",
"mikey179/vfsstream": "^1.6",
"webmozart/glob": "^4.1",
"phake/phake": "^4.4 | ^3.1.9"
"phake/phake": "^4.4"
}
}

File diff suppressed because it is too large Load diff