Fix tests for PHP8...?
This commit is contained in:
parent
9d82154b2f
commit
dee4a2dad5
@ -67,7 +67,7 @@ return static function (array $configArray = []): Container {
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
// Create Config Object
|
||||
$container->set('config', fn () => new Config($configArray));
|
||||
$container->set('config', static fn () => new Config($configArray));
|
||||
|
||||
// Create Cache Object
|
||||
$container->set('cache', static function(ContainerInterface $container): CacheInterface {
|
||||
@ -77,7 +77,7 @@ return static function (array $configArray = []): Container {
|
||||
});
|
||||
|
||||
// Create Aura Router Object
|
||||
$container->set('aura-router', fn() => new RouterContainer);
|
||||
$container->set('aura-router', static fn() => new RouterContainer);
|
||||
|
||||
// Create Html helpers
|
||||
$container->set('html-helper', static function(ContainerInterface $container) {
|
||||
@ -125,8 +125,8 @@ return static function (array $configArray = []): Container {
|
||||
});
|
||||
|
||||
// Create Request Object
|
||||
$container->set('request', fn () => ServerRequestFactory::fromGlobals(
|
||||
$_SERVER,
|
||||
$container->set('request', static fn () => ServerRequestFactory::fromGlobals(
|
||||
$GLOBALS['_SERVER'],
|
||||
$_GET,
|
||||
$_POST,
|
||||
$_COOKIE,
|
||||
@ -134,10 +134,10 @@ return static function (array $configArray = []): Container {
|
||||
));
|
||||
|
||||
// Create session Object
|
||||
$container->set('session', fn () => (new SessionFactory())->newInstance($_COOKIE));
|
||||
$container->set('session', static fn () => (new SessionFactory())->newInstance($_COOKIE));
|
||||
|
||||
// Miscellaneous helper methods
|
||||
$container->set('util', fn ($container) => new Util($container));
|
||||
$container->set('util', static fn ($container) => new Util($container));
|
||||
|
||||
// Models
|
||||
$container->set('kitsu-model', static function(ContainerInterface $container): Kitsu\Model {
|
||||
@ -170,10 +170,10 @@ return static function (array $configArray = []): Container {
|
||||
|
||||
return $model;
|
||||
});
|
||||
$container->set('anime-model', fn ($container) => new Model\Anime($container));
|
||||
$container->set('manga-model', fn ($container) => new Model\Manga($container));
|
||||
$container->set('anime-collection-model', fn ($container) => new Model\AnimeCollection($container));
|
||||
$container->set('manga-collection-model', fn ($container) => new Model\MangaCollection($container));
|
||||
$container->set('anime-model', static fn ($container) => new Model\Anime($container));
|
||||
$container->set('manga-model', static fn ($container) => new Model\Manga($container));
|
||||
$container->set('anime-collection-model', static fn ($container) => new Model\AnimeCollection($container));
|
||||
$container->set('manga-collection-model', static fn ($container) => new Model\MangaCollection($container));
|
||||
$container->set('settings-model', static function($container) {
|
||||
$model = new Model\Settings($container->get('config'));
|
||||
$model->setContainer($container);
|
||||
@ -181,13 +181,13 @@ return static function (array $configArray = []): Container {
|
||||
});
|
||||
|
||||
// Miscellaneous Classes
|
||||
$container->set('auth', fn ($container) => new Kitsu\Auth($container));
|
||||
$container->set('url-generator', fn ($container) => new UrlGenerator($container));
|
||||
$container->set('auth', static fn ($container) => new Kitsu\Auth($container));
|
||||
$container->set('url-generator', static fn ($container) => new UrlGenerator($container));
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Dispatcher
|
||||
// -------------------------------------------------------------------------
|
||||
$container->set('dispatcher', fn ($container) => new Dispatcher($container));
|
||||
$container->set('dispatcher', static fn ($container) => new Dispatcher($container));
|
||||
|
||||
return $container;
|
||||
};
|
||||
|
@ -5,8 +5,8 @@ namespace Aviat\AnimeClient;
|
||||
$whose = $config->get('whose_list') . "'s ";
|
||||
$lastSegment = $urlGenerator->lastSegment();
|
||||
$extraSegment = $lastSegment === 'list' ? '/list' : '';
|
||||
$hasAnime = stripos($_SERVER['REQUEST_URI'], 'anime') !== FALSE;
|
||||
$hasManga = stripos($_SERVER['REQUEST_URI'], 'manga') !== FALSE;
|
||||
$hasAnime = stripos($GLOBALS['_SERVER']['REQUEST_URI'], 'anime') !== FALSE;
|
||||
$hasManga = stripos($GLOBALS['_SERVER']['REQUEST_URI'], 'manga') !== FALSE;
|
||||
|
||||
?>
|
||||
<div id="main-nav" class="flex flex-align-end flex-wrap">
|
||||
@ -84,7 +84,7 @@ $hasManga = stripos($_SERVER['REQUEST_URI'], 'manga') !== FALSE;
|
||||
<?php if ($container->get('util')->isViewPage() && ($hasAnime || $hasManga)): ?>
|
||||
<nav>
|
||||
<?= $helper->menu($menu_name) ?>
|
||||
<?php if (stripos($_SERVER['REQUEST_URI'], 'history') === FALSE): ?>
|
||||
<?php if (stripos($GLOBALS['_SERVER']['REQUEST_URI'], 'history') === FALSE): ?>
|
||||
<br />
|
||||
<ul>
|
||||
<?php $currentView = Util::eq('list', $lastSegment) ? 'list' : 'cover' ?>
|
||||
|
@ -49,11 +49,11 @@
|
||||
"ext-gd": "*",
|
||||
"ext-pdo": "*",
|
||||
"filp/whoops": "^2.1",
|
||||
"laminas/laminas-diactoros": "^2.2.3",
|
||||
"laminas/laminas-diactoros": "^2.5.0",
|
||||
"laminas/laminas-httphandlerrunner": "^1.1.0",
|
||||
"maximebf/consolekit": "^1.0.3",
|
||||
"monolog/monolog": "^2.0.2",
|
||||
"php": ">=7.4",
|
||||
"php": "^7.4 || ~8.0.0",
|
||||
"psr/container": "^1.0.0",
|
||||
"psr/http-message": "^1.0.1",
|
||||
"psr/log": "^1.1.3",
|
||||
|
2
console
2
console
@ -7,7 +7,7 @@ require_once __DIR__ . '/vendor/autoload.php';
|
||||
use Aviat\AnimeClient\Command;
|
||||
use ConsoleKit\Console;
|
||||
|
||||
$_SERVER['HTTP_HOST'] = 'localhost';
|
||||
$GLOBALS['_SERVER']['HTTP_HOST'] = 'localhost';
|
||||
|
||||
define('APP_DIR', __DIR__ . '/app');
|
||||
define('TEMPLATE_DIR', APP_DIR . '/templates');
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$verb = strtolower($_SERVER['REQUEST_METHOD']);
|
||||
$verb = strtolower($GLOBALS['_SERVER']['REQUEST_METHOD']);
|
||||
|
||||
// Send request method if nothing else is specified
|
||||
if (empty($_GET))
|
||||
|
@ -7,7 +7,10 @@
|
||||
</coverage>
|
||||
<testsuites>
|
||||
<testsuite name="AnimeClient">
|
||||
<directory>tests</directory>
|
||||
<directory>tests/AnimeClient</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Ion">
|
||||
<directory>tests/Ion</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
|
@ -168,7 +168,7 @@ abstract class BaseCommand extends Command {
|
||||
|
||||
// Create Request/Response Objects
|
||||
$container->set('request', fn () => ServerRequestFactory::fromGlobals(
|
||||
$_SERVER,
|
||||
$GLOBALS['_SERVER'],
|
||||
$_GET,
|
||||
$_POST,
|
||||
$_COOKIE,
|
||||
|
@ -54,7 +54,7 @@ final class FormGenerator {
|
||||
{
|
||||
try
|
||||
{
|
||||
return new static($container);
|
||||
return new self($container);
|
||||
}
|
||||
catch (\Throwable $e)
|
||||
{
|
||||
@ -74,7 +74,7 @@ final class FormGenerator {
|
||||
{
|
||||
$type = $form['type'];
|
||||
$display = $form['display'] ?? TRUE;
|
||||
$value = $form['value'] ?? '';
|
||||
$value = $form['value'] ?? $form['default'] ?? '';
|
||||
|
||||
if ($display === FALSE)
|
||||
{
|
||||
@ -101,6 +101,7 @@ final class FormGenerator {
|
||||
'1' => 'Yes',
|
||||
'0' => 'No',
|
||||
];
|
||||
$params['strict'] = true;
|
||||
unset($params['attribs']['id']);
|
||||
break;
|
||||
|
||||
|
@ -35,13 +35,7 @@ class Config extends AbstractType {
|
||||
public ?string $asset_path; // Path to public folder for urls
|
||||
|
||||
/**
|
||||
* @deprecated Use 'theme' instead
|
||||
* @var bool
|
||||
*/
|
||||
public $dark_theme; /* Deprecated */
|
||||
|
||||
/**
|
||||
* @var string The PHP timezone
|
||||
* The PHP timezone
|
||||
*/
|
||||
public string $timezone = '';
|
||||
|
||||
@ -73,16 +67,22 @@ class Config extends AbstractType {
|
||||
|
||||
public bool $secure_urls = TRUE;
|
||||
|
||||
public bool $show_anime_collection = FALSE;
|
||||
/**
|
||||
* @var string|bool
|
||||
*/
|
||||
public $show_anime_collection = FALSE;
|
||||
|
||||
public bool $show_manga_collection = FALSE;
|
||||
/**
|
||||
* @var string|bool
|
||||
*/
|
||||
public $show_manga_collection = FALSE;
|
||||
|
||||
/**
|
||||
* CSS theme: light, dark, or auto-switching
|
||||
*
|
||||
* @var 'auto' | 'light' | 'dark'
|
||||
*/
|
||||
public ?string $theme;
|
||||
public ?string $theme = 'auto';
|
||||
|
||||
public ?string $whose_list;
|
||||
|
||||
|
@ -27,7 +27,10 @@ class Anilist extends AbstractType {
|
||||
|
||||
public ?string $access_token;
|
||||
|
||||
public ?int $access_token_expires;
|
||||
/**
|
||||
* @var int|string|null
|
||||
*/
|
||||
public $access_token_expires;
|
||||
|
||||
public ?string $refresh_token;
|
||||
|
||||
|
@ -19,9 +19,6 @@ namespace Aviat\AnimeClient\Types\Config;
|
||||
use Aviat\AnimeClient\Types\AbstractType;
|
||||
|
||||
class Cache extends AbstractType {
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $driver = 'null';
|
||||
|
||||
public ?string $host;
|
||||
@ -33,13 +30,7 @@ class Cache extends AbstractType {
|
||||
|
||||
public ?string $database;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public array $connection = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public array $options = [];
|
||||
public ?array $options;
|
||||
}
|
@ -116,7 +116,7 @@ class AnimeClientTestCase extends TestCase {
|
||||
public function setSuperGlobals($supers = []): void
|
||||
{
|
||||
$default = [
|
||||
'_SERVER' => $_SERVER,
|
||||
'_SERVER' => $GLOBALS['_SERVER'],
|
||||
'_GET' => $_GET,
|
||||
'_POST' => $_POST,
|
||||
'_COOKIE' => $_COOKIE,
|
||||
@ -125,7 +125,7 @@ class AnimeClientTestCase extends TestCase {
|
||||
|
||||
$request = \call_user_func_array(
|
||||
[ServerRequestFactory::class, 'fromGlobals'],
|
||||
array_merge($default, $supers)
|
||||
array_values(array_merge($default, $supers)),
|
||||
);
|
||||
$this->container->setInstance('request', $request);
|
||||
$this->container->set('response', static function() {
|
||||
|
@ -35,12 +35,12 @@ class ControllerTest extends AnimeClientTestCase {
|
||||
parent::setUp();
|
||||
|
||||
// Create Request/Response Objects
|
||||
$_SERVER['HTTP_REFERER'] = '';
|
||||
$GLOBALS['_SERVER']['HTTP_REFERER'] = '';
|
||||
$this->setSuperGlobals([
|
||||
'_GET' => [],
|
||||
'_POST' => [],
|
||||
'_COOKIE' => [],
|
||||
'_SERVER' => $_SERVER,
|
||||
'_SERVER' => $GLOBALS['_SERVER'],
|
||||
'_FILES' => []
|
||||
]);
|
||||
|
||||
|
@ -35,7 +35,7 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
protected function doSetUp($config, $uri, $host): void
|
||||
{
|
||||
// Set up the environment
|
||||
$_SERVER = array_merge($_SERVER, [
|
||||
$GLOBALS['_SERVER'] = array_merge($GLOBALS['_SERVER'], [
|
||||
'REQUEST_METHOD' => 'GET',
|
||||
'REQUEST_URI' => $uri,
|
||||
'PATH_INFO' => $uri,
|
||||
@ -44,7 +44,7 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
]);
|
||||
|
||||
$this->setSuperGlobals([
|
||||
'_SERVER' => $_SERVER
|
||||
'_SERVER' => $GLOBALS['_SERVER']
|
||||
]);
|
||||
|
||||
$logger = new Logger('test_logger');
|
||||
|
@ -246,30 +246,14 @@ const SETTINGS_MAP = [
|
||||
|
||||
|
||||
class FormGeneratorTest extends AnimeClientTestCase {
|
||||
protected $generator;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->generator = FormGenerator::new($this->container);
|
||||
}
|
||||
|
||||
public function testSanity(): void
|
||||
{
|
||||
$generator = FormGenerator::new($this->container);
|
||||
$this->assertInstanceOf(FormGenerator::class, $generator);
|
||||
}
|
||||
|
||||
public function testGeneration(): void
|
||||
{
|
||||
// $html = $this->generator->generate('database', SETTINGS_MAP);
|
||||
// $this->assertMatchesHtmlSnapshot($html);
|
||||
$generator = FormGenerator::new($this->container);
|
||||
foreach (SETTINGS_MAP as $section => $fields)
|
||||
{
|
||||
foreach ($fields as $name => $config)
|
||||
{
|
||||
$html = $this->generator->generate($name, $config);
|
||||
$html = $generator->generate($name, $config);
|
||||
$this->assertMatchesSnapshot($html);
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<input id="whose_list" type="text" name="whose_list" value="" />
|
||||
<input id="whose_list" type="text" name="whose_list" value="Somebody" />
|
||||
|
@ -1,5 +1,5 @@
|
||||
<select id="theme" name="theme">
|
||||
<option value="auto">Automatically match OS theme</option>
|
||||
<option value="auto" selected>Automatically match OS theme</option>
|
||||
<option value="light">Original Light Theme</option>
|
||||
<option value="dark">Dark Theme</option>
|
||||
</select>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<select id="type" name="type">
|
||||
<option value="mysql">MySQL</option>
|
||||
<option value="pgsql">PostgreSQL</option>
|
||||
<option value="sqlite">SQLite</option>
|
||||
<option value="sqlite" selected>SQLite</option>
|
||||
</select>
|
||||
|
@ -1 +1 @@
|
||||
<input id="file" type="text" name="file" value="" />
|
||||
<input id="file" type="text" name="file" value="anime_collection.sqlite" />
|
||||
|
@ -1 +1 @@
|
||||
<input id="access_token_expires" type="text" name="access_token_expires" readonly value="" />
|
||||
<input id="access_token_expires" type="text" name="access_token_expires" readonly value="0" />
|
||||
|
@ -112,7 +112,7 @@ class IonTestCase extends TestCase {
|
||||
public function setSuperGlobals(array $supers = []): void
|
||||
{
|
||||
$default = [
|
||||
'_SERVER' => $_SERVER,
|
||||
'_SERVER' => $GLOBALS['_SERVER'],
|
||||
'_GET' => $_GET,
|
||||
'_POST' => $_POST,
|
||||
'_COOKIE' => $_COOKIE,
|
||||
|
@ -22,7 +22,7 @@ return static function(array $config_array = []) {
|
||||
|
||||
$container->set('request', static function() {
|
||||
return ServerRequestFactory::fromGlobals(
|
||||
$_SERVER,
|
||||
$GLOBALS['_SERVER'],
|
||||
$_GET,
|
||||
$_POST,
|
||||
$_COOKIE,
|
||||
|
Loading…
Reference in New Issue
Block a user