Reformat test suite files
This commit is contained in:
parent
327065498b
commit
a0d30c002a
@ -103,10 +103,8 @@ function _iterateToml(TomlBuilder $builder, iterable $data, mixed $parentKey = N
|
||||
? "{$parentKey}.{$key}"
|
||||
: $key;
|
||||
|
||||
if ( ! isSequentialArray($value))
|
||||
{
|
||||
$builder->addTable($newKey);
|
||||
}
|
||||
|
||||
$builder->addTable($newKey);
|
||||
|
||||
_iterateToml($builder, $value, $newKey);
|
||||
}
|
||||
@ -154,12 +152,7 @@ if ( ! function_exists('array_is_list'))
|
||||
*/
|
||||
function isSequentialArray(mixed $array): bool
|
||||
{
|
||||
if ( ! is_array($array))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return array_is_list($array);
|
||||
return is_array($array) && array_is_list($array);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,13 +44,13 @@ class Json
|
||||
* @param int $fileOptions - Options to pass to file_get_contents
|
||||
* @throws JsonException
|
||||
*/
|
||||
public static function encodeFile(string $filename, mixed $data, int $jsonOptions = 0, int $fileOptions = 0): bool
|
||||
public static function encodeFile(string $filename, mixed $data, int $jsonOptions = 0, int $fileOptions = 0): int
|
||||
{
|
||||
$json = self::encode($data, $jsonOptions);
|
||||
|
||||
$res = file_put_contents($filename, $json, $fileOptions);
|
||||
|
||||
return $res !== FALSE;
|
||||
return ($res !== FALSE) ? $res : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,26 +16,30 @@
|
||||
|
||||
namespace Aviat\AnimeClient\Tests\API;
|
||||
|
||||
use Aviat\AnimeClient\API\APIRequestBuilder;
|
||||
use Aviat\Ion\Json;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\NullLogger;
|
||||
use function Amp\Promise\wait;
|
||||
use function Aviat\AnimeClient\getResponse;
|
||||
|
||||
use Aviat\AnimeClient\API\APIRequestBuilder;
|
||||
use Aviat\Ion\Json;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\NullLogger;
|
||||
|
||||
class APIRequestBuilderTest extends TestCase {
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class APIRequestBuilderTest extends TestCase
|
||||
{
|
||||
protected $builder;
|
||||
|
||||
public function setUp(): void {
|
||||
$this->builder = new class extends APIRequestBuilder {
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->builder = new class () extends APIRequestBuilder {
|
||||
protected string $baseUrl = 'https://httpbin.org/';
|
||||
|
||||
protected array $defaultHeaders = ['User-Agent' => "Tim's Anime Client Testsuite / 4.0"];
|
||||
};
|
||||
|
||||
$this->builder->setLogger(new NullLogger);
|
||||
$this->builder->setLogger(new NullLogger());
|
||||
}
|
||||
|
||||
public function testGzipRequest(): void
|
||||
@ -44,12 +48,12 @@ class APIRequestBuilderTest extends TestCase {
|
||||
->getFullRequest();
|
||||
$response = getResponse($request);
|
||||
$body = Json::decode(wait($response->getBody()->buffer()));
|
||||
$this->assertEquals(1, $body['gzipped']);
|
||||
$this->assertTrue($body['gzipped']);
|
||||
}
|
||||
|
||||
public function testInvalidRequestMethod(): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->builder->newRequest('FOO', 'gzip')
|
||||
->getFullRequest();
|
||||
}
|
||||
@ -63,7 +67,7 @@ class APIRequestBuilderTest extends TestCase {
|
||||
$response = getResponse($request);
|
||||
$body = Json::decode(wait($response->getBody()->buffer()));
|
||||
|
||||
$this->assertEquals('Basic dXNlcm5hbWU6cGFzc3dvcmQ=', $body['headers']['Authorization']);
|
||||
$this->assertSame('Basic dXNlcm5hbWU6cGFzc3dvcmQ=', $body['headers']['Authorization']);
|
||||
}
|
||||
|
||||
public function testRequestWithQueryString(): void
|
||||
@ -71,17 +75,17 @@ class APIRequestBuilderTest extends TestCase {
|
||||
$query = [
|
||||
'foo' => 'bar',
|
||||
'bar' => [
|
||||
'foo' => 'bar'
|
||||
'foo' => 'bar',
|
||||
],
|
||||
'baz' => [
|
||||
'bar' => 'foo'
|
||||
]
|
||||
'bar' => 'foo',
|
||||
],
|
||||
];
|
||||
|
||||
$expected = [
|
||||
'foo' => 'bar',
|
||||
'bar[foo]' => 'bar',
|
||||
'baz[bar]' => 'foo'
|
||||
'baz[bar]' => 'foo',
|
||||
'foo' => 'bar',
|
||||
];
|
||||
|
||||
$request = $this->builder->newRequest('GET', 'get')
|
||||
@ -91,14 +95,14 @@ class APIRequestBuilderTest extends TestCase {
|
||||
$response = getResponse($request);
|
||||
$body = Json::decode(wait($response->getBody()->buffer()));
|
||||
|
||||
$this->assertEquals($expected, $body['args']);
|
||||
$this->assertSame($expected, $body['args']);
|
||||
}
|
||||
|
||||
public function testFormValueRequest(): void
|
||||
{
|
||||
$formValues = [
|
||||
'bar' => 'foo',
|
||||
'foo' => 'bar',
|
||||
'bar' => 'foo'
|
||||
];
|
||||
|
||||
$request = $this->builder->newRequest('POST', 'post')
|
||||
@ -108,7 +112,7 @@ class APIRequestBuilderTest extends TestCase {
|
||||
$response = getResponse($request);
|
||||
$body = Json::decode(wait($response->getBody()->buffer()));
|
||||
|
||||
$this->assertEquals($formValues, $body['form']);
|
||||
$this->assertSame($formValues, $body['form']);
|
||||
}
|
||||
|
||||
public function testFullUrlRequest(): void
|
||||
@ -119,9 +123,9 @@ class APIRequestBuilderTest extends TestCase {
|
||||
'baz' => [2, 3, 4],
|
||||
'bazbar' => [
|
||||
'a' => 1,
|
||||
'b' => 2
|
||||
]
|
||||
]
|
||||
'b' => 2,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$request = $this->builder->newRequest('PUT', 'https://httpbin.org/put')
|
||||
@ -132,6 +136,6 @@ class APIRequestBuilderTest extends TestCase {
|
||||
$response = getResponse($request);
|
||||
$body = Json::decode(wait($response->getBody()->buffer()));
|
||||
|
||||
$this->assertEquals($data, $body['json']);
|
||||
$this->assertSame($data, $body['json']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,17 @@ namespace Aviat\AnimeClient\Tests\API;
|
||||
use Aviat\AnimeClient\API\CacheTrait;
|
||||
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||
|
||||
class CacheTraitTest extends AnimeClientTestCase {
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class CacheTraitTest extends AnimeClientTestCase
|
||||
{
|
||||
protected $testClass;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->testClass = new class {
|
||||
$this->testClass = new class () {
|
||||
use CacheTrait;
|
||||
};
|
||||
}
|
||||
@ -34,6 +38,6 @@ class CacheTraitTest extends AnimeClientTestCase {
|
||||
{
|
||||
$cachePool = $this->container->get('cache');
|
||||
$this->testClass->setCache($cachePool);
|
||||
$this->assertEquals($cachePool, $this->testClass->getCache());
|
||||
$this->assertSame($cachePool, $this->testClass->getCache());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,11 +18,14 @@ namespace Aviat\AnimeClient\Tests\API\Kitsu;
|
||||
|
||||
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||
|
||||
class ModelTest extends AnimeClientTestCase {
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class ModelTest extends AnimeClientTestCase
|
||||
{
|
||||
protected $model;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setup();
|
||||
$this->model = $this->container->get('kitsu-model');
|
||||
@ -30,13 +33,13 @@ class ModelTest extends AnimeClientTestCase {
|
||||
|
||||
public function testGetAnimeKitsuIdFromMALId(): void
|
||||
{
|
||||
$kitsuId = $this->model->getKitsuIdFromMALId("1", 'anime');
|
||||
self::assertEquals("1", $kitsuId);
|
||||
$kitsuId = $this->model->getKitsuIdFromMALId('1', 'anime');
|
||||
$this->assertSame('1', $kitsuId);
|
||||
}
|
||||
|
||||
public function testGetNullFromMALAnimeId(): void
|
||||
{
|
||||
$kitsuId = $this->model->getKitsuIdFromMALId("0", 'anime');
|
||||
self::assertNull($kitsuId);
|
||||
$kitsuId = $this->model->getKitsuIdFromMALId('0', 'anime');
|
||||
$this->assertNull($kitsuId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,17 @@ use Aviat\AnimeClient\API\Kitsu\Transformer\AnimeListTransformer;
|
||||
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||
use Aviat\Ion\Json;
|
||||
|
||||
class AnimeListTransformerTest extends AnimeClientTestCase {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class AnimeListTransformerTest extends AnimeClientTestCase
|
||||
{
|
||||
protected string $dir;
|
||||
protected array $beforeTransform;
|
||||
protected AnimeListTransformer $transformer;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->dir = AnimeClientTestCase::TEST_DATA_DIR . '/Kitsu';
|
||||
|
||||
@ -37,7 +42,7 @@ class AnimeListTransformerTest extends AnimeClientTestCase {
|
||||
|
||||
public function testTransform(): void
|
||||
{
|
||||
$this->markTestSkipped("Old test data");
|
||||
$this->markTestSkipped('Old test data');
|
||||
|
||||
$actual = $this->transformer->transform($this->beforeTransform);
|
||||
$this->assertMatchesSnapshot($actual);
|
||||
@ -53,8 +58,8 @@ class AnimeListTransformerTest extends AnimeClientTestCase {
|
||||
'episodes_watched' => 38,
|
||||
'rewatched' => 0,
|
||||
'notes' => 'Very formulaic.',
|
||||
'edit' => true
|
||||
]
|
||||
'edit' => TRUE,
|
||||
],
|
||||
], [
|
||||
'input' => [
|
||||
'id' => 14047981,
|
||||
@ -66,8 +71,8 @@ class AnimeListTransformerTest extends AnimeClientTestCase {
|
||||
'notes' => 'Very formulaic.',
|
||||
'edit' => 'true',
|
||||
'private' => 'On',
|
||||
'rewatching' => 'On'
|
||||
]
|
||||
'rewatching' => 'On',
|
||||
],
|
||||
], [
|
||||
'input' => [
|
||||
'id' => 14047983,
|
||||
@ -79,18 +84,17 @@ class AnimeListTransformerTest extends AnimeClientTestCase {
|
||||
'notes' => '',
|
||||
'edit' => 'true',
|
||||
'private' => 'On',
|
||||
'rewatching' => 'On'
|
||||
]
|
||||
'rewatching' => 'On',
|
||||
],
|
||||
]];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataUntransform
|
||||
* @param array $input
|
||||
*/
|
||||
public function testUntransform(array $input): void
|
||||
{
|
||||
$actual = $this->transformer->untransform($input);
|
||||
$this->assertMatchesSnapshot($actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,13 +20,17 @@ use Aviat\AnimeClient\API\Kitsu\Transformer\AnimeTransformer;
|
||||
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||
use Aviat\Ion\Json;
|
||||
|
||||
class AnimeTransformerTest extends AnimeClientTestCase {
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class AnimeTransformerTest extends AnimeClientTestCase
|
||||
{
|
||||
protected $dir;
|
||||
protected $beforeTransform;
|
||||
protected $transformer;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->dir = AnimeClientTestCase::TEST_DATA_DIR . '/Kitsu';
|
||||
|
||||
@ -40,4 +44,4 @@ class AnimeTransformerTest extends AnimeClientTestCase {
|
||||
$actual = $this->transformer->transform($this->beforeTransform);
|
||||
$this->assertMatchesSnapshot($actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,11 +20,16 @@ use Aviat\AnimeClient\API\Kitsu\Transformer\CharacterTransformer;
|
||||
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||
use Aviat\Ion\Json;
|
||||
|
||||
class CharacterTransformerTest extends AnimeClientTestCase {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class CharacterTransformerTest extends AnimeClientTestCase
|
||||
{
|
||||
protected array $beforeTransform;
|
||||
protected string $dir;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->dir = AnimeClientTestCase::TEST_DATA_DIR . '/Kitsu';
|
||||
|
||||
@ -37,4 +42,4 @@ class CharacterTransformerTest extends AnimeClientTestCase {
|
||||
$actual = (new CharacterTransformer())->transform($this->beforeTransform);
|
||||
$this->assertMatchesSnapshot($actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,16 +16,20 @@
|
||||
|
||||
namespace Aviat\AnimeClient\Tests\API\Kitsu\Transformer;
|
||||
|
||||
use Aviat\AnimeClient\API\Kitsu\Transformer\AnimeHistoryTransformer;
|
||||
use Aviat\AnimeClient\API\Kitsu\Transformer\MangaHistoryTransformer;
|
||||
use Aviat\AnimeClient\API\Kitsu\Transformer\{AnimeHistoryTransformer, MangaHistoryTransformer};
|
||||
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||
use Aviat\Ion\Json;
|
||||
|
||||
class HistoryTransformerTest extends AnimeClientTestCase {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class HistoryTransformerTest extends AnimeClientTestCase
|
||||
{
|
||||
protected array $beforeTransform;
|
||||
protected string $dir;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->dir = AnimeClientTestCase::TEST_DATA_DIR . '/Kitsu';
|
||||
|
||||
@ -35,7 +39,7 @@ class HistoryTransformerTest extends AnimeClientTestCase {
|
||||
|
||||
public function testAnimeTransform(): void
|
||||
{
|
||||
$this->markTestSkipped("Old test data");
|
||||
$this->markTestSkipped('Old test data');
|
||||
|
||||
$actual = (new AnimeHistoryTransformer())->transform($this->beforeTransform);
|
||||
$this->assertMatchesSnapshot($actual);
|
||||
@ -46,4 +50,4 @@ class HistoryTransformerTest extends AnimeClientTestCase {
|
||||
$actual = (new MangaHistoryTransformer())->transform($this->beforeTransform);
|
||||
$this->assertMatchesSnapshot($actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,14 +24,18 @@ use Aviat\AnimeClient\Types\{
|
||||
};
|
||||
use Aviat\Ion\Json;
|
||||
|
||||
class MangaListTransformerTest extends AnimeClientTestCase {
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class MangaListTransformerTest extends AnimeClientTestCase
|
||||
{
|
||||
protected $dir;
|
||||
protected $rawBefore;
|
||||
protected $beforeTransform;
|
||||
protected $transformer;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->dir = AnimeClientTestCase::TEST_DATA_DIR . '/Kitsu';
|
||||
@ -56,17 +60,17 @@ class MangaListTransformerTest extends AnimeClientTestCase {
|
||||
'chapters_read' => 67,
|
||||
'manga' => [
|
||||
'id' => '12345',
|
||||
'titles' => ["Bokura wa Minna Kawaisou"],
|
||||
'titles' => ['Bokura wa Minna Kawaisou'],
|
||||
'alternate_title' => NULL,
|
||||
'slug' => "bokura-wa-minna-kawaisou",
|
||||
'url' => "https://kitsu.io/manga/bokura-wa-minna-kawaisou",
|
||||
'slug' => 'bokura-wa-minna-kawaisou',
|
||||
'url' => 'https://kitsu.io/manga/bokura-wa-minna-kawaisou',
|
||||
'type' => 'manga',
|
||||
'image' => 'https://media.kitsu.io/manga/poster_images/20286/small.jpg?1434293999',
|
||||
'genres' => [],
|
||||
],
|
||||
'status' => 'current',
|
||||
'notes' => '',
|
||||
'rereading' => false,
|
||||
'rereading' => FALSE,
|
||||
'reread_count' => 0,
|
||||
'new_rating' => 9,
|
||||
];
|
||||
@ -78,14 +82,13 @@ class MangaListTransformerTest extends AnimeClientTestCase {
|
||||
'data' => FormItemData::from([
|
||||
'status' => 'current',
|
||||
'progress' => 67,
|
||||
'reconsuming' => false,
|
||||
'reconsuming' => FALSE,
|
||||
'reconsumeCount' => 0,
|
||||
'notes' => '',
|
||||
'ratingTwenty' => 18,
|
||||
])
|
||||
]),
|
||||
]);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -20,13 +20,17 @@ use Aviat\AnimeClient\API\Kitsu\Transformer\MangaTransformer;
|
||||
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||
use Aviat\Ion\Json;
|
||||
|
||||
class MangaTransformerTest extends AnimeClientTestCase {
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class MangaTransformerTest extends AnimeClientTestCase
|
||||
{
|
||||
protected $dir;
|
||||
protected $beforeTransform;
|
||||
protected $transformer;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->dir = AnimeClientTestCase::TEST_DATA_DIR . '/Kitsu';
|
||||
|
||||
@ -40,4 +44,4 @@ class MangaTransformerTest extends AnimeClientTestCase {
|
||||
$actual = $this->transformer->transform($this->beforeTransform);
|
||||
$this->assertMatchesSnapshot($actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,11 +20,16 @@ use Aviat\AnimeClient\API\Kitsu\Transformer\PersonTransformer;
|
||||
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||
use Aviat\Ion\Json;
|
||||
|
||||
class PersonTransformerTest extends AnimeClientTestCase {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class PersonTransformerTest extends AnimeClientTestCase
|
||||
{
|
||||
protected array $beforeTransform;
|
||||
protected string $dir;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->dir = AnimeClientTestCase::TEST_DATA_DIR . '/Kitsu';
|
||||
|
||||
@ -37,4 +42,4 @@ class PersonTransformerTest extends AnimeClientTestCase {
|
||||
$actual = (new PersonTransformer())->transform($this->beforeTransform);
|
||||
$this->assertMatchesSnapshot($actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,11 +20,16 @@ use Aviat\AnimeClient\API\Kitsu\Transformer\UserTransformer;
|
||||
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||
use Aviat\Ion\Json;
|
||||
|
||||
class UserTransformerTest extends AnimeClientTestCase {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class UserTransformerTest extends AnimeClientTestCase
|
||||
{
|
||||
protected array $beforeTransform;
|
||||
protected string $dir;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->dir = AnimeClientTestCase::TEST_DATA_DIR . '/Kitsu';
|
||||
|
||||
@ -37,4 +42,4 @@ class UserTransformerTest extends AnimeClientTestCase {
|
||||
$actual = (new UserTransformer())->transform($this->beforeTransform);
|
||||
$this->assertMatchesSnapshot($actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,11 @@ use Aviat\AnimeClient\API\ParallelAPIRequest;
|
||||
use Aviat\Ion\Friend;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ParallelAPIRequestTest extends TestCase {
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class ParallelAPIRequestTest extends TestCase
|
||||
{
|
||||
public function testAddStringUrlRequest()
|
||||
{
|
||||
$requester = new ParallelAPIRequest();
|
||||
@ -29,14 +32,14 @@ class ParallelAPIRequestTest extends TestCase {
|
||||
|
||||
$friend = new Friend($requester);
|
||||
|
||||
$this->assertEquals($friend->requests, ['https://httpbin.org']);
|
||||
$this->assertSame($friend->requests, ['https://httpbin.org']);
|
||||
}
|
||||
|
||||
public function testAddStringUrlRequests()
|
||||
{
|
||||
$requests = [
|
||||
'foo' => 'http://example.com',
|
||||
'bar' => 'https://example.com'
|
||||
'bar' => 'https://example.com',
|
||||
];
|
||||
|
||||
$requester = new ParallelAPIRequest();
|
||||
@ -44,6 +47,6 @@ class ParallelAPIRequestTest extends TestCase {
|
||||
|
||||
$friend = new Friend($requester);
|
||||
|
||||
$this->assertEquals($friend->requests, $requests);
|
||||
$this->assertSame($friend->requests, $requests);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,23 +16,20 @@
|
||||
|
||||
namespace Aviat\AnimeClient\Tests;
|
||||
|
||||
use function Aviat\AnimeClient\arrayToToml;
|
||||
use function Aviat\AnimeClient\checkFolderPermissions;
|
||||
use function Aviat\AnimeClient\clearCache;
|
||||
use function Aviat\AnimeClient\colNotEmpty;
|
||||
use function Aviat\AnimeClient\getLocalImg;
|
||||
use function Aviat\AnimeClient\getResponse;
|
||||
use function Aviat\AnimeClient\isSequentialArray;
|
||||
use function Aviat\AnimeClient\tomlToArray;
|
||||
use DateTime;
|
||||
use function Aviat\AnimeClient\{arrayToToml, checkFolderPermissions, clearCache, colNotEmpty, getLocalImg, getResponse, isSequentialArray, tomlToArray};
|
||||
|
||||
class AnimeClientTest extends AnimeClientTestCase
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class AnimeClientTest extends AnimeClientTestCase
|
||||
{
|
||||
public function testArrayToToml (): void
|
||||
public function testArrayToToml(): void
|
||||
{
|
||||
$arr = [
|
||||
'cat' => false,
|
||||
'cat' => FALSE,
|
||||
'foo' => 'bar',
|
||||
'dateTime' => (array) new \DateTime(),
|
||||
'dateTime' => (array) new DateTime(),
|
||||
'bar' => [
|
||||
'a' => 1,
|
||||
'b' => 2,
|
||||
@ -44,7 +41,7 @@ class AnimeClientTest extends AnimeClientTestCase
|
||||
'z' => [3, 6, 9],
|
||||
],
|
||||
'foobar' => [
|
||||
'z' => 22/7,
|
||||
'z' => 22 / 7,
|
||||
'a' => [
|
||||
'aa' => -8,
|
||||
'b' => [
|
||||
@ -65,16 +62,16 @@ class AnimeClientTest extends AnimeClientTestCase
|
||||
public function testArrayToTomlNullValue(): void
|
||||
{
|
||||
$arr = [
|
||||
'cat' => false,
|
||||
'bat' => null,
|
||||
'cat' => FALSE,
|
||||
'bat' => NULL,
|
||||
'foo' => 'bar',
|
||||
];
|
||||
|
||||
$toml = arrayToToml($arr);
|
||||
$parsedArray = tomlToArray($toml);
|
||||
|
||||
$this->assertEquals([
|
||||
'cat' => false,
|
||||
$this->assertSame([
|
||||
'cat' => FALSE,
|
||||
'foo' => 'bar',
|
||||
], $parsedArray);
|
||||
}
|
||||
@ -84,7 +81,7 @@ class AnimeClientTest extends AnimeClientTestCase
|
||||
$this->assertFalse(isSequentialArray(0));
|
||||
$this->assertFalse(isSequentialArray([50 => 'foo']));
|
||||
$this->assertTrue(isSequentialArray([]));
|
||||
$this->assertTrue(isSequentialArray([1,2,3,4,5]));
|
||||
$this->assertTrue(isSequentialArray([1, 2, 3, 4, 5]));
|
||||
}
|
||||
|
||||
public function testGetResponse(): void
|
||||
@ -96,19 +93,19 @@ class AnimeClientTest extends AnimeClientTestCase
|
||||
{
|
||||
$config = $this->container->get('config');
|
||||
$actual = checkFolderPermissions($config);
|
||||
$this->assertTrue(is_array($actual));
|
||||
$this->assertIsArray($actual);
|
||||
}
|
||||
|
||||
public function testGetLocalImageEmptyUrl(): void
|
||||
{
|
||||
$actual = getLocalImg('');
|
||||
$this->assertEquals('images/placeholder.webp', $actual);
|
||||
$this->assertSame('images/placeholder.webp', $actual);
|
||||
}
|
||||
|
||||
public function testGetLocalImageBadUrl(): void
|
||||
{
|
||||
$actual = getLocalImg('//foo.bar');
|
||||
$this->assertEquals('images/placeholder.webp', $actual);
|
||||
$this->assertSame('images/placeholder.webp', $actual);
|
||||
}
|
||||
|
||||
public function testColNotEmpty(): void
|
||||
@ -125,12 +122,12 @@ class AnimeClientTest extends AnimeClientTestCase
|
||||
'foo' => 'baz',
|
||||
]];
|
||||
|
||||
$this->assertEquals(false, colNotEmpty($hasEmptyCols, 'foo'));
|
||||
$this->assertEquals(true, colNotEmpty($hasNonEmptyCols, 'foo'));
|
||||
$this->assertFalse(colNotEmpty($hasEmptyCols, 'foo'));
|
||||
$this->assertTrue(colNotEmpty($hasNonEmptyCols, 'foo'));
|
||||
}
|
||||
|
||||
public function testClearCache(): void
|
||||
{
|
||||
$this->assertTrue(clearCache($this->container->get('cache')));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,27 +16,28 @@
|
||||
|
||||
namespace Aviat\AnimeClient\Tests;
|
||||
|
||||
use Aviat\Ion\Di\ContainerAware;
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
use function Aviat\Ion\_dir;
|
||||
|
||||
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
|
||||
use Aviat\Ion\Json;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Spatie\Snapshots\MatchesSnapshots;
|
||||
|
||||
use Laminas\Diactoros\{
|
||||
Response as HttpResponse,
|
||||
ServerRequestFactory
|
||||
};
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Spatie\Snapshots\MatchesSnapshots;
|
||||
use function Aviat\Ion\_dir;
|
||||
use function call_user_func_array;
|
||||
|
||||
use const Aviat\AnimeClient\{
|
||||
SLUG_PATTERN,
|
||||
DEFAULT_CONTROLLER,
|
||||
SLUG_PATTERN,
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for TestCases
|
||||
*/
|
||||
class AnimeClientTestCase extends TestCase {
|
||||
class AnimeClientTestCase extends TestCase
|
||||
{
|
||||
use ContainerAware;
|
||||
use MatchesSnapshots;
|
||||
|
||||
@ -55,7 +56,7 @@ class AnimeClientTestCase extends TestCase {
|
||||
array_map('unlink', $files);
|
||||
}
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
@ -66,7 +67,7 @@ class AnimeClientTestCase extends TestCase {
|
||||
'data_cache_path' => _dir(self::TEST_DATA_DIR, 'cache'),
|
||||
'cache' => [
|
||||
'driver' => 'null',
|
||||
'connection' => []
|
||||
'connection' => [],
|
||||
],
|
||||
'database' => [
|
||||
'collection' => [
|
||||
@ -76,7 +77,7 @@ class AnimeClientTestCase extends TestCase {
|
||||
'pass' => '',
|
||||
'port' => '',
|
||||
'name' => 'default',
|
||||
'database' => '',
|
||||
'database' => '',
|
||||
'file' => ':memory:',
|
||||
],
|
||||
'cache' => [
|
||||
@ -86,21 +87,22 @@ class AnimeClientTestCase extends TestCase {
|
||||
'pass' => '',
|
||||
'port' => '',
|
||||
'name' => 'default',
|
||||
'database' => '',
|
||||
'database' => '',
|
||||
'file' => ':memory:',
|
||||
]
|
||||
],
|
||||
],
|
||||
'routes' => [ ],
|
||||
'routes' => [],
|
||||
];
|
||||
|
||||
// Set up DI container
|
||||
$di = require self::ROOT_DIR . '/app/bootstrap.php';
|
||||
$di = require self::ROOT_DIR . '/app/bootstrap.php';
|
||||
$container = $di($config_array);
|
||||
|
||||
// Use mock session handler
|
||||
$container->set('session-handler', static function() {
|
||||
$container->set('session-handler', static function () {
|
||||
$session_handler = new TestSessionHandler();
|
||||
session_set_save_handler($session_handler, TRUE);
|
||||
|
||||
return $session_handler;
|
||||
});
|
||||
|
||||
@ -111,7 +113,6 @@ class AnimeClientTestCase extends TestCase {
|
||||
* Set arbitrary superglobal values for testing purposes
|
||||
*
|
||||
* @param array $supers
|
||||
* @return void
|
||||
*/
|
||||
public function setSuperGlobals($supers = []): void
|
||||
{
|
||||
@ -120,17 +121,15 @@ class AnimeClientTestCase extends TestCase {
|
||||
'_GET' => $_GET,
|
||||
'_POST' => $_POST,
|
||||
'_COOKIE' => $_COOKIE,
|
||||
'_FILES' => $_FILES
|
||||
'_FILES' => $_FILES,
|
||||
];
|
||||
|
||||
$request = \call_user_func_array(
|
||||
$request = call_user_func_array(
|
||||
[ServerRequestFactory::class, 'fromGlobals'],
|
||||
array_values(array_merge($default, $supers)),
|
||||
);
|
||||
$this->container->setInstance('request', $request);
|
||||
$this->container->set('response', static function() {
|
||||
return new HttpResponse();
|
||||
});
|
||||
$this->container->set('response', static fn () => new HttpResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,4 +163,4 @@ class AnimeClientTestCase extends TestCase {
|
||||
return Json::decode($rawData);
|
||||
}
|
||||
}
|
||||
// End of AnimeClientTestCase.php
|
||||
// End of AnimeClientTestCase.php
|
||||
|
@ -18,19 +18,24 @@ namespace Aviat\AnimeClient\Tests\Command;
|
||||
|
||||
use Aviat\AnimeClient\Command\BaseCommand;
|
||||
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||
use Aviat\Ion\Di\Container;
|
||||
use Aviat\Ion\Friend;
|
||||
use ConsoleKit\Console;
|
||||
use Aviat\Ion\Di\Container;
|
||||
|
||||
class Command extends BaseCommand {
|
||||
|
||||
class Command extends BaseCommand
|
||||
{
|
||||
}
|
||||
|
||||
class BaseCommandTest extends AnimeClientTestCase {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class BaseCommandTest extends AnimeClientTestCase
|
||||
{
|
||||
protected Command $base;
|
||||
protected Friend $friend;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->base = new Command(new Console());
|
||||
$this->friend = new Friend($this->base);
|
||||
}
|
||||
@ -40,4 +45,4 @@ class BaseCommandTest extends AnimeClientTestCase {
|
||||
$container = $this->friend->setupContainer();
|
||||
$this->assertInstanceOf(Container::class, $container);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,22 +16,23 @@
|
||||
|
||||
namespace Aviat\AnimeClient\Tests;
|
||||
|
||||
use Aura\Router\RouterFactory;
|
||||
use Aura\Web\WebFactory;
|
||||
use Aviat\AnimeClient\Controller;
|
||||
use Aviat\AnimeClient\Controller\{
|
||||
Anime as AnimeController,
|
||||
Character as CharacterController,
|
||||
AnimeCollection as AnimeCollectionController,
|
||||
// MangaCollection as MangaCollectionController,
|
||||
Manga as MangaController
|
||||
Character as CharacterController,
|
||||
Manga as MangaController // MangaCollection as MangaCollectionController,
|
||||
};
|
||||
|
||||
class ControllerTest extends AnimeClientTestCase {
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class ControllerTest extends AnimeClientTestCase
|
||||
{
|
||||
protected $BaseController;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// Create Request/Response Objects
|
||||
@ -41,7 +42,7 @@ class ControllerTest extends AnimeClientTestCase {
|
||||
'_POST' => [],
|
||||
'_COOKIE' => [],
|
||||
'_SERVER' => $GLOBALS['_SERVER'],
|
||||
'_FILES' => []
|
||||
'_FILES' => [],
|
||||
]);
|
||||
|
||||
$this->BaseController = new Controller($this->container);
|
||||
@ -53,7 +54,7 @@ class ControllerTest extends AnimeClientTestCase {
|
||||
$config->set('database', [
|
||||
'type' => 'sqlite',
|
||||
'database' => '',
|
||||
'file' => ":memory:"
|
||||
'file' => ':memory:',
|
||||
]);
|
||||
$this->container->setInstance('config', $config);
|
||||
|
||||
@ -81,15 +82,14 @@ class ControllerTest extends AnimeClientTestCase {
|
||||
|
||||
public function testBaseControllerSanity()
|
||||
{
|
||||
$this->assertTrue(\is_object($this->BaseController));
|
||||
$this->assertIsObject($this->BaseController);
|
||||
}
|
||||
|
||||
public function testFormatTitle()
|
||||
{
|
||||
$this->assertEquals(
|
||||
$this->assertSame(
|
||||
$this->BaseController->formatTitle('foo', 'bar', 'baz'),
|
||||
'foo · bar · baz'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,17 +17,19 @@
|
||||
namespace Aviat\AnimeClient\Tests;
|
||||
|
||||
use Aura\Router\Route;
|
||||
use Aviat\AnimeClient\Controller;
|
||||
use Aviat\AnimeClient\Dispatcher;
|
||||
use Aviat\AnimeClient\UrlGenerator;
|
||||
use Aviat\AnimeClient\{Controller, Dispatcher, UrlGenerator};
|
||||
use Aviat\Ion\Config;
|
||||
use Aviat\Ion\Di\ContainerInterface;
|
||||
use InvalidArgumentException;
|
||||
use JetBrains\PhpStorm\ArrayShape;
|
||||
use Monolog\Handler\TestHandler;
|
||||
use Monolog\Logger;
|
||||
|
||||
|
||||
class DispatcherTest extends AnimeClientTestCase {
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class DispatcherTest extends AnimeClientTestCase
|
||||
{
|
||||
protected ContainerInterface $container;
|
||||
protected $router;
|
||||
protected $config;
|
||||
@ -41,11 +43,11 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
'REQUEST_URI' => $uri,
|
||||
'PATH_INFO' => $uri,
|
||||
'HTTP_HOST' => $host,
|
||||
'SERVER_NAME' => $host
|
||||
'SERVER_NAME' => $host,
|
||||
]);
|
||||
|
||||
$this->setSuperGlobals([
|
||||
'_SERVER' => $GLOBALS['_SERVER']
|
||||
'_SERVER' => $GLOBALS['_SERVER'],
|
||||
]);
|
||||
|
||||
$logger = new Logger('test_logger');
|
||||
@ -78,7 +80,7 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
'login_form' => [
|
||||
'path' => '/login',
|
||||
'action' => 'login',
|
||||
'verb' => 'get'
|
||||
'verb' => 'get',
|
||||
],
|
||||
'watching' => [
|
||||
'path' => '/anime/watching{/view}',
|
||||
@ -87,8 +89,8 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
'type' => 'currently-watching',
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
'view' => '[a-z_]+',
|
||||
],
|
||||
],
|
||||
'plan_to_read' => [
|
||||
'path' => '/manga/plan_to_read{/view}',
|
||||
@ -97,15 +99,15 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
'type' => 'Plan to Read',
|
||||
],
|
||||
'tokens' => [
|
||||
'view' => '[a-z_]+'
|
||||
]
|
||||
'view' => '[a-z_]+',
|
||||
],
|
||||
],
|
||||
],
|
||||
'config' => [
|
||||
'anime_path' => 'anime',
|
||||
'manga_path' => 'manga',
|
||||
'default_list' => 'anime'
|
||||
]
|
||||
'default_list' => 'anime',
|
||||
],
|
||||
];
|
||||
|
||||
$data = [
|
||||
@ -131,8 +133,8 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
'config' => $defaultConfig,
|
||||
'controller' => 'manga',
|
||||
'host' => 'localhost',
|
||||
'uri' => '/manga/plan_to_read'
|
||||
]
|
||||
'uri' => '/manga/plan_to_read',
|
||||
],
|
||||
];
|
||||
|
||||
$data['manga_default_routing_anime']['config']['default_list'] = 'manga';
|
||||
@ -143,6 +145,10 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
|
||||
/**
|
||||
* @dataProvider dataRoute
|
||||
* @param mixed $config
|
||||
* @param mixed $controller
|
||||
* @param mixed $host
|
||||
* @param mixed $uri
|
||||
*/
|
||||
public function testRoute($config, $controller, $host, $uri): void
|
||||
{
|
||||
@ -151,16 +157,16 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
$request = $this->container->get('request');
|
||||
|
||||
// Check route setup
|
||||
$this->assertEquals($config['routes'], $this->config->get('routes'), 'Incorrect route path');
|
||||
$this->assertSame($config['routes'], $this->config->get('routes'), 'Incorrect route path');
|
||||
$this->assertIsArray($this->router->getOutputRoutes());
|
||||
|
||||
// Check environment variables
|
||||
$this->assertEquals($uri, $request->getServerParams()['REQUEST_URI']);
|
||||
$this->assertEquals($host, $request->getServerParams()['HTTP_HOST']);
|
||||
$this->assertSame($uri, $request->getServerParams()['REQUEST_URI']);
|
||||
$this->assertSame($host, $request->getServerParams()['HTTP_HOST']);
|
||||
|
||||
// Make sure the route is an anime type
|
||||
//$this->assertTrue($matcher->count() > 0, '0 routes');
|
||||
$this->assertEquals($controller, $this->router->getController(), 'Incorrect Route type');
|
||||
$this->assertSame($controller, $this->router->getController(), 'Incorrect Route type');
|
||||
|
||||
// Make sure the route matches, by checking that it is actually an object
|
||||
$route = $this->router->getRoute();
|
||||
@ -175,13 +181,13 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
'manga_path' => 'manga',
|
||||
'default_anime_list_path' => 'watching',
|
||||
'default_manga_list_path' => 'all',
|
||||
'default_list' => 'manga'
|
||||
'default_list' => 'manga',
|
||||
],
|
||||
'routes' => [
|
||||
'login_form' => [
|
||||
'path' => '/login',
|
||||
'action' => ['login'],
|
||||
'verb' => 'get'
|
||||
'verb' => 'get',
|
||||
],
|
||||
'index' => [
|
||||
'path' => '/',
|
||||
@ -189,21 +195,22 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
'params' => [
|
||||
'url' => '', // Determined by config
|
||||
'code' => '301',
|
||||
'type' => 'manga'
|
||||
]
|
||||
]
|
||||
]
|
||||
'type' => 'manga',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
$this->doSetUp($config, '/', 'localhost');
|
||||
$this->assertEquals('//localhost/manga/all', $this->urlGenerator->defaultUrl('manga'), 'Incorrect default url');
|
||||
$this->assertEquals('//localhost/anime/watching', $this->urlGenerator->defaultUrl('anime'), 'Incorrect default url');
|
||||
$this->assertSame('//localhost/manga/all', $this->urlGenerator->defaultUrl('manga'), 'Incorrect default url');
|
||||
$this->assertSame('//localhost/anime/watching', $this->urlGenerator->defaultUrl('anime'), 'Incorrect default url');
|
||||
|
||||
$this->urlGenerator->defaultUrl('foo');
|
||||
}
|
||||
|
||||
#[ArrayShape(['controller_list_sanity_check' => "array", 'empty_controller_list' => "array"])]
|
||||
public function dataGetControllerList(): array
|
||||
{
|
||||
$expectedList = [
|
||||
@ -240,17 +247,17 @@ class DispatcherTest extends AnimeClientTestCase {
|
||||
'default_list' => 'manga',
|
||||
'routes' => [],
|
||||
],
|
||||
'expected' => $expectedList
|
||||
]
|
||||
'expected' => $expectedList,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataGetControllerList
|
||||
*/
|
||||
public function testGetControllerList($config, $expected): void
|
||||
public function testGetControllerList(array $config, array $expected): void
|
||||
{
|
||||
$this->doSetUp($config, '/', 'localhost');
|
||||
$this->assertEquals($expected, $this->router->getControllerList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ const SETTINGS_MAP = [
|
||||
'display' => FALSE,
|
||||
'description' => '',
|
||||
'value' => 'foo_bar',
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
@ -86,7 +86,7 @@ const SETTINGS_MAP = [
|
||||
'APCu' => 'apcu',
|
||||
'Memcached' => 'memcached',
|
||||
'Redis' => 'redis',
|
||||
'No Cache' => 'null'
|
||||
'No Cache' => 'null',
|
||||
],
|
||||
],
|
||||
'connection' => [
|
||||
@ -147,7 +147,7 @@ const SETTINGS_MAP = [
|
||||
'Automatically match OS theme' => 'auto',
|
||||
'Original Light Theme' => 'light',
|
||||
'Dark Theme' => 'dark',
|
||||
]
|
||||
],
|
||||
],
|
||||
'show_anime_collection' => [
|
||||
'type' => 'boolean',
|
||||
@ -181,7 +181,7 @@ const SETTINGS_MAP = [
|
||||
'Dropped' => 'dropped',
|
||||
'Completed' => 'completed',
|
||||
'All' => 'all',
|
||||
]
|
||||
],
|
||||
],
|
||||
'default_manga_list_path' => [ //reading|plan_to_read|on_hold|dropped|completed|all
|
||||
'type' => 'select',
|
||||
@ -194,8 +194,8 @@ const SETTINGS_MAP = [
|
||||
'Dropped' => 'dropped',
|
||||
'Completed' => 'completed',
|
||||
'All' => 'all',
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
'database' => [
|
||||
'type' => [
|
||||
@ -222,7 +222,7 @@ const SETTINGS_MAP = [
|
||||
'pass' => [
|
||||
'type' => 'string',
|
||||
'title' => 'Password',
|
||||
'description' => 'Database connection password'
|
||||
'description' => 'Database connection password',
|
||||
],
|
||||
'port' => [
|
||||
'type' => 'string',
|
||||
@ -244,11 +244,15 @@ const SETTINGS_MAP = [
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
class FormGeneratorTest extends AnimeClientTestCase {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class FormGeneratorTest extends AnimeClientTestCase
|
||||
{
|
||||
public function testGeneration(): void
|
||||
{
|
||||
$generator = FormGenerator::new($this->container);
|
||||
|
||||
foreach (SETTINGS_MAP as $section => $fields)
|
||||
{
|
||||
foreach ($fields as $name => $config)
|
||||
@ -258,4 +262,4 @@ class FormGeneratorTest extends AnimeClientTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,11 @@ namespace Aviat\AnimeClient\Tests\Helper;
|
||||
use Aviat\AnimeClient\Helper\Form as FormHelper;
|
||||
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||
|
||||
class FormHelperTest extends AnimeClientTestCase {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class FormHelperTest extends AnimeClientTestCase
|
||||
{
|
||||
public function testFormHelper(): void
|
||||
{
|
||||
$helper = new FormHelper();
|
||||
@ -29,9 +33,9 @@ class FormHelperTest extends AnimeClientTestCase {
|
||||
'type' => 'text',
|
||||
'value' => 'foo',
|
||||
'placeholder' => 'field',
|
||||
'name' => 'test'
|
||||
'name' => 'test',
|
||||
]);
|
||||
|
||||
$this->assertMatchesSnapshot($actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,16 @@ namespace Aviat\AnimeClient\Tests\Helper;
|
||||
use Aviat\AnimeClient\Helper\Menu as MenuHelper;
|
||||
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||
|
||||
class MenuHelperTest extends AnimeClientTestCase {
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class MenuHelperTest extends AnimeClientTestCase
|
||||
{
|
||||
protected $helper;
|
||||
protected $urlGenerator;
|
||||
|
||||
public function setUp(): void {
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->helper = $this->container->get('html-helper');
|
||||
$this->urlGenerator = $this->container->get('url-generator');
|
||||
@ -36,15 +40,15 @@ class MenuHelperTest extends AnimeClientTestCase {
|
||||
'no selection' => [
|
||||
'route_prefix' => '/foo',
|
||||
'items' => [
|
||||
'bar' => '/bar'
|
||||
]
|
||||
'bar' => '/bar',
|
||||
],
|
||||
],
|
||||
'selected' => [
|
||||
'route_prefix' => '',
|
||||
'items' => [
|
||||
'index' => '/foobar'
|
||||
]
|
||||
]
|
||||
'index' => '/foobar',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$expected = [];
|
||||
@ -64,15 +68,15 @@ class MenuHelperTest extends AnimeClientTestCase {
|
||||
$config->set('menus', $menus);
|
||||
$this->container->setInstance('config', $config);
|
||||
|
||||
foreach($menus as $case => $config)
|
||||
foreach ($menus as $case => $config)
|
||||
{
|
||||