Tweak tests for new version of PHPUnit

This commit is contained in:
Timothy Warren 2019-12-06 09:15:49 -05:00
parent 347674f9e5
commit b4b5c63d65
20 changed files with 46 additions and 50 deletions

View File

@ -31,7 +31,7 @@ Update your anime/manga list on Kitsu.io and MyAnimeList.net
### Requirements
* PHP 7.1+
* PHP 7.2+
* PDO SQLite or PDO PostgreSQL (For collection tab)
* GD extension for caching images

View File

@ -93,12 +93,12 @@ class InlineCommentSniff implements Sniff
private function _checkCommentStyle(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
if ($tokens[$stackPtr]['content']{0} === '#') {
if ($tokens[$stackPtr]['content'][0] === '#') {
$error = 'Perl-style comments are not allowed; use "// Comment" or DocBlock comments instead';
$phpcsFile->addError($error, $stackPtr, 'WrongStyle');
return FALSE;
} else if (substr($tokens[$stackPtr]['content'], 0, 2) === '/*'
|| $tokens[$stackPtr]['content']{0} === '*'
|| $tokens[$stackPtr]['content'][0] === '*'
) {
$error = 'Multi lines comments are not allowed; use "// Comment" DocBlock comments instead';
$phpcsFile->addError($error, $stackPtr, 'WrongStyle');

View File

@ -9,7 +9,7 @@
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2019 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.5
* @version 4.2
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/

View File

@ -35,7 +35,7 @@ function get_text_to_replace($tokens)
// Tokens have the follow structure if arrays:
// [0] => token type constant
// [1] => raw sytax parsed to that token
// [1] => raw syntax parsed to that token
// [2] => line number
foreach($tokens as $token)
{

View File

@ -16,6 +16,7 @@
namespace Aviat\AnimeClient\API;
use Amp\Artax\Request;
use function Amp\call;
use function Amp\Promise\{all, wait};
use function Aviat\AnimeClient\getApiClient;
@ -35,7 +36,7 @@ final class ParallelAPIRequest {
/**
* Add a request
*
* @param string|\Amp\Artax\Request $request
* @param string|Request $request
* @param string|number $key
* @return self
*/
@ -54,7 +55,7 @@ final class ParallelAPIRequest {
/**
* Add multiple requests
*
* @param string[]|\Amp\Artax\Request[] $requests
* @param string[]|Request[] $requests
* @return self
*/
public function addRequests(array $requests): self
@ -77,7 +78,7 @@ final class ParallelAPIRequest {
foreach ($this->requests as $key => $url)
{
$promises[$key] = call(function () use ($client, $url) {
$promises[$key] = call(static function () use ($client, $url) {
$response = yield $client->request($url);
return yield $response->getBody();
});
@ -100,7 +101,7 @@ final class ParallelAPIRequest {
foreach ($this->requests as $key => $url)
{
$promises[$key] = call(function () use ($client, $url) {
$promises[$key] = call(static function () use ($client, $url) {
return yield $client->request($url);
});
}

View File

@ -28,8 +28,7 @@ class APIRequestBuilderTest extends TestCase {
protected $builder;
public function setUp()
{
public function setUp(): void {
$this->builder = new class extends APIRequestBuilder {
protected $baseUrl = 'https://httpbin.org/';

View File

@ -23,8 +23,7 @@ class CacheTraitTest extends AnimeClientTestCase {
protected $testClass;
public function setUp()
{
public function setUp(): void {
parent::setUp();
$this->testClass = new class {
use CacheTrait;

View File

@ -26,8 +26,7 @@ class JsonAPITest extends TestCase {
protected $organizedIncludes;
protected $inlineIncluded;
public function setUp()
{
public function setUp(): void {
$dir = __DIR__ . '/../test_data/JsonAPI';
$this->startData = Json::decodeFile("{$dir}/jsonApiExample.json");
$this->organizedIncludes = Json::decodeFile("{$dir}/organizedIncludes.json");

View File

@ -27,8 +27,7 @@ class AnimeListTransformerTest extends AnimeClientTestCase {
protected $afterTransform;
protected $transformer;
public function setUp()
{
public function setUp(): void {
parent::setUp();
$this->dir = AnimeClientTestCase::TEST_DATA_DIR . '/Kitsu';

View File

@ -27,8 +27,7 @@ class AnimeTransformerTest extends AnimeClientTestCase {
protected $afterTransform;
protected $transformer;
public function setUp()
{
public function setUp(): void {
parent::setUp();
$this->dir = AnimeClientTestCase::TEST_DATA_DIR . '/Kitsu';

View File

@ -33,8 +33,7 @@ class MangaListTransformerTest extends AnimeClientTestCase {
protected $afterTransform;
protected $transformer;
public function setUp()
{
public function setUp(): void {
parent::setUp();
$kitsuModel = $this->container->get('kitsu-model');

View File

@ -28,8 +28,7 @@ class MangaTransformerTest extends AnimeClientTestCase {
protected $afterTransform;
protected $transformer;
public function setUp()
{
public function setUp(): void {
parent::setUp();
$this->dir = AnimeClientTestCase::TEST_DATA_DIR . '/Kitsu';

View File

@ -0,0 +1,5 @@
- null
- null
- null
- null
- null

View File

@ -29,7 +29,7 @@ use Zend\Diactoros\{
ServerRequestFactory
};
\define('ROOT_DIR', __DIR__ . '/../');
\define('ROOT_DIR', realpath(__DIR__ . '/../'));
\define('TEST_DATA_DIR', __DIR__ . '/test_data');
\define('TEST_VIEW_DIR', __DIR__ . '/test_views');
@ -50,7 +50,7 @@ class AnimeClientTestCase extends TestCase {
protected static $staticContainer;
protected static $session_handler;
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
// Use mock session handler
//$session_handler = new TestSessionHandler();
@ -62,7 +62,7 @@ class AnimeClientTestCase extends TestCase {
array_map('unlink', $files);
}
public function setUp()
public function setUp(): void
{
parent::setUp();
@ -139,7 +139,7 @@ class AnimeClientTestCase extends TestCase {
array_merge($default, $supers)
);
$this->container->setInstance('request', $request);
$this->container->set('response', function() {
$this->container->set('response', static function() {
return new HttpResponse();
});
}
@ -165,6 +165,7 @@ class AnimeClientTestCase extends TestCase {
*
* Takes multiple path arguments
*
* @param array $args
* @return mixed - the decoded data
*/
public function getMockFileData(...$args)

View File

@ -25,8 +25,7 @@ class BaseCommandTest extends AnimeClientTestCase {
protected $base;
protected $friend;
public function setUp()
{
public function setUp(): void {
$this->base = new BaseCommand(new Console());
$this->friend = new Friend($this->base);
}

View File

@ -31,8 +31,7 @@ class ControllerTest extends AnimeClientTestCase {
protected $BaseController;
public function setUp()
{
public function setUp(): void {
parent::setUp();
// Create Request/Response Objects

View File

@ -16,6 +16,7 @@
namespace Aviat\AnimeClient\Tests;
use Aura\Router\Route;
use Aviat\AnimeClient\Controller;
use Aviat\AnimeClient\Dispatcher;
use Aviat\AnimeClient\UrlGenerator;
@ -31,7 +32,7 @@ class DispatcherTest extends AnimeClientTestCase {
protected $config;
protected $urlGenerator;
protected function doSetUp($config, $uri, $host)
protected function doSetUp($config, $uri, $host): void
{
// Set up the environment
$_SERVER = array_merge($_SERVER, [
@ -63,13 +64,13 @@ class DispatcherTest extends AnimeClientTestCase {
$this->container->setInstance('url-generator', $this->urlGenerator);
}
public function testRouterSanity()
public function testRouterSanity(): void
{
$this->doSetUp([], '/', 'localhost');
$this->assertInternalType('object', $this->router);
$this->assertIsObject($this->router);
}
public function dataRoute()
public function dataRoute(): array
{
$defaultConfig = [
'routes' => [
@ -142,7 +143,7 @@ class DispatcherTest extends AnimeClientTestCase {
/**
* @dataProvider dataRoute
*/
public function testRoute($config, $controller, $host, $uri)
public function testRoute($config, $controller, $host, $uri): void
{
$this->doSetUp($config, $uri, $host);
@ -150,7 +151,7 @@ class DispatcherTest extends AnimeClientTestCase {
// Check route setup
$this->assertEquals($config['routes'], $this->config->get('routes'), 'Incorrect route path');
$this->assertInternalType('array', $this->router->getOutputRoutes());
$this->assertIsArray($this->router->getOutputRoutes());
// Check environment variables
$this->assertEquals($uri, $request->getServerParams()['REQUEST_URI']);
@ -162,10 +163,10 @@ class DispatcherTest extends AnimeClientTestCase {
// Make sure the route matches, by checking that it is actually an object
$route = $this->router->getRoute();
$this->assertInstanceOf(\Aura\Router\Route::class, $route, 'Route is invalid, not matched');
$this->assertInstanceOf(Route::class, $route, 'Route is invalid, not matched');
}
public function testDefaultRoute()
public function testDefaultRoute(): void
{
$config = [
'config' => [
@ -202,7 +203,7 @@ class DispatcherTest extends AnimeClientTestCase {
$this->urlGenerator->defaultUrl('foo');
}
public function dataGetControllerList()
public function dataGetControllerList(): array
{
$expectedList = [
'anime' => Controller\Anime::class,
@ -246,7 +247,7 @@ class DispatcherTest extends AnimeClientTestCase {
/**
* @dataProvider dataGetControllerList
*/
public function testGetControllerList($config, $expected)
public function testGetControllerList($config, $expected): void
{
$this->doSetUp($config, '/', 'localhost');
$this->assertEquals($expected, $this->router->getControllerList());

View File

@ -24,8 +24,7 @@ class MenuHelperTest extends AnimeClientTestCase {
protected $helper;
protected $urlGenerator;
public function setUp()
{
public function setUp(): void {
parent::setUp();
$this->helper = $this->container->get('html-helper');
$this->urlGenerator = $this->container->get('url-generator');

View File

@ -24,8 +24,7 @@ class MenuGeneratorTest extends AnimeClientTestCase {
protected $generator;
protected $friend;
public function setUp()
{
public function setUp(): void {
parent::setUp();
$this->generator = new MenuGenerator($this->container);
}

View File

@ -22,8 +22,7 @@ class UtilTest extends AnimeClientTestCase {
protected $util;
public function setUp()
{
public function setUp(): void {
parent::setUp();
$this->util = new Util($this->container);
}