Version 5.1 - All the GraphQL #32
@ -42,7 +42,8 @@
|
||||
"henrikbjorn/lurker": "^1.1.0",
|
||||
"symfony/var-dumper": "^3.2",
|
||||
"squizlabs/php_codesniffer": "^3.0.0@beta",
|
||||
"phpstan/phpstan": "^0.6.4"
|
||||
"phpstan/phpstan": "^0.6.4",
|
||||
"spatie/phpunit-snapshot-assertions": "^0.4.1"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "vendor/bin/robo build",
|
||||
|
@ -22,7 +22,6 @@ use Aviat\Ion\Friend;
|
||||
use Aviat\Ion\Json;
|
||||
|
||||
class AnimeListTransformerTest extends AnimeClientTestCase {
|
||||
|
||||
protected $dir;
|
||||
protected $beforeTransform;
|
||||
protected $afterTransform;
|
||||
@ -34,19 +33,14 @@ class AnimeListTransformerTest extends AnimeClientTestCase {
|
||||
$this->dir = AnimeClientTestCase::TEST_DATA_DIR . '/Kitsu';
|
||||
|
||||
$this->beforeTransform = Json::decodeFile("{$this->dir}/animeListItemBeforeTransform.json");
|
||||
$this->afterTransform = Json::decodeFile("{$this->dir}/animeListItemAfterTransform.json");
|
||||
|
||||
$this->transformer = new AnimeListTransformer();
|
||||
}
|
||||
|
||||
public function testTransform()
|
||||
{
|
||||
$expected = $this->afterTransform;
|
||||
$actual = $this->transformer->transform($this->beforeTransform);
|
||||
|
||||
// Json::encodeFile("{$this->dir}/animeListItemAfterTransform.json", $actual);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
$this->assertMatchesSnapshot($actual);
|
||||
}
|
||||
|
||||
public function dataUntransform()
|
||||
@ -60,19 +54,6 @@ class AnimeListTransformerTest extends AnimeClientTestCase {
|
||||
'rewatched' => 0,
|
||||
'notes' => 'Very formulaic.',
|
||||
'edit' => true
|
||||
],
|
||||
'expected' => [
|
||||
'id' => 14047981,
|
||||
'mal_id' => null,
|
||||
'data' => [
|
||||
'status' => 'current',
|
||||
'rating' => 4,
|
||||
'reconsuming' => false,
|
||||
'reconsumeCount' => 0,
|
||||
'notes' => 'Very formulaic.',
|
||||
'progress' => 38,
|
||||
'private' => false
|
||||
]
|
||||
]
|
||||
], [
|
||||
'input' => [
|
||||
@ -86,19 +67,6 @@ class AnimeListTransformerTest extends AnimeClientTestCase {
|
||||
'edit' => 'true',
|
||||
'private' => 'On',
|
||||
'rewatching' => 'On'
|
||||
],
|
||||
'expected' => [
|
||||
'id' => 14047981,
|
||||
'mal_id' => '12345',
|
||||
'data' => [
|
||||
'status' => 'current',
|
||||
'rating' => 4,
|
||||
'reconsuming' => true,
|
||||
'reconsumeCount' => 0,
|
||||
'notes' => 'Very formulaic.',
|
||||
'progress' => 38,
|
||||
'private' => true,
|
||||
]
|
||||
]
|
||||
]];
|
||||
}
|
||||
@ -106,9 +74,9 @@ class AnimeListTransformerTest extends AnimeClientTestCase {
|
||||
/**
|
||||
* @dataProvider dataUntransform
|
||||
*/
|
||||
public function testUntransform($input, $expected)
|
||||
public function testUntransform($input)
|
||||
{
|
||||
$actual = $this->transformer->untransform($input);
|
||||
$this->assertEquals($expected, $actual);
|
||||
$this->assertMatchesSnapshot($actual);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<?php return array (
|
||||
'id' => '15839442',
|
||||
'mal_id' => '33206',
|
||||
'episodes' =>
|
||||
array (
|
||||
'watched' => 0,
|
||||
'total' => '-',
|
||||
'length' => NULL,
|
||||
),
|
||||
'airing' =>
|
||||
array (
|
||||
'status' => 'Currently Airing',
|
||||
'started' => '2017-01-12',
|
||||
'ended' => NULL,
|
||||
),
|
||||
'anime' =>
|
||||
array (
|
||||
'age_rating' => NULL,
|
||||
'title' => 'Kobayashi-san Chi no Maid Dragon',
|
||||
'titles' =>
|
||||
array (
|
||||
0 => 'Kobayashi-san Chi no Maid Dragon',
|
||||
1 => 'Miss Kobayashi\'s Dragon Maid',
|
||||
2 => '小林さんちのメイドラゴン',
|
||||
),
|
||||
'slug' => 'kobayashi-san-chi-no-maid-dragon',
|
||||
'type' => 'TV',
|
||||
'image' => 'https://media.kitsu.io/anime/poster_images/12243/small.jpg?1481144116',
|
||||
'genres' =>
|
||||
array (
|
||||
0 => 'Comedy',
|
||||
1 => 'Fantasy',
|
||||
2 => 'Slice of Life',
|
||||
),
|
||||
'streaming_links' =>
|
||||
array (
|
||||
),
|
||||
),
|
||||
'watching_status' => 'current',
|
||||
'notes' => NULL,
|
||||
'rewatching' => false,
|
||||
'rewatched' => 0,
|
||||
'user_rating' => '-',
|
||||
'private' => false,
|
||||
);
|
@ -0,0 +1,14 @@
|
||||
<?php return array (
|
||||
'id' => 14047981,
|
||||
'mal_id' => NULL,
|
||||
'data' =>
|
||||
array (
|
||||
'status' => 'current',
|
||||
'reconsuming' => false,
|
||||
'reconsumeCount' => 0,
|
||||
'notes' => 'Very formulaic.',
|
||||
'progress' => 38,
|
||||
'private' => false,
|
||||
'rating' => 4,
|
||||
),
|
||||
);
|
@ -0,0 +1,14 @@
|
||||
<?php return array (
|
||||
'id' => 14047981,
|
||||
'mal_id' => '12345',
|
||||
'data' =>
|
||||
array (
|
||||
'status' => 'current',
|
||||
'reconsuming' => true,
|
||||
'reconsumeCount' => 0,
|
||||
'notes' => 'Very formulaic.',
|
||||
'progress' => 38,
|
||||
'private' => true,
|
||||
'rating' => 4,
|
||||
),
|
||||
);
|
@ -23,6 +23,7 @@ use function Aviat\Ion\_dir;
|
||||
use Aura\Web\WebFactory;
|
||||
use Aviat\Ion\Json;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Spatie\Snapshots\MatchesSnapshots;
|
||||
use Zend\Diactoros\{
|
||||
Response as HttpResponse,
|
||||
ServerRequestFactory
|
||||
@ -36,6 +37,9 @@ define('TEST_VIEW_DIR', __DIR__ . '/test_views');
|
||||
* Base class for TestCases
|
||||
*/
|
||||
class AnimeClientTestCase extends TestCase {
|
||||
use MatchesSnapshots;
|
||||
|
||||
|
||||
// Test directory constants
|
||||
const ROOT_DIR = ROOT_DIR;
|
||||
const SRC_DIR = SRC_DIR;
|
||||
|
Loading…
Reference in New Issue
Block a user