Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
24 changed files with 60 additions and 100 deletions
Showing only changes of commit 49ffee3d89 - Show all commits

View File

@ -40,7 +40,7 @@ final class APIRequestBuilderTest extends TestCase
$this->builder->setLogger(new NullLogger()); $this->builder->setLogger(new NullLogger());
} }
public function testGzipRequest(): void public function testGzipRequest(): never
{ {
$this->markTestSkipped('Need new test API'); $this->markTestSkipped('Need new test API');
@ -51,7 +51,7 @@ final class APIRequestBuilderTest extends TestCase
$this->assertTrue($body['gzipped']); $this->assertTrue($body['gzipped']);
} }
public function testInvalidRequestMethod(): void public function testInvalidRequestMethod(): never
{ {
$this->markTestSkipped('Need new test API'); $this->markTestSkipped('Need new test API');
@ -60,7 +60,7 @@ final class APIRequestBuilderTest extends TestCase
->getFullRequest(); ->getFullRequest();
} }
public function testRequestWithBasicAuth(): void public function testRequestWithBasicAuth(): never
{ {
$this->markTestSkipped('Need new test API'); $this->markTestSkipped('Need new test API');
@ -74,7 +74,7 @@ final class APIRequestBuilderTest extends TestCase
$this->assertSame('Basic dXNlcm5hbWU6cGFzc3dvcmQ=', $body['headers']['Authorization']); $this->assertSame('Basic dXNlcm5hbWU6cGFzc3dvcmQ=', $body['headers']['Authorization']);
} }
public function testRequestWithQueryString(): void public function testRequestWithQueryString(): never
{ {
$this->markTestSkipped('Need new test API'); $this->markTestSkipped('Need new test API');
@ -104,7 +104,7 @@ final class APIRequestBuilderTest extends TestCase
$this->assertSame($expected, $body['args']); $this->assertSame($expected, $body['args']);
} }
public function testFormValueRequest(): void public function testFormValueRequest(): never
{ {
$this->markTestSkipped('Need new test API'); $this->markTestSkipped('Need new test API');
@ -123,7 +123,7 @@ final class APIRequestBuilderTest extends TestCase
$this->assertSame($formValues, $body['form']); $this->assertSame($formValues, $body['form']);
} }
public function testFullUrlRequest(): void public function testFullUrlRequest(): never
{ {
$this->markTestSkipped('Need new test API'); $this->markTestSkipped('Need new test API');

View File

@ -38,7 +38,7 @@ final class AnimeListTransformerTest extends AnimeClientTestCase
$this->transformer = new AnimeListTransformer(); $this->transformer = new AnimeListTransformer();
} }
public function testTransform(): void public function testTransform(): never
{ {
$this->markTestSkipped('Old test data'); $this->markTestSkipped('Old test data');
@ -50,7 +50,7 @@ final class AnimeListTransformerTest extends AnimeClientTestCase
{ {
return [[ return [[
'input' => [ 'input' => [
'id' => 14047981, 'id' => 14_047_981,
'watching_status' => 'current', 'watching_status' => 'current',
'user_rating' => 8, 'user_rating' => 8,
'episodes_watched' => 38, 'episodes_watched' => 38,
@ -60,7 +60,7 @@ final class AnimeListTransformerTest extends AnimeClientTestCase
], ],
], [ ], [
'input' => [ 'input' => [
'id' => 14047981, 'id' => 14_047_981,
'mal_id' => '12345', 'mal_id' => '12345',
'watching_status' => 'current', 'watching_status' => 'current',
'user_rating' => 8, 'user_rating' => 8,
@ -73,7 +73,7 @@ final class AnimeListTransformerTest extends AnimeClientTestCase
], ],
], [ ], [
'input' => [ 'input' => [
'id' => 14047983, 'id' => 14_047_983,
'mal_id' => '12347', 'mal_id' => '12347',
'watching_status' => 'current', 'watching_status' => 'current',
'user_rating' => 0, 'user_rating' => 0,

View File

@ -37,7 +37,7 @@ final class AnimeTransformerTest extends AnimeClientTestCase
$this->transformer = new AnimeTransformer(); $this->transformer = new AnimeTransformer();
} }
public function testTransform() public function testTransform(): never
{ {
$this->markTestSkipped('May fail on CI'); $this->markTestSkipped('May fail on CI');
$actual = $this->transformer->transform($this->beforeTransform); $actual = $this->transformer->transform($this->beforeTransform);

View File

@ -35,7 +35,7 @@ final class CharacterTransformerTest extends AnimeClientTestCase
$this->beforeTransform = $raw; $this->beforeTransform = $raw;
} }
public function testTransform(): void public function testTransform(): never
{ {
$this->markTestSkipped('Fails on CI'); $this->markTestSkipped('Fails on CI');
$actual = (new CharacterTransformer())->transform($this->beforeTransform); $actual = (new CharacterTransformer())->transform($this->beforeTransform);

View File

@ -35,7 +35,7 @@ final class HistoryTransformerTest extends AnimeClientTestCase
$this->beforeTransform = $raw; $this->beforeTransform = $raw;
} }
public function testAnimeTransform(): void public function testAnimeTransform(): never
{ {
$this->markTestSkipped('Old test data'); $this->markTestSkipped('Old test data');

View File

@ -35,7 +35,7 @@ final class PersonTransformerTest extends AnimeClientTestCase
$this->beforeTransform = $raw; $this->beforeTransform = $raw;
} }
public function testTransform(): void public function testTransform(): never
{ {
$this->markTestSkipped('Fails on CI'); $this->markTestSkipped('Fails on CI');
$actual = (new PersonTransformer())->transform($this->beforeTransform); $actual = (new PersonTransformer())->transform($this->beforeTransform);

View File

@ -40,10 +40,10 @@ class AnimeClientTestCase extends TestCase
use MatchesSnapshots; use MatchesSnapshots;
// Test directory constants // Test directory constants
public const ROOT_DIR = AC_TEST_ROOT_DIR; final public const ROOT_DIR = AC_TEST_ROOT_DIR;
public const SRC_DIR = SRC_DIR; final public const SRC_DIR = SRC_DIR;
public const TEST_DATA_DIR = __DIR__ . '/test_data'; final public const TEST_DATA_DIR = __DIR__ . '/test_data';
public const TEST_VIEW_DIR = __DIR__ . '/test_views'; final public const TEST_VIEW_DIR = __DIR__ . '/test_views';
protected ContainerInterface $container; protected ContainerInterface $container;
@ -97,7 +97,7 @@ class AnimeClientTestCase extends TestCase
$container = $di($config_array); $container = $di($config_array);
// Use mock session handler // Use mock session handler
$container->set('session-handler', static function () { $container->set('session-handler', static function (): \Aviat\AnimeClient\Tests\TestSessionHandler {
$session_handler = new TestSessionHandler(); $session_handler = new TestSessionHandler();
session_set_save_handler($session_handler, TRUE); session_set_save_handler($session_handler, TRUE);
@ -123,7 +123,7 @@ class AnimeClientTestCase extends TestCase
]; ];
$request = call_user_func_array( $request = call_user_func_array(
[ServerRequestFactory::class, 'fromGlobals'], ServerRequestFactory::fromGlobals(...),
array_values(array_merge($default, $supers)), array_values(array_merge($default, $supers)),
); );
$this->container->setInstance('request', $request); $this->container->setInstance('request', $request);

View File

@ -141,11 +141,8 @@ final class DispatcherTest extends AnimeClientTestCase
return $data; return $data;
} }
/**
* @param mixed $config
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataRoute')] #[\PHPUnit\Framework\Attributes\DataProvider('dataRoute')]
public function testRoute($config, mixed $controller, mixed $host, mixed $uri): void public function testRoute(mixed $config, mixed $controller, mixed $host, mixed $uri): void
{ {
$this->doSetUp($config, $uri, $host); $this->doSetUp($config, $uri, $host);

View File

@ -251,7 +251,7 @@ final class FormGeneratorTest extends AnimeClientTestCase
{ {
$generator = FormGenerator::new($this->container); $generator = FormGenerator::new($this->container);
foreach (SETTINGS_MAP as $section => $fields) foreach (SETTINGS_MAP as $fields)
{ {
foreach ($fields as $name => $config) foreach ($fields as $name => $config)
{ {

View File

@ -64,6 +64,7 @@ final class MenuHelperTest extends AnimeClientTestCase
// Set config for tests // Set config for tests
$config = $this->container->get('config'); $config = $this->container->get('config');
$config->set('menus', $menus); $config->set('menus', $menus);
$this->container->setInstance('config', $config); $this->container->setInstance('config', $config);
foreach ($menus as $case => $config) foreach ($menus as $case => $config)

View File

@ -83,6 +83,7 @@ final class MenuGeneratorTest extends AnimeClientTestCase
]; ];
$config = $this->container->get('config'); $config = $this->container->get('config');
$config->set('menus', $menus); $config->set('menus', $menus);
$this->container->setInstance('config', $config); $this->container->setInstance('config', $config);
$expected = ''; $expected = '';

View File

@ -23,7 +23,7 @@ final class RequirementsTest extends AnimeClientTestCase
{ {
public function testPHPVersion(): void public function testPHPVersion(): void
{ {
$this->assertTrue(version_compare(PHP_VERSION, '8', 'ge')); $this->assertTrue(PHP_VERSION_ID >= 8);
} }
public function testHasPDO(): void public function testHasPDO(): void

View File

@ -55,13 +55,13 @@ class TestSessionHandler implements SessionHandlerInterface
public function read($id) public function read($id)
{ {
return json_decode(@file_get_contents("{$this->savePath}/{$id}"), TRUE); return json_decode(@file_get_contents("{$this->savePath}/{$id}"), TRUE, 512, JSON_THROW_ON_ERROR);
} }
public function write($id, $data) public function write($id, $data)
{ {
$file = "{$this->savePath}/{$id}"; $file = "{$this->savePath}/{$id}";
file_put_contents($file, json_encode($data)); file_put_contents($file, json_encode($data, JSON_THROW_ON_ERROR));
return TRUE; return TRUE;
} }

View File

@ -69,11 +69,8 @@ final class UtilTest extends AnimeClientTestCase
]; ];
} }
/**
* @param mixed $uri
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataIsViewPage')] #[\PHPUnit\Framework\Attributes\DataProvider('dataIsViewPage')]
public function testIsViewPage($uri, mixed $expected) public function testIsViewPage(mixed $uri, mixed $expected)
{ {
$this->setSuperGlobals([ $this->setSuperGlobals([
'_SERVER' => [ '_SERVER' => [
@ -83,12 +80,8 @@ final class UtilTest extends AnimeClientTestCase
$this->assertSame($expected, $this->util->isViewPage()); $this->assertSame($expected, $this->util->isViewPage());
} }
/**
* @param mixed $uri
* @param mixed $expected
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataIsViewPage')] #[\PHPUnit\Framework\Attributes\DataProvider('dataIsViewPage')]
public function testIsFormPage($uri, $expected) public function testIsFormPage(mixed $uri, mixed $expected)
{ {
$this->setSuperGlobals([ $this->setSuperGlobals([
'_SERVER' => [ '_SERVER' => [

View File

@ -29,9 +29,9 @@ class MockErrorHandler
class TestEnum extends Enum class TestEnum extends Enum
{ {
public const FOO = 'bar'; final public const FOO = 'bar';
public const BAR = 'foo'; final public const BAR = 'foo';
public const FOOBAR = 'baz'; final public const FOOBAR = 'baz';
} }
class FriendGrandParentTestClass class FriendGrandParentTestClass

View File

@ -29,11 +29,8 @@ use TypeError;
*/ */
final class FooTest final class FooTest
{ {
public $item; public function __construct(public $item)
public function __construct($item)
{ {
$this->item = $item;
} }
} }
@ -71,11 +68,8 @@ final class ContainerTest extends IonTestCase
]; ];
} }
/**
* @param mixed $exception
*/
#[DataProvider('dataGetWithException')] #[DataProvider('dataGetWithException')]
public function testGetWithException(mixed $id, $exception, ?string $message = NULL): void public function testGetWithException(mixed $id, mixed $exception, ?string $message = NULL): void
{ {
try try
{ {
@ -92,11 +86,8 @@ final class ContainerTest extends IonTestCase
} }
} }
/**
* @param mixed $exception
*/
#[DataProvider('dataGetWithException')] #[DataProvider('dataGetWithException')]
public function testGetNewWithException(mixed $id, $exception, ?string $message = NULL): void public function testGetNewWithException(mixed $id, mixed $exception, ?string $message = NULL): void
{ {
$this->expectException($exception); $this->expectException($exception);
if ($message !== NULL) if ($message !== NULL)
@ -123,13 +114,8 @@ final class ContainerTest extends IonTestCase
]; ];
} }
/**
* @param mixed $id
* @param mixed $exception
* @param mixed $message
*/
#[DataProvider('dataSetInstanceWithException')] #[DataProvider('dataSetInstanceWithException')]
public function testSetInstanceWithException($id, $exception, $message): void public function testSetInstanceWithException(mixed $id, mixed $exception, mixed $message): void
{ {
try try
{ {
@ -176,9 +162,7 @@ final class ContainerTest extends IonTestCase
public function testGetSet(): void public function testGetSet(): void
{ {
$container = $this->container->set('foo', static function () { $container = $this->container->set('foo', static fn() => static function (): void {});
return static function () {};
});
$this->assertInstanceOf(Container::class, $container); $this->assertInstanceOf(Container::class, $container);
$this->assertInstanceOf(ContainerInterface::class, $container); $this->assertInstanceOf(ContainerInterface::class, $container);

View File

@ -70,12 +70,8 @@ final class EnumTest extends IonTestCase
]; ];
} }
/**
* @param mixed $value
* @param mixed $static
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataIsValid')] #[\PHPUnit\Framework\Attributes\DataProvider('dataIsValid')]
public function testIsValid($value, mixed $expected, $static) public function testIsValid(mixed $value, mixed $expected, mixed $static)
{ {
$actual = ($static) $actual = ($static)
? TestEnum::isValid($value) ? TestEnum::isValid($value)

View File

@ -22,7 +22,7 @@ use Aviat\Ion\Tests\IonTestCase;
*/ */
final class DoubleRenderExceptionTest extends IonTestCase final class DoubleRenderExceptionTest extends IonTestCase
{ {
public function testDefaultMessage() public function testDefaultMessage(): never
{ {
$this->expectException(DoubleRenderException::class); $this->expectException(DoubleRenderException::class);
$this->expectExceptionMessage('A view can only be rendered once, because headers can only be sent once.'); $this->expectExceptionMessage('A view can only be rendered once, because headers can only be sent once.');

View File

@ -26,10 +26,10 @@ use function Aviat\Ion\_dir;
class IonTestCase extends TestCase class IonTestCase extends TestCase
{ {
// Test directory constants // Test directory constants
public const ROOT_DIR = AC_TEST_ROOT_DIR; final public const ROOT_DIR = AC_TEST_ROOT_DIR;
public const SRC_DIR = SRC_DIR; final public const SRC_DIR = SRC_DIR;
public const TEST_DATA_DIR = __DIR__ . '/test_data'; final public const TEST_DATA_DIR = __DIR__ . '/test_data';
public const TEST_VIEW_DIR = __DIR__ . '/test_views'; final public const TEST_VIEW_DIR = __DIR__ . '/test_views';
protected ContainerInterface $container; protected ContainerInterface $container;
protected static $staticContainer; protected static $staticContainer;
@ -92,7 +92,7 @@ class IonTestCase extends TestCase
// Set up DI container // Set up DI container
$di = require 'di.php'; $di = require 'di.php';
$container = $di($config_array); $container = $di($config_array);
$container->set('session-handler', static function () { $container->set('session-handler', static function (): \Aviat\Ion\Tests\TestSessionHandler {
// Use mock session handler // Use mock session handler
$session_handler = new TestSessionHandler(); $session_handler = new TestSessionHandler();
session_set_save_handler($session_handler, TRUE); session_set_save_handler($session_handler, TRUE);
@ -117,7 +117,7 @@ class IonTestCase extends TestCase
]; ];
$request = call_user_func_array( $request = call_user_func_array(
[ServerRequestFactory::class, 'fromGlobals'], ServerRequestFactory::fromGlobals(...),
array_merge($default, $supers) array_merge($default, $supers)
); );
$this->container->setInstance('request', $request); $this->container->setInstance('request', $request);

View File

@ -74,7 +74,7 @@ final class JsonTest extends IonTestCase
$this->assertEquals((object) $expected, Json::decode($json, FALSE)); $this->assertEquals((object) $expected, Json::decode($json, FALSE));
$badJson = '{foo:{1|2}}'; $badJson = '{foo:{1|2}}';
$this->expectException('Aviat\Ion\JsonException'); $this->expectException(\Aviat\Ion\JsonException::class);
$this->expectExceptionMessage('JSON_ERROR_SYNTAX - Syntax error'); $this->expectExceptionMessage('JSON_ERROR_SYNTAX - Syntax error');
$this->expectExceptionCode(JSON_ERROR_SYNTAX); $this->expectExceptionCode(JSON_ERROR_SYNTAX);

View File

@ -55,13 +55,13 @@ class TestSessionHandler implements SessionHandlerInterface
public function read($id) public function read($id)
{ {
return json_decode(@file_get_contents("{$this->save_path}/{$id}"), TRUE); return json_decode(@file_get_contents("{$this->save_path}/{$id}"), TRUE, 512, JSON_THROW_ON_ERROR);
} }
public function write($id, $data) public function write($id, $data)
{ {
$file = "{$this->save_path}/{$id}"; $file = "{$this->save_path}/{$id}";
file_put_contents($file, json_encode($data)); file_put_contents($file, json_encode($data, JSON_THROW_ON_ERROR));
return TRUE; return TRUE;
} }

View File

@ -130,32 +130,22 @@ final class AbstractTransformerTest extends IonTestCase
$this->assertSame($expected, $actual); $this->assertSame($expected, $actual);
} }
/**
* @param mixed $original
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataTransformCollection')] #[\PHPUnit\Framework\Attributes\DataProvider('dataTransformCollection')]
public function testTransformCollection($original, mixed $expected) public function testTransformCollection(mixed $original, mixed $expected)
{ {
$actual = $this->transformer->transformCollection($original); $actual = $this->transformer->transformCollection($original);
$this->assertSame($expected, $actual); $this->assertSame($expected, $actual);
} }
/**
* @param mixed $original
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataUnTransformCollection')] #[\PHPUnit\Framework\Attributes\DataProvider('dataUnTransformCollection')]
public function testUntransformCollection($original, mixed $expected) public function testUntransformCollection(mixed $original, mixed $expected)
{ {
$actual = $this->untransformer->untransformCollection($original); $actual = $this->untransformer->untransformCollection($original);
$this->assertSame($expected, $actual); $this->assertSame($expected, $actual);
} }
/**
* @param mixed $original
* @param mixed $expected
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataUnTransformCollection')] #[\PHPUnit\Framework\Attributes\DataProvider('dataUnTransformCollection')]
public function testUntransformCollectionWithException($original, $expected) public function testUntransformCollectionWithException(mixed $original, mixed $expected)
{ {
$this->expectException(BadMethodCallException::class); $this->expectException(BadMethodCallException::class);
$this->transformer->untransformCollection($original); $this->transformer->untransformCollection($original);

View File

@ -16,15 +16,13 @@ return static function (array $config_array = []) {
$container->setInstance('config', new Config($config_array)); $container->setInstance('config', new Config($config_array));
$container->set('request', static function () { $container->set('request', static fn() => ServerRequestFactory::fromGlobals(
return ServerRequestFactory::fromGlobals(
$GLOBALS['_SERVER'], $GLOBALS['_SERVER'],
$_GET, $_GET,
$_POST, $_POST,
$_COOKIE, $_COOKIE,
$_FILES $_FILES
); ));
});
$container->set('response', static fn () => new Response()); $container->set('response', static fn () => new Response());

View File

@ -36,9 +36,9 @@ class MockErrorHandler
class TestEnum extends Enum class TestEnum extends Enum
{ {
public const FOO = 'bar'; final public const FOO = 'bar';
public const BAR = 'foo'; final public const BAR = 'foo';
public const FOOBAR = 'baz'; final public const FOOBAR = 'baz';
} }
class FriendGrandParentTestClass class FriendGrandParentTestClass
@ -49,13 +49,13 @@ class FriendGrandParentTestClass
class FriendParentTestClass extends FriendGrandParentTestClass class FriendParentTestClass extends FriendGrandParentTestClass
{ {
protected $parentProtected = 47; protected $parentProtected = 47;
private $parentPrivate = 654; private int $parentPrivate = 654;
} }
class FriendTestClass extends FriendParentTestClass class FriendTestClass extends FriendParentTestClass
{ {
protected $protected = 356; protected $protected = 356;
private $private = 486; private int $private = 486;
protected function getProtected() protected function getProtected()
{ {