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

Replace PHPUnit annotations with attributes

This commit is contained in:
J. King 2024-12-27 20:28:38 -05:00
parent ba42b7b0c1
commit ba4d3f497b
77 changed files with 363 additions and 219 deletions

View file

@ -65,6 +65,7 @@ $rules = [
], ],
'function_declaration' => ['closure_function_spacing' => "none"], 'function_declaration' => ['closure_function_spacing' => "none"],
'new_with_braces' => false, // no option to specify absence of braces 'new_with_braces' => false, // no option to specify absence of braces
'php_unit_attributes' => true,
]; ];
$finder = \PhpCsFixer\Finder::create(); $finder = \PhpCsFixer\Finder::create();

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -18,8 +19,10 @@ use JKingWeb\Arsse\REST\Fever\User as FeverUser;
use JKingWeb\Arsse\REST\Miniflux\Token as MinifluxToken; use JKingWeb\Arsse\REST\Miniflux\Token as MinifluxToken;
use JKingWeb\Arsse\ImportExport\OPML; use JKingWeb\Arsse\ImportExport\OPML;
use JKingWeb\Arsse\Service\Daemon; use JKingWeb\Arsse\Service\Daemon;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
/** @covers \JKingWeb\Arsse\CLI */ #[CoversClass(\JKingWeb\Arsse\CLI::class)]
class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest { class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
protected $cli; protected $cli;
@ -47,7 +50,8 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify($this->cli, \Phake::never())->loadConf(); \Phake::verify($this->cli, \Phake::never())->loadConf();
} }
/** @dataProvider provideHelpText */
#[DataProvider('provideHelpText')]
public function testPrintHelp(string $cmd, string $name): void { public function testPrintHelp(string $cmd, string $name): void {
$this->assertConsole($cmd, 0, str_replace("arsse.php", $name, CLI::USAGE)); $this->assertConsole($cmd, 0, str_replace("arsse.php", $name, CLI::USAGE));
\Phake::verify($this->cli, \Phake::never())->loadConf(); \Phake::verify($this->cli, \Phake::never())->loadConf();
@ -66,7 +70,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
public function testStartTheDaemon(): void { public function testStartTheDaemon(): void {
$srv = \Phake::mock(Service::class); $srv = \Phake::mock(Service::class);
\Phake::when($srv)->watch->thenReturn(new \DateTimeImmutable); \Phake::when($srv)->watch->thenReturn(new \DateTimeImmutable());
\Phake::when(Arsse::$obj)->get(Service::class)->thenReturn($srv); \Phake::when(Arsse::$obj)->get(Service::class)->thenReturn($srv);
$this->assertConsole("arsse.php daemon", 0); $this->assertConsole("arsse.php daemon", 0);
\Phake::verify($this->cli)->loadConf(); \Phake::verify($this->cli)->loadConf();
@ -77,7 +81,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
$f = tempnam(sys_get_temp_dir(), "arsse"); $f = tempnam(sys_get_temp_dir(), "arsse");
$srv = \Phake::mock(Service::class); $srv = \Phake::mock(Service::class);
$daemon = \Phake::mock(Daemon::class); $daemon = \Phake::mock(Daemon::class);
\Phake::when($srv)->watch->thenReturn(new \DateTimeImmutable); \Phake::when($srv)->watch->thenReturn(new \DateTimeImmutable());
\Phake::when($daemon)->checkPIDFilePath->thenReturn($f); \Phake::when($daemon)->checkPIDFilePath->thenReturn($f);
\Phake::when($daemon)->fork->thenReturn(null); \Phake::when($daemon)->fork->thenReturn(null);
\Phake::when(Arsse::$obj)->get(Service::class)->thenReturn($srv); \Phake::when(Arsse::$obj)->get(Service::class)->thenReturn($srv);
@ -95,7 +99,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
public function testFailToStartTheForkingDaemon(): void { public function testFailToStartTheForkingDaemon(): void {
$srv = \Phake::mock(Service::class); $srv = \Phake::mock(Service::class);
$daemon = \Phake::mock(Daemon::class); $daemon = \Phake::mock(Daemon::class);
\Phake::when($srv)->watch->thenReturn(new \DateTimeImmutable); \Phake::when($srv)->watch->thenReturn(new \DateTimeImmutable());
\Phake::when($daemon)->checkPIDFilePath->thenThrow(new Service\Exception("pidDuplicate", ['pid' => 2112])); \Phake::when($daemon)->checkPIDFilePath->thenThrow(new Service\Exception("pidDuplicate", ['pid' => 2112]));
\Phake::when($daemon)->fork->thenReturn(null); \Phake::when($daemon)->fork->thenReturn(null);
\Phake::when(Arsse::$obj)->get(Service::class)->thenReturn($srv); \Phake::when(Arsse::$obj)->get(Service::class)->thenReturn($srv);
@ -109,14 +113,15 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
public function testRefreshAllFeeds(): void { public function testRefreshAllFeeds(): void {
$srv = \Phake::mock(Service::class); $srv = \Phake::mock(Service::class);
\Phake::when($srv)->watch->thenReturn(new \DateTimeImmutable); \Phake::when($srv)->watch->thenReturn(new \DateTimeImmutable());
\Phake::when(Arsse::$obj)->get(Service::class)->thenReturn($srv); \Phake::when(Arsse::$obj)->get(Service::class)->thenReturn($srv);
$this->assertConsole("arsse.php feed refresh-all", 0); $this->assertConsole("arsse.php feed refresh-all", 0);
\Phake::verify($this->cli)->loadConf(); \Phake::verify($this->cli)->loadConf();
\Phake::verify($srv)->watch(false); \Phake::verify($srv)->watch(false);
} }
/** @dataProvider provideFeedUpdates */
#[DataProvider('provideFeedUpdates')]
public function testRefreshAFeed(string $cmd, int $exitStatus, string $output): void { public function testRefreshAFeed(string $cmd, int $exitStatus, string $output): void {
\Phake::when(Arsse::$db)->feedUpdate(1, true)->thenReturn(true); \Phake::when(Arsse::$db)->feedUpdate(1, true)->thenReturn(true);
\Phake::when(Arsse::$db)->feedUpdate(2, true)->thenThrow(new \JKingWeb\Arsse\Feed\Exception("", ['url' => "http://example.com/"], $this->mockGuzzleException(ClientException::class, "", 404))); \Phake::when(Arsse::$db)->feedUpdate(2, true)->thenThrow(new \JKingWeb\Arsse\Feed\Exception("", ['url' => "http://example.com/"], $this->mockGuzzleException(ClientException::class, "", 404)));
@ -132,7 +137,8 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideDefaultConfigurationSaves */
#[DataProvider('provideDefaultConfigurationSaves')]
public function testSaveTheDefaultConfiguration(string $cmd, int $exitStatus, string $file): void { public function testSaveTheDefaultConfiguration(string $cmd, int $exitStatus, string $file): void {
$conf = \Phake::mock(Conf::class); $conf = \Phake::mock(Conf::class);
\Phake::when($conf)->exportFile("php://output", true)->thenReturn(true); \Phake::when($conf)->exportFile("php://output", true)->thenReturn(true);
@ -153,7 +159,8 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideUserList */
#[DataProvider('provideUserList')]
public function testListUsers(string $cmd, array $list, int $exitStatus, string $output): void { public function testListUsers(string $cmd, array $list, int $exitStatus, string $output): void {
Arsse::$user = \Phake::mock(User::class); Arsse::$user = \Phake::mock(User::class);
\Phake::when(Arsse::$user)->list()->thenReturn($list); \Phake::when(Arsse::$user)->list()->thenReturn($list);
@ -171,7 +178,8 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideUserAdditions */
#[DataProvider('provideUserAdditions')]
public function testAddAUser(string $cmd, int $exitStatus, string $output): void { public function testAddAUser(string $cmd, int $exitStatus, string $output): void {
Arsse::$user = \Phake::mock(User::class); Arsse::$user = \Phake::mock(User::class);
\Phake::when(Arsse::$user)->add("john.doe@example.com", $this->anything())->thenThrow(new \JKingWeb\Arsse\User\ExceptionConflict("alreadyExists")); \Phake::when(Arsse::$user)->add("john.doe@example.com", $this->anything())->thenThrow(new \JKingWeb\Arsse\User\ExceptionConflict("alreadyExists"));
@ -199,7 +207,8 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify(Arsse::$user)->propertiesSet("jane.doe@example.com", ['admin' => true]); \Phake::verify(Arsse::$user)->propertiesSet("jane.doe@example.com", ['admin' => true]);
} }
/** @dataProvider provideUserAuthentication */
#[DataProvider('provideUserAuthentication')]
public function testAuthenticateAUser(string $cmd, int $exitStatus, string $output): void { public function testAuthenticateAUser(string $cmd, int $exitStatus, string $output): void {
Arsse::$user = \Phake::mock(User::class); Arsse::$user = \Phake::mock(User::class);
\Phake::when(Arsse::$user)->auth->thenReturn(false); \Phake::when(Arsse::$user)->auth->thenReturn(false);
@ -214,7 +223,7 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
} }
public static function provideUserAuthentication(): iterable { public static function provideUserAuthentication(): iterable {
$l = new \JKingWeb\Arsse\Lang; $l = new \JKingWeb\Arsse\Lang();
$success = $l("CLI.Auth.Success"); $success = $l("CLI.Auth.Success");
$failure = $l("CLI.Auth.Failure"); $failure = $l("CLI.Auth.Failure");
return [ return [
@ -229,7 +238,8 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideUserRemovals */
#[DataProvider('provideUserRemovals')]
public function testRemoveAUser(string $cmd, int $exitStatus, string $output): void { public function testRemoveAUser(string $cmd, int $exitStatus, string $output): void {
Arsse::$user = \Phake::mock(User::class); Arsse::$user = \Phake::mock(User::class);
\Phake::when(Arsse::$user)->remove->thenThrow(new \JKingWeb\Arsse\User\ExceptionConflict("doesNotExist")); \Phake::when(Arsse::$user)->remove->thenThrow(new \JKingWeb\Arsse\User\ExceptionConflict("doesNotExist"));
@ -244,7 +254,8 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideUserPasswordChanges */
#[DataProvider('provideUserPasswordChanges')]
public function testChangeAUserPassword(string $cmd, int $exitStatus, string $output): void { public function testChangeAUserPassword(string $cmd, int $exitStatus, string $output): void {
$passwordChange = function($user, $pass = null) { $passwordChange = function($user, $pass = null) {
switch ($user) { switch ($user) {
@ -273,7 +284,8 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideUserPasswordClearings */
#[DataProvider('provideUserPasswordClearings')]
public function testClearAUserPassword(string $cmd, int $exitStatus, string $output): void { public function testClearAUserPassword(string $cmd, int $exitStatus, string $output): void {
$passwordClear = function($user) { $passwordClear = function($user) {
switch ($user) { switch ($user) {
@ -300,7 +312,8 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideOpmlExports */
#[DataProvider('provideOpmlExports')]
public function testExportToOpml(string $cmd, int $exitStatus, string $file, string $user, bool $flat): void { public function testExportToOpml(string $cmd, int $exitStatus, string $file, string $user, bool $flat): void {
$opml = \Phake::mock(OPML::class); $opml = \Phake::mock(OPML::class);
\Phake::when($opml)->exportFile("php://output", $user, $flat)->thenReturn(true); \Phake::when($opml)->exportFile("php://output", $user, $flat)->thenReturn(true);
@ -341,7 +354,8 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideOpmlImports */
#[DataProvider('provideOpmlImports')]
public function testImportFromOpml(string $cmd, int $exitStatus, string $file, string $user, bool $flat, bool $replace): void { public function testImportFromOpml(string $cmd, int $exitStatus, string $file, string $user, bool $flat, bool $replace): void {
$opml = \Phake::mock(OPML::class); $opml = \Phake::mock(OPML::class);
\Phake::when($opml)->importFile("php://input", $user, $flat, $replace)->thenReturn(true); \Phake::when($opml)->importFile("php://input", $user, $flat, $replace)->thenReturn(true);
@ -425,7 +439,8 @@ class TestCLI extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify(Arsse::$user)->propertiesGet("john.doe@example.com"); \Phake::verify(Arsse::$user)->propertiesGet("john.doe@example.com");
} }
/** @dataProvider provideMetadataChanges */
#[DataProvider('provideMetadataChanges')]
public function testSetMetadataOfAUser(string $cmd, string $user, array $in, array $out, int $exp): void { public function testSetMetadataOfAUser(string $cmd, string $user, array $in, array $out, int $exp): void {
Arsse::$user = \Phake::mock(User::class); Arsse::$user = \Phake::mock(User::class);
\Phake::when(Arsse::$user)->propertiesSet->thenReturn($out); \Phake::when(Arsse::$user)->propertiesSet->thenReturn($out);

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -9,8 +10,10 @@ namespace JKingWeb\Arsse\TestCase\Conf;
use JKingWeb\Arsse\Conf; use JKingWeb\Arsse\Conf;
use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStream;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Depends;
/** @covers \JKingWeb\Arsse\Conf */ #[CoversClass(\JKingWeb\Arsse\Conf::class)]
class TestConf extends \JKingWeb\Arsse\Test\AbstractTest { class TestConf extends \JKingWeb\Arsse\Test\AbstractTest {
public static $vfs; public static $vfs;
public static $path; public static $path;
@ -43,7 +46,8 @@ class TestConf extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertInstanceOf(Conf::class, new Conf); $this->assertInstanceOf(Conf::class, new Conf);
} }
/** @depends testLoadDefaultValues */
#[Depends('testLoadDefaultValues')]
public function testImportFromArray(): void { public function testImportFromArray(): void {
$arr = [ $arr = [
'lang' => "xx", 'lang' => "xx",
@ -54,7 +58,8 @@ class TestConf extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertEquals("xx", $conf->lang); $this->assertEquals("xx", $conf->lang);
} }
/** @depends testImportFromArray */
#[Depends('testImportFromArray')]
public function testImportFromFile(): void { public function testImportFromFile(): void {
$conf = new Conf; $conf = new Conf;
$conf->importFile(self::$path."confGood"); $conf->importFile(self::$path."confGood");
@ -63,38 +68,44 @@ class TestConf extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertEquals("xx", $conf->lang); $this->assertEquals("xx", $conf->lang);
} }
/** @depends testImportFromFile */
#[Depends('testImportFromFile')]
public function testImportFromMissingFile(): void { public function testImportFromMissingFile(): void {
$this->assertException("fileMissing", "Conf"); $this->assertException("fileMissing", "Conf");
$conf = new Conf(self::$path."confMissing"); $conf = new Conf(self::$path."confMissing");
} }
/** @depends testImportFromFile */
#[Depends('testImportFromFile')]
public function testImportFromEmptyFile(): void { public function testImportFromEmptyFile(): void {
$this->assertException("fileCorrupt", "Conf"); $this->assertException("fileCorrupt", "Conf");
$conf = new Conf(self::$path."confEmpty"); $conf = new Conf(self::$path."confEmpty");
} }
/** @depends testImportFromFile */
#[Depends('testImportFromFile')]
public function testImportFromFileWithoutReadPermission(): void { public function testImportFromFileWithoutReadPermission(): void {
$this->assertException("fileUnreadable", "Conf"); $this->assertException("fileUnreadable", "Conf");
$conf = new Conf(self::$path."confUnreadable"); $conf = new Conf(self::$path."confUnreadable");
} }
/** @depends testImportFromFile */
#[Depends('testImportFromFile')]
public function testImportFromFileWhichIsNotAnArray(): void { public function testImportFromFileWhichIsNotAnArray(): void {
$this->assertException("fileCorrupt", "Conf"); $this->assertException("fileCorrupt", "Conf");
$conf = new Conf(self::$path."confNotArray"); $conf = new Conf(self::$path."confNotArray");
} }
/** @depends testImportFromFile */
#[Depends('testImportFromFile')]
public function testImportFromFileWhichIsNotPhp(): void { public function testImportFromFileWhichIsNotPhp(): void {
$this->assertException("fileCorrupt", "Conf"); $this->assertException("fileCorrupt", "Conf");
// this should not print the output of the non-PHP file // this should not print the output of the non-PHP file
$conf = new Conf(self::$path."confNotPHP"); $conf = new Conf(self::$path."confNotPHP");
} }
/** @depends testImportFromFile */
#[Depends('testImportFromFile')]
public function testImportFromCorruptFile(): void { public function testImportFromCorruptFile(): void {
$this->assertException("fileCorrupt", "Conf"); $this->assertException("fileCorrupt", "Conf");
$conf = new Conf(self::$path."confCorrupt"); $conf = new Conf(self::$path."confCorrupt");
@ -145,8 +156,8 @@ class TestConf extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertArraySubset($exp, $res); $this->assertArraySubset($exp, $res);
} }
/** @depends testExportToArray #[Depends('testExportToArray')]
* @depends testImportFromFile */ #[Depends('testImportFromFile')]
public function testExportToFile(): void { public function testExportToFile(): void {
$conf = new Conf; $conf = new Conf;
$conf->lang = ["en", "fr"]; // should not be exported: not scalar $conf->lang = ["en", "fr"]; // should not be exported: not scalar
@ -167,7 +178,8 @@ class TestConf extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertArraySubset($exp, $arr); $this->assertArraySubset($exp, $arr);
} }
/** @depends testExportToFile */
#[Depends('testExportToFile')]
public function testExportToStdout(): void { public function testExportToStdout(): void {
$conf = new Conf(self::$path."confGood"); $conf = new Conf(self::$path."confGood");
$conf->exportFile(self::$path."confGood"); $conf->exportFile(self::$path."confGood");

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -55,7 +56,7 @@ abstract class AbstractTest extends \JKingWeb\Arsse\Test\AbstractTest {
// but other engines should clean up from potentially interrupted prior tests // but other engines should clean up from potentially interrupted prior tests
static::setConf(); static::setConf();
try { try {
static::$drv = new static::$dbDriverClass; static::$drv = new static::$dbDriverClass();
} catch (\JKingWeb\Arsse\Db\Exception $e) { } catch (\JKingWeb\Arsse\Db\Exception $e) {
static::$failureReason = $e->getMessage(); static::$failureReason = $e->getMessage();
return; return;

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -9,8 +10,10 @@ namespace JKingWeb\Arsse\TestCase\Database;
use JKingWeb\Arsse\Database; use JKingWeb\Arsse\Database;
use JKingWeb\Arsse\Db\Transaction; use JKingWeb\Arsse\Db\Transaction;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\DataProvider;
/** @coversNothing */ #[CoversNothing]
class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest { class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest {
protected $db = null; protected $db = null;
@ -36,9 +39,9 @@ class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest {
} }
/** /**
* @dataProvider provideInClauses
* @covers \JKingWeb\Arsse\Database::generateIn * @covers \JKingWeb\Arsse\Database::generateIn
*/ */
#[DataProvider('provideInClauses')]
public function testGenerateInClause(string $clause, array $values, array $inV, string $inT): void { public function testGenerateInClause(string $clause, array $values, array $inV, string $inT): void {
$types = array_fill(0, sizeof($values), $inT); $types = array_fill(0, sizeof($values), $inT);
$exp = [$clause, $types, $values]; $exp = [$clause, $types, $values];
@ -73,9 +76,9 @@ class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest {
} }
/** /**
* @dataProvider provideSearchClauses
* @covers \JKingWeb\Arsse\Database::generateSearch * @covers \JKingWeb\Arsse\Database::generateSearch
*/ */
#[DataProvider('provideSearchClauses')]
public function testGenerateSearchClause(string $clause, array $values, array $inV, array $inC, bool $inAny): void { public function testGenerateSearchClause(string $clause, array $values, array $inV, array $inC, bool $inAny): void {
// this is not an exhaustive test; integration tests already cover the ins and outs of the functionality // this is not an exhaustive test; integration tests already cover the ins and outs of the functionality
$types = array_fill(0, sizeof($values), "str"); $types = array_fill(0, sizeof($values), "str");

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -43,7 +44,7 @@ abstract class BaseDriver extends \JKingWeb\Arsse\Test\AbstractTest {
"INSERT INTO arsse_meta(\"key\",value) values('schema_version','0')", "INSERT INTO arsse_meta(\"key\",value) values('schema_version','0')",
]); ]);
// construct a fresh driver for each test // construct a fresh driver for each test
$this->drv = new static::$dbDriverClass; $this->drv = new static::$dbDriverClass();
} }
public function tearDown(): void { public function tearDown(): void {

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -8,6 +9,7 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Db; namespace JKingWeb\Arsse\TestCase\Db;
use JKingWeb\Arsse\Db\Statement; use JKingWeb\Arsse\Db\Statement;
use PHPUnit\Framework\Attributes\DataProvider;
abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest { abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest {
protected static $interface; protected static $interface;
@ -47,7 +49,8 @@ abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertInstanceOf(Statement::class, new $this->statementClass(...$this->makeStatement("SELECT ? as value"))); $this->assertInstanceOf(Statement::class, new $this->statementClass(...$this->makeStatement("SELECT ? as value")));
} }
/** @dataProvider provideBindings */
#[DataProvider('provideBindings')]
public function testBindATypedValue($value, string $type, string $exp): void { public function testBindATypedValue($value, string $type, string $exp): void {
if ($exp === "null") { if ($exp === "null") {
$query = "SELECT (? is null) as pass"; $query = "SELECT (? is null) as pass";
@ -60,7 +63,8 @@ abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertTrue((bool) $act); $this->assertTrue((bool) $act);
} }
/** @dataProvider provideBinaryBindings */
#[DataProvider('provideBinaryBindings')]
public function testHandleBinaryData($value, string $type, string $exp): void { public function testHandleBinaryData($value, string $type, string $exp): void {
if ($exp === "null") { if ($exp === "null") {
$query = "SELECT (? is null) as pass"; $query = "SELECT (? is null) as pass";

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -33,7 +34,7 @@ class BaseUpdate extends \JKingWeb\Arsse\Test\AbstractTest {
parent::setUp(); parent::setUp();
self::setConf(); self::setConf();
// construct a fresh driver for each test // construct a fresh driver for each test
$this->drv = new static::$dbDriverClass; $this->drv = new static::$dbDriverClass();
$schemaId = (get_class($this->drv))::schemaID(); $schemaId = (get_class($this->drv))::schemaID();
// set up a virtual filesystem for schema files // set up a virtual filesystem for schema files
$this->vfs = vfsStream::setup("schemata", null, [$schemaId => []]); $this->vfs = vfsStream::setup("schemata", null, [$schemaId => []]);

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -7,11 +8,12 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Db\MySQL; namespace JKingWeb\Arsse\TestCase\Db\MySQL;
/** use PHPUnit\Framework\Attributes\Group;
* @group slow use PHPUnit\Framework\Attributes\CoversNothing;
* @group coverageOptional
* @coversNothing #[Group('slow')]
*/ #[Group('coverageOptional')]
#[CoversNothing]
class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest {
use \JKingWeb\Arsse\Test\DatabaseDrivers\MySQL; use \JKingWeb\Arsse\Test\DatabaseDrivers\MySQL;

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -7,12 +8,13 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Db\MySQLPDO; namespace JKingWeb\Arsse\TestCase\Db\MySQLPDO;
/** use PHPUnit\Framework\Attributes\Group;
* @group slow use PHPUnit\Framework\Attributes\CoversNothing;
* @group optional
* @group coverageOptional #[Group('slow')]
* @coversNothing #[Group('optional')]
*/ #[Group('coverageOptional')]
#[CoversNothing]
class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest {
use \JKingWeb\Arsse\Test\DatabaseDrivers\MySQLPDO; use \JKingWeb\Arsse\Test\DatabaseDrivers\MySQLPDO;

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -7,11 +8,12 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Db\PostgreSQL; namespace JKingWeb\Arsse\TestCase\Db\PostgreSQL;
/** use PHPUnit\Framework\Attributes\Group;
* @group slow use PHPUnit\Framework\Attributes\CoversNothing;
* @group coverageOptional
* @coversNothing #[Group('slow')]
*/ #[Group('coverageOptional')]
#[CoversNothing]
class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest {
use \JKingWeb\Arsse\Test\DatabaseDrivers\PostgreSQL; use \JKingWeb\Arsse\Test\DatabaseDrivers\PostgreSQL;

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -7,12 +8,13 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Db\PostgreSQLPDO; namespace JKingWeb\Arsse\TestCase\Db\PostgreSQLPDO;
/** use PHPUnit\Framework\Attributes\Group;
* @group slow use PHPUnit\Framework\Attributes\CoversNothing;
* @group optional
* @group coverageOptional #[Group('slow')]
* @coversNothing #[Group('optional')]
*/ #[Group('coverageOptional')]
#[CoversNothing]
class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest {
use \JKingWeb\Arsse\Test\DatabaseDrivers\PostgreSQLPDO; use \JKingWeb\Arsse\Test\DatabaseDrivers\PostgreSQLPDO;

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -7,10 +8,11 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Db\SQLite3; namespace JKingWeb\Arsse\TestCase\Db\SQLite3;
/** use PHPUnit\Framework\Attributes\Group;
* @group optional use PHPUnit\Framework\Attributes\CoversNothing;
* @coversNothing
*/ #[Group('optional')]
#[CoversNothing]
class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest {
use \JKingWeb\Arsse\Test\DatabaseDrivers\SQLite3; use \JKingWeb\Arsse\Test\DatabaseDrivers\SQLite3;

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -7,9 +8,9 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Db\SQLite3PDO; namespace JKingWeb\Arsse\TestCase\Db\SQLite3PDO;
/** use PHPUnit\Framework\Attributes\CoversNothing;
* @coversNothing
*/ #[CoversNothing]
class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest {
use \JKingWeb\Arsse\Test\DatabaseDrivers\SQLite3PDO; use \JKingWeb\Arsse\Test\DatabaseDrivers\SQLite3PDO;

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -9,9 +10,9 @@ namespace JKingWeb\Arsse\TestCase\Db;
use JKingWeb\Arsse\Db\Transaction; use JKingWeb\Arsse\Db\Transaction;
use JKingWeb\Arsse\Db\Exception; use JKingWeb\Arsse\Db\Exception;
use PHPUnit\Framework\Attributes\CoversClass;
/** #[CoversClass(\JKingWeb\Arsse\Db\Transaction::class)]
* @covers \JKingWeb\Arsse\Db\Transaction */
class TestTransaction extends \JKingWeb\Arsse\Test\AbstractTest { class TestTransaction extends \JKingWeb\Arsse\Test\AbstractTest {
protected $drv; protected $drv;

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -11,8 +12,10 @@ use JKingWeb\Arsse\Arsse;
use JKingWeb\Arsse\Lang; use JKingWeb\Arsse\Lang;
use JKingWeb\Arsse\Exception; use JKingWeb\Arsse\Exception;
use JKingWeb\Arsse\Lang\Exception as LangException; use JKingWeb\Arsse\Lang\Exception as LangException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Depends;
/** @covers \JKingWeb\Arsse\AbstractException */ #[CoversClass(\JKingWeb\Arsse\AbstractException::class)]
class TestException extends \JKingWeb\Arsse\Test\AbstractTest { class TestException extends \JKingWeb\Arsse\Test\AbstractTest {
public function setUp(): void { public function setUp(): void {
self::clearData(false); self::clearData(false);
@ -26,41 +29,31 @@ class TestException extends \JKingWeb\Arsse\Test\AbstractTest {
throw new Exception("unknown"); throw new Exception("unknown");
} }
/** #[Depends('testBaseClass')]
* @depends testBaseClass
*/
public function testBaseClassWithoutMessage(): void { public function testBaseClassWithoutMessage(): void {
$this->assertException("unknown"); $this->assertException("unknown");
throw new Exception(); throw new Exception;
} }
/** #[Depends('testBaseClass')]
* @depends testBaseClass
*/
public function testDerivedClass(): void { public function testDerivedClass(): void {
$this->assertException("fileMissing", "Lang"); $this->assertException("fileMissing", "Lang");
throw new LangException("fileMissing"); throw new LangException("fileMissing");
} }
/** #[Depends('testDerivedClass')]
* @depends testDerivedClass
*/
public function testDerivedClassWithMessageParameters(): void { public function testDerivedClassWithMessageParameters(): void {
$this->assertException("fileMissing", "Lang"); $this->assertException("fileMissing", "Lang");
throw new LangException("fileMissing", "en"); throw new LangException("fileMissing", "en");
} }
/** #[Depends('testBaseClass')]
* @depends testBaseClass
*/
public function testBaseClassWithUnknownCode(): void { public function testBaseClassWithUnknownCode(): void {
$this->assertException("uncoded"); $this->assertException("uncoded");
throw new Exception("testThisExceptionMessageDoesNotExist"); throw new Exception("testThisExceptionMessageDoesNotExist");
} }
/** #[Depends('testBaseClassWithUnknownCode')]
* @depends testBaseClassWithUnknownCode
*/
public function testDerivedClassWithMissingMessage(): void { public function testDerivedClassWithMissingMessage(): void {
$this->assertException("uncoded"); $this->assertException("uncoded");
throw new LangException("testThisExceptionMessageDoesNotExist"); throw new LangException("testThisExceptionMessageDoesNotExist");

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -11,13 +12,15 @@ use GuzzleHttp\Exception\BadResponseException;
use GuzzleHttp\Exception\TooManyRedirectsException; use GuzzleHttp\Exception\TooManyRedirectsException;
use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Exception\TransferException;
use JKingWeb\Arsse\Feed\Exception as FeedException; use JKingWeb\Arsse\Feed\Exception as FeedException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PicoFeed\PicoFeedException; use PicoFeed\PicoFeedException;
/** #[CoversClass(\JKingWeb\Arsse\Feed\Exception::class)]
* @covers \JKingWeb\Arsse\Feed\Exception #[Group('slow')]
* @group slow */
class TestException extends \JKingWeb\Arsse\Test\AbstractTest { class TestException extends \JKingWeb\Arsse\Test\AbstractTest {
/** @dataProvider provideCurlErrors */ #[DataProvider('provideCurlErrors')]
public function testHandleCurlErrors(int $code, string $message): void { public function testHandleCurlErrors(int $code, string $message): void {
$e = $this->mockGuzzleException(TransferException::class, "cURL error $code: Some message", 0); $e = $this->mockGuzzleException(TransferException::class, "cURL error $code: Some message", 0);
$this->assertException($message, "Feed"); $this->assertException($message, "Feed");
@ -116,7 +119,8 @@ class TestException extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideHTTPErrors */
#[DataProvider('provideHTTPErrors')]
public function testHandleHttpErrors(int $code, string $message): void { public function testHandleHttpErrors(int $code, string $message): void {
$e = $this->mockGuzzleException(BadResponseException::class, "Irrelevant message", $code); $e = $this->mockGuzzleException(BadResponseException::class, "Irrelevant message", $code);
$this->assertException($message, "Feed"); $this->assertException($message, "Feed");
@ -143,7 +147,8 @@ class TestException extends \JKingWeb\Arsse\Test\AbstractTest {
return $out; return $out;
} }
/** @dataProvider providePicoFeedException */
#[DataProvider('providePicoFeedException')]
public function testHandlePicofeedException(PicoFeedException $e, string $message) { public function testHandlePicofeedException(PicoFeedException $e, string $message) {
$this->assertException($message, "Feed"); $this->assertException($message, "Feed");
throw new FeedException("", ['url' => "https://example.com/"], $e); throw new FeedException("", ['url' => "https://example.com/"], $e);
@ -171,7 +176,7 @@ class TestException extends \JKingWeb\Arsse\Test\AbstractTest {
} }
public function testHandleUnexpectedError() { public function testHandleUnexpectedError() {
$e = new \Exception; $e = new \Exception();
$this->assertException("internalError", "Feed"); $this->assertException("internalError", "Feed");
throw new FeedException("", ['url' => "https://example.com/"], $e); throw new FeedException("", ['url' => "https://example.com/"], $e);
} }

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -12,10 +13,12 @@ use JKingWeb\Arsse\Feed;
use JKingWeb\Arsse\Database; use JKingWeb\Arsse\Database;
use JKingWeb\Arsse\Misc\Date; use JKingWeb\Arsse\Misc\Date;
use JKingWeb\Arsse\Test\Result; use JKingWeb\Arsse\Test\Result;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
/** #[CoversClass(\JKingWeb\Arsse\Feed::class)]
* @covers \JKingWeb\Arsse\Feed #[Group('slow')]
* @group slow */
class TestFeed extends \JKingWeb\Arsse\Test\AbstractTest { class TestFeed extends \JKingWeb\Arsse\Test\AbstractTest {
protected static $host = "http://localhost:8000/"; protected static $host = "http://localhost:8000/";
protected $base = ""; protected $base = "";
@ -224,7 +227,8 @@ class TestFeed extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame("http://example.com/1", $f->newItems[0]->url); $this->assertSame("http://example.com/1", $f->newItems[0]->url);
} }
/** @dataProvider provide304ResponseURLs */
#[DataProvider('provide304ResponseURLs')]
public function testHandleCacheHeadersOn304(string $url): void { public function testHandleCacheHeadersOn304(string $url): void {
// upon 304, the client should re-use the caching header values it supplied to the server // upon 304, the client should re-use the caching header values it supplied to the server
$t = Date::transform("2010-01-01T00:00:00Z", "unix"); $t = Date::transform("2010-01-01T00:00:00Z", "unix");
@ -284,7 +288,8 @@ class TestFeed extends \JKingWeb\Arsse\Test\AbstractTest {
} }
} }
/** @dataProvider provide304Timestamps */
#[DataProvider('provide304Timestamps')]
public function testComputeNextFetchFrom304(string $t, string $exp): void { public function testComputeNextFetchFrom304(string $t, string $exp): void {
$t = $t ? strtotime($t) : ""; $t = $t ? strtotime($t) : "";
$f = new Feed(null, $this->base."NextFetch/NotModified?t=$t", Date::transform($t, "http")); $f = new Feed(null, $this->base."NextFetch/NotModified?t=$t", Date::transform($t, "http"));

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -9,10 +10,11 @@ namespace JKingWeb\Arsse\TestCase\Feed;
use JKingWeb\Arsse\Arsse; use JKingWeb\Arsse\Arsse;
use JKingWeb\Arsse\Feed; use JKingWeb\Arsse\Feed;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
/** #[CoversClass(\JKingWeb\Arsse\Feed::class)]
* @covers \JKingWeb\Arsse\Feed #[Group('slow')]
* @group slow */
class TestFetching extends \JKingWeb\Arsse\Test\AbstractTest { class TestFetching extends \JKingWeb\Arsse\Test\AbstractTest {
protected static $host = "http://localhost:8000/"; protected static $host = "http://localhost:8000/";
protected $base = ""; protected $base = "";

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -10,8 +11,10 @@ namespace JKingWeb\Arsse\TestCase\ImportExport;
use JKingWeb\Arsse\ImportExport\AbstractImportExport; use JKingWeb\Arsse\ImportExport\AbstractImportExport;
use JKingWeb\Arsse\ImportExport\Exception; use JKingWeb\Arsse\ImportExport\Exception;
use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStream;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
/** @covers \JKingWeb\Arsse\ImportExport\AbstractImportExport */ #[CoversClass(\JKingWeb\Arsse\ImportExport\AbstractImportExport::class)]
class TestFile extends \JKingWeb\Arsse\Test\AbstractTest { class TestFile extends \JKingWeb\Arsse\Test\AbstractTest {
protected $vfs; protected $vfs;
protected $path; protected $path;
@ -45,7 +48,8 @@ class TestFile extends \JKingWeb\Arsse\Test\AbstractTest {
parent::tearDown(); parent::tearDown();
} }
/** @dataProvider provideFileExports */
#[DataProvider('provideFileExports')]
public function testExportToAFile(string $file, string $user, bool $flat, $exp): void { public function testExportToAFile(string $file, string $user, bool $flat, $exp): void {
$path = $this->path.$file; $path = $this->path.$file;
try { try {
@ -84,7 +88,8 @@ class TestFile extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideFileImports */
#[DataProvider('provideFileImports')]
public function testImportFromAFile(string $file, string $user, bool $flat, bool $replace, $exp): void { public function testImportFromAFile(string $file, string $user, bool $flat, bool $replace, $exp): void {
$path = $this->path.$file; $path = $this->path.$file;
try { try {

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -11,8 +12,9 @@ use JKingWeb\Arsse\Arsse;
use JKingWeb\Arsse\Db\SQLite3\Driver; use JKingWeb\Arsse\Db\SQLite3\Driver;
use JKingWeb\Arsse\ImportExport\AbstractImportExport; use JKingWeb\Arsse\ImportExport\AbstractImportExport;
use JKingWeb\Arsse\Test\Database; use JKingWeb\Arsse\Test\Database;
use PHPUnit\Framework\Attributes\CoversClass;
/** @covers \JKingWeb\Arsse\ImportExport\AbstractImportExport */ #[CoversClass(\JKingWeb\Arsse\ImportExport\AbstractImportExport::class)]
class TestImportExport extends \JKingWeb\Arsse\Test\AbstractTest { class TestImportExport extends \JKingWeb\Arsse\Test\AbstractTest {
protected $drv; protected $drv;
protected $proc; protected $proc;

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -8,8 +9,10 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Lang; namespace JKingWeb\Arsse\TestCase\Lang;
use JKingWeb\Arsse\Lang as TestClass; use JKingWeb\Arsse\Lang as TestClass;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Depends;
/** @covers \JKingWeb\Arsse\Lang */ #[CoversClass(\JKingWeb\Arsse\Lang::class)]
class TestBasic extends \JKingWeb\Arsse\Test\AbstractTest { class TestBasic extends \JKingWeb\Arsse\Test\AbstractTest {
use \JKingWeb\Arsse\Test\Lang\Setup; use \JKingWeb\Arsse\Test\Lang\Setup;
@ -21,9 +24,7 @@ class TestBasic extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertCount(sizeof($this->files), $this->l->list("en")); $this->assertCount(sizeof($this->files), $this->l->list("en"));
} }
/** #[Depends('testListLanguages')]
* @depends testListLanguages
*/
public function testSetLanguage(): void { public function testSetLanguage(): void {
$this->assertEquals("en", $this->l->set("en")); $this->assertEquals("en", $this->l->set("en"));
$this->assertEquals("en_ca", $this->l->set("en_ca")); $this->assertEquals("en_ca", $this->l->set("en_ca"));
@ -34,18 +35,14 @@ class TestBasic extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertEquals("", $this->l->set("")); $this->assertEquals("", $this->l->set(""));
} }
/** #[Depends('testSetLanguage')]
* @depends testSetLanguage
*/
public function testLoadInternalStrings(): void { public function testLoadInternalStrings(): void {
$exp = (new \ReflectionClassConstant(TestClass::class, "REQUIRED"))->getValue(); $exp = (new \ReflectionClassConstant(TestClass::class, "REQUIRED"))->getValue();
$this->assertEquals("", $this->l->set("", true)); $this->assertEquals("", $this->l->set("", true));
$this->assertCount(sizeof($exp), $this->l->dump()); $this->assertCount(sizeof($exp), $this->l->dump());
} }
/** #[Depends('testLoadInternalStrings')]
* @depends testLoadInternalStrings
*/
public function testLoadDefaultLanguage(): void { public function testLoadDefaultLanguage(): void {
$this->assertEquals(TestClass::DEFAULT, $this->l->set(TestClass::DEFAULT, true)); $this->assertEquals(TestClass::DEFAULT, $this->l->set(TestClass::DEFAULT, true));
$str = $this->l->dump(); $str = $this->l->dump();
@ -53,9 +50,7 @@ class TestBasic extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertArrayHasKey('Test.presentText', $str); $this->assertArrayHasKey('Test.presentText', $str);
} }
/** #[Depends('testLoadDefaultLanguage')]
* @depends testLoadDefaultLanguage
*/
public function testLoadSupplementaryLanguage(): void { public function testLoadSupplementaryLanguage(): void {
$this->l->set(TestClass::DEFAULT, true); $this->l->set(TestClass::DEFAULT, true);
$this->assertEquals("ja", $this->l->set("ja", true)); $this->assertEquals("ja", $this->l->set("ja", true));

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -8,8 +9,10 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Lang; namespace JKingWeb\Arsse\TestCase\Lang;
use JKingWeb\Arsse\Lang as TestClass; use JKingWeb\Arsse\Lang as TestClass;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Depends;
/** @covers \JKingWeb\Arsse\Lang */ #[CoversClass(\JKingWeb\Arsse\Lang::class)]
class TestComplex extends \JKingWeb\Arsse\Test\AbstractTest { class TestComplex extends \JKingWeb\Arsse\Test\AbstractTest {
use \JKingWeb\Arsse\Test\Lang\Setup; use \JKingWeb\Arsse\Test\Lang\Setup;
@ -26,9 +29,7 @@ class TestComplex extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertArrayNotHasKey('Test.absentText', $this->l->dump()); $this->assertArrayNotHasKey('Test.absentText', $this->l->dump());
} }
/** #[Depends('testLazyLoad')]
* @depends testLazyLoad
*/
public function testGetWantedAndLoadedLocale(): void { public function testGetWantedAndLoadedLocale(): void {
$this->l->set("en", true); $this->l->set("en", true);
$this->l->set("ja"); $this->l->set("ja");
@ -44,9 +45,7 @@ class TestComplex extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertEquals('und der Stein der Weisen', $str['Test.presentText']); $this->assertEquals('und der Stein der Weisen', $str['Test.presentText']);
} }
/** #[Depends('testLoadCascadeOfFiles')]
* @depends testLoadCascadeOfFiles
*/
public function testLoadSubtag(): void { public function testLoadSubtag(): void {
$this->assertEquals("en_ca", $this->l->set("en_ca", true)); $this->assertEquals("en_ca", $this->l->set("en_ca", true));
} }
@ -56,49 +55,37 @@ class TestComplex extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertEquals('und der Stein der Weisen', $this->l->msg('Test.presentText')); $this->assertEquals('und der Stein der Weisen', $this->l->msg('Test.presentText'));
} }
/** #[Depends('testFetchAMessage')]
* @depends testFetchAMessage
*/
public function testFetchAMessageWithMissingParameters(): void { public function testFetchAMessageWithMissingParameters(): void {
$this->l->set("en_ca", true); $this->l->set("en_ca", true);
$this->assertEquals('{0} and {1}', $this->l->msg('Test.presentText')); $this->assertEquals('{0} and {1}', $this->l->msg('Test.presentText'));
} }
/** #[Depends('testFetchAMessage')]
* @depends testFetchAMessage
*/
public function testFetchAMessageWithSingleNumericParameter(): void { public function testFetchAMessageWithSingleNumericParameter(): void {
$this->l->set("en_ca", true); $this->l->set("en_ca", true);
$this->assertEquals('Default language file "en" missing', $this->l->msg('Exception.JKingWeb/Arsse/Lang/Exception.defaultFileMissing', TestClass::DEFAULT)); $this->assertEquals('Default language file "en" missing', $this->l->msg('Exception.JKingWeb/Arsse/Lang/Exception.defaultFileMissing', TestClass::DEFAULT));
} }
/** #[Depends('testFetchAMessage')]
* @depends testFetchAMessage
*/
public function testFetchAMessageWithMultipleNumericParameters(): void { public function testFetchAMessageWithMultipleNumericParameters(): void {
$this->l->set("en_ca", true); $this->l->set("en_ca", true);
$this->assertEquals('Happy Rotter and the Philosopher\'s Stone', $this->l->msg('Test.presentText', ['Happy Rotter', 'the Philosopher\'s Stone'])); $this->assertEquals('Happy Rotter and the Philosopher\'s Stone', $this->l->msg('Test.presentText', ['Happy Rotter', 'the Philosopher\'s Stone']));
} }
/** #[Depends('testFetchAMessage')]
* @depends testFetchAMessage
*/
public function testFetchAMessageWithNamedParameters(): void { public function testFetchAMessageWithNamedParameters(): void {
$this->assertEquals('Message string "Test.absentText" missing from all loaded language files (en)', $this->l->msg('Exception.JKingWeb/Arsse/Lang/Exception.stringMissing', ['msgID' => 'Test.absentText', 'fileList' => 'en'])); $this->assertEquals('Message string "Test.absentText" missing from all loaded language files (en)', $this->l->msg('Exception.JKingWeb/Arsse/Lang/Exception.stringMissing', ['msgID' => 'Test.absentText', 'fileList' => 'en']));
} }
/** #[Depends('testFetchAMessage')]
* @depends testFetchAMessage
*/
public function testReloadDefaultStrings(): void { public function testReloadDefaultStrings(): void {
$this->l->set("de", true); $this->l->set("de", true);
$this->l->set("en", true); $this->l->set("en", true);
$this->assertEquals('and the Philosopher\'s Stone', $this->l->msg('Test.presentText')); $this->assertEquals('and the Philosopher\'s Stone', $this->l->msg('Test.presentText'));
} }
/** #[Depends('testFetchAMessage')]
* @depends testFetchAMessage
*/
public function testReloadGeneralTagAfterSubtag(): void { public function testReloadGeneralTagAfterSubtag(): void {
$this->l->set("en", true); $this->l->set("en", true);
$this->l->set("en_us", true); $this->l->set("en_us", true);

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -8,8 +9,9 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Lang; namespace JKingWeb\Arsse\TestCase\Lang;
use JKingWeb\Arsse\Lang as TestClass; use JKingWeb\Arsse\Lang as TestClass;
use PHPUnit\Framework\Attributes\CoversClass;
/** @covers \JKingWeb\Arsse\Lang */ #[CoversClass(\JKingWeb\Arsse\Lang::class)]
class TestErrors extends \JKingWeb\Arsse\Test\AbstractTest { class TestErrors extends \JKingWeb\Arsse\Test\AbstractTest {
use \JKingWeb\Arsse\Test\Lang\Setup; use \JKingWeb\Arsse\Test\Lang\Setup;

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -8,8 +9,9 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Misc; namespace JKingWeb\Arsse\TestCase\Misc;
use JKingWeb\Arsse\Misc\Date; use JKingWeb\Arsse\Misc\Date;
use PHPUnit\Framework\Attributes\CoversClass;
/** @covers \JKingWeb\Arsse\Misc\Date */ #[CoversClass(\JKingWeb\Arsse\Misc\Date::class)]
class TestDate extends \JKingWeb\Arsse\Test\AbstractTest { class TestDate extends \JKingWeb\Arsse\Test\AbstractTest {
public function testNormalizeADate(): void { public function testNormalizeADate(): void {
$exp = new \DateTimeImmutable("2018-01-01T00:00:00Z"); $exp = new \DateTimeImmutable("2018-01-01T00:00:00Z");

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -8,8 +9,9 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Misc; namespace JKingWeb\Arsse\TestCase\Misc;
use JKingWeb\Arsse\Factory; use JKingWeb\Arsse\Factory;
use PHPUnit\Framework\Attributes\CoversClass;
/** @covers \JKingWeb\Arsse\Factory */ #[CoversClass(\JKingWeb\Arsse\Factory::class)]
class TestFactory extends \JKingWeb\Arsse\Test\AbstractTest { class TestFactory extends \JKingWeb\Arsse\Test\AbstractTest {
public function testInstantiateAClass(): void { public function testInstantiateAClass(): void {
$f = new Factory; $f = new Factory;

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -10,11 +11,13 @@ namespace JKingWeb\Arsse\TestCase\Misc;
use JKingWeb\Arsse\Misc\HTTP; use JKingWeb\Arsse\Misc\HTTP;
use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
/** @covers \JKingWeb\Arsse\Misc\HTTP */ #[CoversClass(\JKingWeb\Arsse\Misc\HTTP::class)]
class TestHTTP extends \JKingWeb\Arsse\Test\AbstractTest { class TestHTTP extends \JKingWeb\Arsse\Test\AbstractTest {
/** @dataProvider provideMediaTypes */ #[DataProvider('provideMediaTypes')]
public function testMatchMediaType(string $header, array $types, bool $exp): void { public function testMatchMediaType(string $header, array $types, bool $exp): void {
$msg = (new Request("POST", "/"))->withHeader("Content-Type", $header); $msg = (new Request("POST", "/"))->withHeader("Content-Type", $header);
$this->assertSame($exp, HTTP::matchType($msg, ...$types)); $this->assertSame($exp, HTTP::matchType($msg, ...$types));
@ -36,7 +39,8 @@ class TestHTTP extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideTypedMessages */
#[DataProvider('provideTypedMessages')]
public function testCreateResponses(string $type, array $params, ResponseInterface $exp): void { public function testCreateResponses(string $type, array $params, ResponseInterface $exp): void {
$act = call_user_func(["JKingWeb\\Arsse\\Misc\\HTTP", $type], ...$params); $act = call_user_func(["JKingWeb\\Arsse\\Misc\\HTTP", $type], ...$params);
$this->assertMessage($exp, $act); $this->assertMessage($exp, $act);

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -9,11 +10,10 @@ namespace JKingWeb\Arsse\TestCase\Misc;
use JKingWeb\Arsse\Misc\Query; use JKingWeb\Arsse\Misc\Query;
use JKingWeb\Arsse\Misc\QueryFilter; use JKingWeb\Arsse\Misc\QueryFilter;
use PHPUnit\Framework\Attributes\CoversClass;
/** #[CoversClass(\JKingWeb\Arsse\Misc\Query::class)]
* @covers \JKingWeb\Arsse\Misc\Query #[CoversClass(\JKingWeb\Arsse\Misc\QueryFilter::class)]
* @covers \JKingWeb\Arsse\Misc\QueryFilter
*/
class TestQuery extends \JKingWeb\Arsse\Test\AbstractTest { class TestQuery extends \JKingWeb\Arsse\Test\AbstractTest {
public function testBasicQuery(): void { public function testBasicQuery(): void {
$q = new Query("select * from table where a = ?", "int", 3); $q = new Query("select * from table where a = ?", "int", 3);

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -8,8 +9,10 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Misc; namespace JKingWeb\Arsse\TestCase\Misc;
use JKingWeb\Arsse\Rule\Rule; use JKingWeb\Arsse\Rule\Rule;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
/** @covers \JKingWeb\Arsse\Rule\Rule */ #[CoversClass(\JKingWeb\Arsse\Rule\Rule::class)]
class TestRule extends \JKingWeb\Arsse\Test\AbstractTest { class TestRule extends \JKingWeb\Arsse\Test\AbstractTest {
public function testPrepareAPattern(): void { public function testPrepareAPattern(): void {
$exp = "`\\`..\\`..\\`..\\\\\\`..`u"; $exp = "`\\`..\\`..\\`..\\\\\\`..`u";
@ -28,7 +31,8 @@ class TestRule extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertSame("", Rule::prep("")); $this->assertSame("", Rule::prep(""));
} }
/** @dataProvider provideApplications */
#[DataProvider('provideApplications')]
public function testApplyRules(string $keepRule, string $blockRule, string $title, array $categories, $exp): void { public function testApplyRules(string $keepRule, string $blockRule, string $title, array $categories, $exp): void {
$keepRule = Rule::prep($keepRule); $keepRule = Rule::prep($keepRule);
$blockRule = Rule::prep($blockRule); $blockRule = Rule::prep($blockRule);

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -8,10 +9,12 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Misc; namespace JKingWeb\Arsse\TestCase\Misc;
use JKingWeb\Arsse\Misc\URL; use JKingWeb\Arsse\Misc\URL;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
/** @covers \JKingWeb\Arsse\Misc\URL */ #[CoversClass(\JKingWeb\Arsse\Misc\URL::class)]
class TestURL extends \JKingWeb\Arsse\Test\AbstractTest { class TestURL extends \JKingWeb\Arsse\Test\AbstractTest {
/** @dataProvider provideNormalizations */ #[DataProvider('provideNormalizations')]
public function testNormalizeAUrl(string $url, string $exp, ?string $user = null, ?string $pass = null): void { public function testNormalizeAUrl(string $url, string $exp, ?string $user = null, ?string $pass = null): void {
$this->assertSame($exp, URL::normalize($url, $user, $pass)); $this->assertSame($exp, URL::normalize($url, $user, $pass));
} }
@ -73,7 +76,8 @@ class TestURL extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideQueries */
#[DataProvider('provideQueries')]
public function testAppendQueryParameters(string $url, string $query, string $exp): void { public function testAppendQueryParameters(string $url, string $query, string $exp): void {
$this->assertSame($exp, URL::queryAppend($url, $query)); $this->assertSame($exp, URL::queryAppend($url, $query));
} }
@ -89,7 +93,8 @@ class TestURL extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideAbsolutes */
#[DataProvider('provideAbsolutes')]
public function testDetermineAbsoluteness(bool $exp, string $url): void { public function testDetermineAbsoluteness(bool $exp, string $url): void {
$this->assertSame($exp, URL::absolute($url)); $this->assertSame($exp, URL::absolute($url));
} }

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -10,8 +11,9 @@ namespace JKingWeb\Arsse\TestCase\Misc;
use JKingWeb\Arsse\Misc\ValueInfo as I; use JKingWeb\Arsse\Misc\ValueInfo as I;
use JKingWeb\Arsse\Test\Misc\StrClass; use JKingWeb\Arsse\Test\Misc\StrClass;
use JKingWeb\Arsse\Test\Result; use JKingWeb\Arsse\Test\Result;
use PHPUnit\Framework\Attributes\DataProvider;
/** @covers \JKingWeb\Arsse\Misc\ValueInfo */ #[CoversClass(\JKingWeb\Arsse\Misc\ValueInfo::class)]
class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest { class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
public function testGetIntegerInfo(): void { public function testGetIntegerInfo(): void {
$tests = [ $tests = [
@ -70,7 +72,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[[], 0], [[], 0],
["some string", 0], ["some string", 0],
[" ", 0], [" ", 0],
[new \StdClass, 0], [new \StdClass(), 0],
[new StrClass(""), I::NULL], [new StrClass(""), I::NULL],
[new StrClass("1"), I::VALID], [new StrClass("1"), I::VALID],
[new StrClass("0"), I::VALID | I::ZERO], [new StrClass("0"), I::VALID | I::ZERO],
@ -145,7 +147,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[[], 0], [[], 0],
["some string", I::VALID], ["some string", I::VALID],
[" ", I::VALID | I::WHITE], [" ", I::VALID | I::WHITE],
[new \StdClass, 0], [new \StdClass(), 0],
[new StrClass(""), I::VALID | I::EMPTY], [new StrClass(""), I::VALID | I::EMPTY],
[new StrClass("1"), I::VALID], [new StrClass("1"), I::VALID],
[new StrClass("0"), I::VALID], [new StrClass("0"), I::VALID],
@ -216,7 +218,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[[], false, false], [[], false, false],
["some string", false, false], ["some string", false, false],
[" ", false, false], [" ", false, false],
[new \StdClass, false, false], [new \StdClass(), false, false],
[new StrClass(""), false, true], [new StrClass(""), false, true],
[new StrClass("1"), true, true], [new StrClass("1"), true, true],
[new StrClass("0"), false, true], [new StrClass("0"), false, true],
@ -288,7 +290,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[[], null], [[], null],
["some string", null], ["some string", null],
[" ", null], [" ", null],
[new \StdClass, null], [new \StdClass(), null],
[new StrClass(""), false], [new StrClass(""), false],
[new StrClass("1"), true], [new StrClass("1"), true],
[new StrClass("0"), false], [new StrClass("0"), false],
@ -306,7 +308,8 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
} }
} }
/** @dataProvider provideSimpleNormalizationValues */
#[DataProvider('provideSimpleNormalizationValues')]
public function testNormalizeSimpleValues($input, string $typeName, $exp, bool $pass, bool $strict, bool $drop): void { public function testNormalizeSimpleValues($input, string $typeName, $exp, bool $pass, bool $strict, bool $drop): void {
$assert = function($exp, $act, string $msg) { $assert = function($exp, $act, string $msg) {
if (is_null($exp)) { if (is_null($exp)) {
@ -365,7 +368,8 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
} }
} }
/** @dataProvider provideDateNormalizationValues */
#[DataProvider('provideDateNormalizationValues')]
public function testNormalizeDateValues($input, $format, $exp, bool $strict, bool $drop): void { public function testNormalizeDateValues($input, $format, $exp, bool $strict, bool $drop): void {
if ($strict && $drop) { if ($strict && $drop) {
$modeName = "strict drop"; $modeName = "strict drop";
@ -511,7 +515,7 @@ class TestValueInfo extends \JKingWeb\Arsse\Test\AbstractTest {
[[], [null,true], [false,false], [0, false], [0.0, false], ["", false], [[], true], [null, false]], [[], [null,true], [false,false], [0, false], [0.0, false], ["", false], [[], true], [null, false]],
["some string", [null,true], [true, false], [0, false], [0.0, false], ["some string", true], [["some string"], false], [null, false]], ["some string", [null,true], [true, false], [0, false], [0.0, false], ["some string", true], [["some string"], false], [null, false]],
[" ", [null,true], [true, false], [0, false], [0.0, false], [" ", true], [[" "], false], [null, false]], [" ", [null,true], [true, false], [0, false], [0.0, false], [" ", true], [[" "], false], [null, false]],
[new \StdClass, [null,true], [true, false], [0, false], [0.0, false], ["", false], [[new \StdClass], false], [null, false]], [new \StdClass(), [null,true], [true, false], [0, false], [0.0, false], ["", false], [[new \StdClass()], false], [null, false]],
[new StrClass(""), [null,true], [false,true], [0, false], [0.0, false], ["", true], [[new StrClass("")], false], [null, false]], [new StrClass(""), [null,true], [false,true], [0, false], [0.0, false], ["", true], [[new StrClass("")], false], [null, false]],
[new StrClass("1"), [null,true], [true, true], [1, true], [1.0, true], ["1", true], [[new StrClass("1")], false], [null, false]], [new StrClass("1"), [null,true], [true, true], [1, true], [1.0, true], ["1", true], [[new StrClass("1")], false], [null, false]],
[new StrClass("0"), [null,true], [false,true], [0, true], [0.0, true], ["0", true], [[new StrClass("0")], false], [null, false]], [new StrClass("0"), [null,true], [false,true], [0, true], [0.0, true], ["0", true], [[new StrClass("0")], false], [null, false]],

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -10,11 +11,13 @@ namespace JKingWeb\Arsse\TestCase\REST\Miniflux;
use JKingWeb\Arsse\Misc\HTTP; use JKingWeb\Arsse\Misc\HTTP;
use JKingWeb\Arsse\REST\Miniflux\Status; use JKingWeb\Arsse\REST\Miniflux\Status;
use JKingWeb\Arsse\REST\Miniflux\V1; use JKingWeb\Arsse\REST\Miniflux\V1;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
/** @covers \JKingWeb\Arsse\REST\Miniflux\Status */ #[CoversClass(\JKingWeb\Arsse\REST\Miniflux\Status::class)]
class TestStatus extends \JKingWeb\Arsse\Test\AbstractTest { class TestStatus extends \JKingWeb\Arsse\Test\AbstractTest {
/** @dataProvider provideRequests */ #[DataProvider('provideRequests')]
public function testAnswerStatusRequests(string $url, string $method, ResponseInterface $exp): void { public function testAnswerStatusRequests(string $url, string $method, ResponseInterface $exp): void {
$act = (new Status)->dispatch($this->serverRequest($method, $url, "")); $act = (new Status)->dispatch($this->serverRequest($method, $url, ""));
$this->assertMessage($exp, $act); $this->assertMessage($exp, $act);

View file

@ -84,7 +84,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::when(Arsse::$user)->propertiesGet->thenReturn(['num' => 42, 'admin' => false, 'root_folder_name' => null, 'tz' => "Asia/Gaza"]); \Phake::when(Arsse::$user)->propertiesGet->thenReturn(['num' => 42, 'admin' => false, 'root_folder_name' => null, 'tz' => "Asia/Gaza"]);
\Phake::when(Arsse::$user)->begin->thenReturn($this->transaction); \Phake::when(Arsse::$user)->begin->thenReturn($this->transaction);
//initialize a handler //initialize a handler
$this->h = new V1(); $this->h = new V1;
} }
protected static function v($value) { protected static function v($value) {

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -9,9 +10,10 @@ namespace JKingWeb\Arsse\TestCase\REST\NextcloudNews;
use JKingWeb\Arsse\Misc\HTTP; use JKingWeb\Arsse\Misc\HTTP;
use JKingWeb\Arsse\REST\NextcloudNews\Versions; use JKingWeb\Arsse\REST\NextcloudNews\Versions;
use PHPUnit\Framework\Attributes\CoversClass;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
/** @covers \JKingWeb\Arsse\REST\NextcloudNews\Versions */ #[CoversClass(\JKingWeb\Arsse\REST\NextcloudNews\Versions::class)]
class TestVersions extends \JKingWeb\Arsse\Test\AbstractTest { class TestVersions extends \JKingWeb\Arsse\Test\AbstractTest {
public function setUp(): void { public function setUp(): void {
parent::setUp(); parent::setUp();

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -19,10 +20,12 @@ use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\ServerRequest; use GuzzleHttp\Psr7\ServerRequest;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
/** @covers \JKingWeb\Arsse\REST */ #[CoversClass(\JKingWeb\Arsse\REST::class)]
class TestREST extends \JKingWeb\Arsse\Test\AbstractTest { class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
/** @dataProvider provideApiMatchData */ #[DataProvider('provideApiMatchData')]
public function testMatchAUrlToAnApi($apiList, string $input, array $exp): void { public function testMatchAUrlToAnApi($apiList, string $input, array $exp): void {
$r = new REST($apiList); $r = new REST($apiList);
try { try {
@ -58,9 +61,10 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideAuthenticableRequests */
#[DataProvider('provideAuthenticableRequests')]
public function testAuthenticateRequests(array $serverParams, array $expAttr): void { public function testAuthenticateRequests(array $serverParams, array $expAttr): void {
$r = new REST(); $r = new REST;
// create a mock user manager // create a mock user manager
Arsse::$user = \Phake::mock(User::class); Arsse::$user = \Phake::mock(User::class);
\Phake::when(Arsse::$user)->auth->thenReturn(false); \Phake::when(Arsse::$user)->auth->thenReturn(false);
@ -93,7 +97,7 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
public function testSendAuthenticationChallenges(): void { public function testSendAuthenticationChallenges(): void {
self::setConf(); self::setConf();
$r = new REST(); $r = new REST;
$in = HTTP::respEmpty(401); $in = HTTP::respEmpty(401);
$exp = $in->withHeader("WWW-Authenticate", 'Basic realm="OOK", charset="UTF-8"'); $exp = $in->withHeader("WWW-Authenticate", 'Basic realm="OOK", charset="UTF-8"');
$act = $r->challenge($in, "OOK"); $act = $r->challenge($in, "OOK");
@ -103,9 +107,10 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertMessage($exp, $act); $this->assertMessage($exp, $act);
} }
/** @dataProvider provideUnnormalizedOrigins */
#[DataProvider('provideUnnormalizedOrigins')]
public function testNormalizeOrigins(string $origin, string $exp, ?array $ports = null): void { public function testNormalizeOrigins(string $origin, string $exp, ?array $ports = null): void {
$r = new REST(); $r = new REST;
$act = $r->corsNormalizeOrigin($origin, $ports); $act = $r->corsNormalizeOrigin($origin, $ports);
$this->assertSame($exp, $act); $this->assertSame($exp, $act);
} }
@ -146,7 +151,8 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideCorsNegotiations */
#[DataProvider('provideCorsNegotiations')]
public function testNegotiateCors($origin, bool $exp, ?string $allowed = null, ?string $denied = null): void { public function testNegotiateCors($origin, bool $exp, ?string $allowed = null, ?string $denied = null): void {
self::setConf(); self::setConf();
$rMock = \Phake::partialMock(REST::class); $rMock = \Phake::partialMock(REST::class);
@ -184,9 +190,10 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideCorsHeaders */
#[DataProvider('provideCorsHeaders')]
public function testAddCorsHeaders(string $reqMethod, array $reqHeaders, array $resHeaders, array $expHeaders): void { public function testAddCorsHeaders(string $reqMethod, array $reqHeaders, array $resHeaders, array $expHeaders): void {
$r = new REST(); $r = new REST;
$req = new Request($reqMethod, "php://memory", $reqHeaders); $req = new Request($reqMethod, "php://memory", $reqHeaders);
$res = HTTP::respEmpty(204, $resHeaders); $res = HTTP::respEmpty(204, $resHeaders);
$exp = HTTP::respEmpty(204, $expHeaders); $exp = HTTP::respEmpty(204, $expHeaders);
@ -248,7 +255,8 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideUnnormalizedResponses */
#[DataProvider('provideUnnormalizedResponses')]
public function testNormalizeHttpResponses(ResponseInterface $res, ResponseInterface $exp, ?RequestInterface $req = null): void { public function testNormalizeHttpResponses(ResponseInterface $res, ResponseInterface $exp, ?RequestInterface $req = null): void {
$rMock = \Phake::partialMock(REST::class); $rMock = \Phake::partialMock(REST::class);
\Phake::when($rMock)->corsNegotiate->thenReturn(true); \Phake::when($rMock)->corsNegotiate->thenReturn(true);
@ -284,7 +292,8 @@ 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 {
$rMock = \Phake::partialMock(REST::class); $rMock = \Phake::partialMock(REST::class);
\Phake::when($rMock)->normalizeResponse->thenReturnCallback(function($res) { \Phake::when($rMock)->normalizeResponse->thenReturnCallback(function($res) {

View file

@ -147,7 +147,7 @@ LONG_STRING;
'expires' => "2112-12-21 21:12:00", 'expires' => "2112-12-21 21:12:00",
'user' => self::$userId, 'user' => self::$userId,
]); ]);
$this->h = new API(); $this->h = new API;
} }
protected function req($data, string $method = "POST", string $target = "", ?string $strData = null, ?string $user = null): ResponseInterface { protected function req($data, string $method = "POST", string $target = "", ?string $strData = null, ?string $user = null): ResponseInterface {

View file

@ -26,7 +26,7 @@ class TestIcon extends \JKingWeb\Arsse\Test\AbstractTest {
Arsse::$user = \Phake::mock(User::class); Arsse::$user = \Phake::mock(User::class);
// create a mock database interface // create a mock database interface
Arsse::$db = \Phake::mock(Database::class); Arsse::$db = \Phake::mock(Database::class);
$this->h = new Icon(); $this->h = new Icon;
} }
protected function req(string $target, string $method = "GET", ?string $user = null): ResponseInterface { protected function req(string $target, string $method = "GET", ?string $user = null): ResponseInterface {

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -9,8 +10,10 @@ namespace JKingWeb\Arsse\TestCase\REST\TinyTinyRSS;
use JKingWeb\Arsse\Context\Context; use JKingWeb\Arsse\Context\Context;
use JKingWeb\Arsse\REST\TinyTinyRSS\Search; use JKingWeb\Arsse\REST\TinyTinyRSS\Search;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
/** @covers \JKingWeb\Arsse\REST\TinyTinyRSS\Search */ #[CoversClass(\JKingWeb\Arsse\REST\TinyTinyRSS\Search::class)]
class TestSearch extends \JKingWeb\Arsse\Test\AbstractTest { class TestSearch extends \JKingWeb\Arsse\Test\AbstractTest {
public static function provideSearchStrings(): iterable { public static function provideSearchStrings(): iterable {
return [ return [
@ -118,7 +121,8 @@ class TestSearch extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideSearchStrings */
#[DataProvider('provideSearchStrings')]
public function testApplySearchToContext(string $search, $exp): void { public function testApplySearchToContext(string $search, $exp): void {
$act = Search::parse($search, "UTC"); $act = Search::parse($search, "UTC");
$this->assertEquals($exp, $act); $this->assertEquals($exp, $act);

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -10,8 +11,11 @@ namespace JKingWeb\Arsse\TestCase\Service;
use JKingWeb\Arsse\Service\Daemon; use JKingWeb\Arsse\Service\Daemon;
use JKingWeb\Arsse\Service\Exception; use JKingWeb\Arsse\Service\Exception;
use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStream;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
/** @covers \JKingWeb\Arsse\Service\Daemon */ #[CoversClass(\JKingWeb\Arsse\Service\Daemon::class)]
class TestDaemon extends \JKingWeb\Arsse\Test\AbstractTest { class TestDaemon extends \JKingWeb\Arsse\Test\AbstractTest {
protected $pidfiles = [ protected $pidfiles = [
'errors' => [ 'errors' => [
@ -47,7 +51,8 @@ class TestDaemon extends \JKingWeb\Arsse\Test\AbstractTest {
$this->daemon = \Phake::partialMock(Daemon::class); $this->daemon = \Phake::partialMock(Daemon::class);
} }
/** @dataProvider providePathResolutions */
#[DataProvider('providePathResolutions')]
public function testResolveRelativePaths(string $path, $cwd, $exp): void { public function testResolveRelativePaths(string $path, $cwd, $exp): void {
// set up mock daemon class // set up mock daemon class
\Phake::when($this->daemon)->cwd->thenReturn($cwd); \Phake::when($this->daemon)->cwd->thenReturn($cwd);
@ -73,7 +78,8 @@ class TestDaemon extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider providePidFileChecks */
#[DataProvider('providePidFileChecks')]
public function testCheckPidFiles(string $file, bool $accessible, $exp): void { public function testCheckPidFiles(string $file, bool $accessible, $exp): void {
$vfs = vfsStream::setup("pidtest", 0777, $this->pidfiles); $vfs = vfsStream::setup("pidtest", 0777, $this->pidfiles);
$path = $vfs->url()."/"; $path = $vfs->url()."/";
@ -109,7 +115,8 @@ class TestDaemon extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider providePidReadChecks */
#[DataProvider('providePidReadChecks')]
public function testCheckPidReads(string $file, $exp) { public function testCheckPidReads(string $file, $exp) {
$vfs = vfsStream::setup("pidtest", 0777, $this->pidfiles); $vfs = vfsStream::setup("pidtest", 0777, $this->pidfiles);
$path = $vfs->url()."/pid/"; $path = $vfs->url()."/pid/";
@ -155,10 +162,8 @@ class TestDaemon extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** #[DataProvider('providePidWriteChecks')]
* @dataProvider providePidWriteChecks #[RequiresPhpExtension('posix')]
* @requires extension posix
*/
public function testCheckPidWrites(string $file, $exp) { public function testCheckPidWrites(string $file, $exp) {
$pid = (string) posix_getpid(); $pid = (string) posix_getpid();
$vfs = vfsStream::setup("pidtest", 0777, $this->pidfiles); $vfs = vfsStream::setup("pidtest", 0777, $this->pidfiles);

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -11,8 +12,9 @@ use JKingWeb\Arsse\Arsse;
use JKingWeb\Arsse\Database; use JKingWeb\Arsse\Database;
use JKingWeb\Arsse\Service\Driver as DriverInterface; use JKingWeb\Arsse\Service\Driver as DriverInterface;
use JKingWeb\Arsse\Service\Serial\Driver; use JKingWeb\Arsse\Service\Serial\Driver;
use PHPUnit\Framework\Attributes\CoversClass;
/** @covers \JKingWeb\Arsse\Service\Serial\Driver */ #[CoversClass(\JKingWeb\Arsse\Service\Serial\Driver::class)]
class TestSerial extends \JKingWeb\Arsse\Test\AbstractTest { class TestSerial extends \JKingWeb\Arsse\Test\AbstractTest {
public function setUp(): void { public function setUp(): void {
parent::setUp(); parent::setUp();

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -11,8 +12,9 @@ use JKingWeb\Arsse\Arsse;
use JKingWeb\Arsse\Database; use JKingWeb\Arsse\Database;
use JKingWeb\Arsse\Service; use JKingWeb\Arsse\Service;
use JKingWeb\Arsse\Misc\Date; use JKingWeb\Arsse\Misc\Date;
use PHPUnit\Framework\Attributes\CoversClass;
/** @covers \JKingWeb\Arsse\Service */ #[CoversClass(\JKingWeb\Arsse\Service::class)]
class TestService extends \JKingWeb\Arsse\Test\AbstractTest { class TestService extends \JKingWeb\Arsse\Test\AbstractTest {
protected $srv; protected $srv;
@ -20,7 +22,7 @@ class TestService extends \JKingWeb\Arsse\Test\AbstractTest {
parent::setUp(); parent::setUp();
self::setConf(); self::setConf();
Arsse::$db = \Phake::mock(Database::class); Arsse::$db = \Phake::mock(Database::class);
$this->srv = new Service(); $this->srv = new Service;
} }
public function testCheckIn(): void { public function testCheckIn(): void {

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -10,8 +11,9 @@ namespace JKingWeb\Arsse\TestCase\Service;
use JKingWeb\Arsse\Arsse; use JKingWeb\Arsse\Arsse;
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;
use PHPUnit\Framework\Attributes\CoversClass;
/** @covers \JKingWeb\Arsse\Service\Subprocess\Driver */ #[CoversClass(\JKingWeb\Arsse\Service\Subprocess\Driver::class)]
class TestSubprocess extends \JKingWeb\Arsse\Test\AbstractTest { class TestSubprocess extends \JKingWeb\Arsse\Test\AbstractTest {
public function setUp(): void { public function setUp(): void {
parent::setUp(); parent::setUp();

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -13,8 +14,10 @@ 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 PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
/** @covers \JKingWeb\Arsse\Arsse */ #[CoversClass(\JKingWeb\Arsse\Arsse::class)]
class TestArsse extends \JKingWeb\Arsse\Test\AbstractTest { class TestArsse extends \JKingWeb\Arsse\Test\AbstractTest {
public function setUp(): void { public function setUp(): void {
self::clearData(false); self::clearData(false);
@ -46,7 +49,8 @@ class TestArsse extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertInstanceOf(User::class, Arsse::$user); $this->assertInstanceOf(User::class, Arsse::$user);
} }
/** @dataProvider provideExtensionChecks */
#[DataProvider('provideExtensionChecks')]
public function testCheckForExtensions(array $ext, $exp): void { public function testCheckForExtensions(array $ext, $exp): void {
if ($exp instanceof \Exception) { if ($exp instanceof \Exception) {
$this->assertException($exp); $this->assertException($exp);

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -11,8 +12,11 @@ use JKingWeb\Arsse\Arsse;
use JKingWeb\Arsse\Database; use JKingWeb\Arsse\Database;
use JKingWeb\Arsse\User\Driver as DriverInterface; use JKingWeb\Arsse\User\Driver as DriverInterface;
use JKingWeb\Arsse\User\Internal\Driver; use JKingWeb\Arsse\User\Internal\Driver;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
/** @covers \JKingWeb\Arsse\User\Internal\Driver */ #[CoversClass(\JKingWeb\Arsse\User\Internal\Driver::class)]
class TestInternal extends \JKingWeb\Arsse\Test\AbstractTest { class TestInternal extends \JKingWeb\Arsse\Test\AbstractTest {
protected $d; protected $d;
@ -33,10 +37,8 @@ class TestInternal extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertTrue(strlen(Driver::driverName()) > 0); $this->assertTrue(strlen(Driver::driverName()) > 0);
} }
/** #[DataProvider('provideAuthentication')]
* @dataProvider provideAuthentication #[Group('slow')]
* @group slow
*/
public function testAuthenticateAUser(string $user, $password, bool $exp): void { public function testAuthenticateAUser(string $user, $password, bool $exp): void {
\Phake::when(Arsse::$db)->userPasswordGet("john.doe@example.com")->thenReturn('$2y$10$1zbqRJhxM8uUjeSBPp4IhO90xrqK0XjEh9Z16iIYEFRV4U.zeAFom'); // hash of "secret" \Phake::when(Arsse::$db)->userPasswordGet("john.doe@example.com")->thenReturn('$2y$10$1zbqRJhxM8uUjeSBPp4IhO90xrqK0XjEh9Z16iIYEFRV4U.zeAFom'); // hash of "secret"
\Phake::when(Arsse::$db)->userPasswordGet("jane.doe@example.com")->thenReturn('$2y$10$bK1ljXfTSyc2D.NYvT.Eq..OpehLRXVbglW.23ihVuyhgwJCd.7Im'); // hash of "superman" \Phake::when(Arsse::$db)->userPasswordGet("jane.doe@example.com")->thenReturn('$2y$10$bK1ljXfTSyc2D.NYvT.Eq..OpehLRXVbglW.23ihVuyhgwJCd.7Im'); // hash of "superman"

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -14,8 +15,10 @@ use JKingWeb\Arsse\Db\Transaction;
use JKingWeb\Arsse\User\ExceptionConflict; use JKingWeb\Arsse\User\ExceptionConflict;
use JKingWeb\Arsse\User\ExceptionInput; use JKingWeb\Arsse\User\ExceptionInput;
use JKingWeb\Arsse\User\Driver; use JKingWeb\Arsse\User\Driver;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
/** @covers \JKingWeb\Arsse\User */ #[CoversClass(\JKingWeb\Arsse\User::class)]
class TestUser extends \JKingWeb\Arsse\Test\AbstractTest { class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
protected $drv; protected $drv;
@ -54,7 +57,8 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
$this->assertNotEquals($pass1, $pass2); $this->assertNotEquals($pass1, $pass2);
} }
/** @dataProvider provideAuthentication */
#[DataProvider('provideAuthentication')]
public function testAuthenticateAUser(bool $preAuth, string $user, string $password, bool $exp): void { public function testAuthenticateAUser(bool $preAuth, string $user, string $password, bool $exp): void {
Arsse::$conf->userPreAuth = $preAuth; Arsse::$conf->userPreAuth = $preAuth;
\Phake::when($this->drv)->auth->thenReturn(false); \Phake::when($this->drv)->auth->thenReturn(false);
@ -156,7 +160,8 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
} }
} }
/** @dataProvider provideInvalidUserNames */
#[DataProvider('provideInvalidUserNames')]
public function testAddAnInvalidUser(string $user): void { public function testAddAnInvalidUser(string $user): void {
$u = new User($this->drv); $u = new User($this->drv);
$this->assertException("invalidUsername", "User", "ExceptionInput"); $this->assertException("invalidUsername", "User", "ExceptionInput");
@ -240,7 +245,8 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::verify($this->drv)->userRename($old, $old); \Phake::verify($this->drv)->userRename($old, $old);
} }
/** @dataProvider provideInvalidUserNames */
#[DataProvider('provideInvalidUserNames')]
public function testRenameAUserToAnInvalidName(string $new): void { public function testRenameAUserToAnInvalidName(string $new): void {
$u = new User($this->drv); $u = new User($this->drv);
$this->assertException("invalidUsername", "User", "ExceptionInput"); $this->assertException("invalidUsername", "User", "ExceptionInput");
@ -405,7 +411,8 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
} }
} }
/** @dataProvider provideProperties */
#[DataProvider('provideProperties')]
public function testGetThePropertiesOfAUser(array $exp, array $base, array $extra): void { public function testGetThePropertiesOfAUser(array $exp, array $base, array $extra): void {
$user = "john.doe@example.com"; $user = "john.doe@example.com";
$exp = array_merge(['num' => null], array_combine(array_keys(User::PROPERTIES), array_fill(0, sizeof(User::PROPERTIES), null)), $exp); $exp = array_merge(['num' => null], array_combine(array_keys(User::PROPERTIES), array_fill(0, sizeof(User::PROPERTIES), null)), $exp);
@ -460,7 +467,8 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
} }
} }
/** @dataProvider providePropertyChanges */
#[DataProvider('providePropertyChanges')]
public function testSetThePropertiesOfAUser(array $in, $out): void { public function testSetThePropertiesOfAUser(array $in, $out): void {
$user = "john.doe@example.com"; $user = "john.doe@example.com";
if ($out instanceof \Exception) { if ($out instanceof \Exception) {
@ -479,7 +487,8 @@ class TestUser extends \JKingWeb\Arsse\Test\AbstractTest {
} }
} }
/** @dataProvider providePropertyChanges */
#[DataProvider('providePropertyChanges')]
public function testSetThePropertiesOfAUserWeDoNotKnow(array $in, $out): void { public function testSetThePropertiesOfAUserWeDoNotKnow(array $in, $out): void {
$user = "john.doe@example.com"; $user = "john.doe@example.com";
if ($out instanceof \Exception) { if ($out instanceof \Exception) {

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -24,15 +25,16 @@ use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Psr7\ServerRequest; use GuzzleHttp\Psr7\ServerRequest;
use PHPUnit\Framework\Attributes\CoversNothing;
/** @coversNothing */ #[CoversNothing]
abstract class AbstractTest extends \PHPUnit\Framework\TestCase { abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
public function setUp(): void { public function setUp(): void {
self::clearData(); self::clearData();
// create the object factory as a mock // create the object factory as a mock
Arsse::$obj = \Phake::mock(Factory::class); Arsse::$obj = \Phake::mock(Factory::class);
\Phake::when(Arsse::$obj)->get->thenReturnCallback(function(string $class) { \Phake::when(Arsse::$obj)->get->thenReturnCallback(function(string $class) {
return new $class; return new $class();
}); });
} }

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */
@ -23,7 +24,7 @@ trait MySQL {
if (!class_exists("mysqli")) { if (!class_exists("mysqli")) {
return null; return null;
} }
$drv = new \mysqli_driver; $drv = new \mysqli_driver();
$drv->report_mode = \MYSQLI_REPORT_OFF; $drv->report_mode = \MYSQLI_REPORT_OFF;
$d = mysqli_init(); $d = mysqli_init();
$d->options(\MYSQLI_OPT_INT_AND_FLOAT_NATIVE, false); $d->options(\MYSQLI_OPT_INT_AND_FLOAT_NATIVE, false);

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */

View file

@ -1,4 +1,5 @@
<?php <?php
/** @license MIT /** @license MIT
* 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 */