Fix tests
This commit is contained in:
parent
3bb4f32bdb
commit
be252836be
@ -22,39 +22,51 @@ use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||
use Aviat\Ion\Json;
|
||||
|
||||
class MangaListTransformerTest extends AnimeClientTestCase {
|
||||
|
||||
|
||||
protected $dir;
|
||||
protected $rawBefore;
|
||||
protected $beforeTransform;
|
||||
protected $afterTransform;
|
||||
protected $transformer;
|
||||
|
||||
public function setUp()
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$kitsuModel = $this->container->get('kitsu-model');
|
||||
|
||||
$this->dir = AnimeClientTestCase::TEST_DATA_DIR . '/Kitsu';
|
||||
|
||||
|
||||
// Prep for transform
|
||||
$rawBefore = Json::decodeFile("{$this->dir}/mangaListBeforeTransform.json");
|
||||
$this->beforeTransform = JsonAPI::inlineRawIncludes($rawBefore, 'manga');
|
||||
$included = JsonAPI::organizeIncludes($rawBefore['included']);
|
||||
$included = JsonAPI::inlineIncludedRelationships($included, 'manga');
|
||||
foreach($rawBefore['data'] as $i => &$item)
|
||||
{
|
||||
$item['included'] = $included;
|
||||
}
|
||||
|
||||
$this->beforeTransform = $rawBefore['data'];
|
||||
$this->afterTransform = Json::decodeFile("{$this->dir}/mangaListAfterTransform.json");
|
||||
|
||||
|
||||
$this->transformer = new MangaListTransformer();
|
||||
}
|
||||
|
||||
|
||||
public function testTransform()
|
||||
{
|
||||
$expected = $this->afterTransform;
|
||||
$actual = $this->transformer->transformCollection($this->beforeTransform);
|
||||
|
||||
|
||||
// Json::encodeFile("{$this->dir}/mangaListAfterTransform.json", $actual);
|
||||
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
|
||||
public function testUntransform()
|
||||
{
|
||||
$input = [
|
||||
'id' => "15084773",
|
||||
'id' => '15084773',
|
||||
'mal_id' => '26769',
|
||||
'chapters_read' => 67,
|
||||
'manga' => [
|
||||
'titles' => ["Bokura wa Minna Kawaisou"],
|
||||
@ -71,10 +83,11 @@ class MangaListTransformerTest extends AnimeClientTestCase {
|
||||
'reread_count' => 0,
|
||||
'new_rating' => 9,
|
||||
];
|
||||
|
||||
|
||||
$actual = $this->transformer->untransform($input);
|
||||
$expected = [
|
||||
'id' => '15084773',
|
||||
'mal_id' => '26769',
|
||||
'data' => [
|
||||
'status' => 'current',
|
||||
'progress' => 67,
|
||||
@ -84,7 +97,7 @@ class MangaListTransformerTest extends AnimeClientTestCase {
|
||||
'rating' => 4.5
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
[{
|
||||
"id": "15084773",
|
||||
"mal_id": "26769",
|
||||
"chapters": {
|
||||
"read": 67,
|
||||
"total": "-"
|
||||
@ -15,7 +16,7 @@
|
||||
"url": "https:\/\/kitsu.io\/manga\/bokura-wa-minna-kawaisou",
|
||||
"type": "manga",
|
||||
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/20286\/small.jpg?1434293999",
|
||||
"genres": []
|
||||
"genres": ["Comedy", "Romance", "School", "Slice of Life", "Thriller"]
|
||||
},
|
||||
"reading_status": "current",
|
||||
"notes": "",
|
||||
@ -24,6 +25,7 @@
|
||||
"user_rating": 9
|
||||
}, {
|
||||
"id": "15085607",
|
||||
"mal_id": "16",
|
||||
"chapters": {
|
||||
"read": 17,
|
||||
"total": 120
|
||||
@ -39,7 +41,7 @@
|
||||
"url": "https:\/\/kitsu.io\/manga\/love-hina",
|
||||
"type": "manga",
|
||||
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/47\/small.jpg?1434249493",
|
||||
"genres": []
|
||||
"genres": ["Comedy", "Ecchi", "Harem", "Romance", "Sports"]
|
||||
},
|
||||
"reading_status": "current",
|
||||
"notes": "",
|
||||
@ -48,6 +50,7 @@
|
||||
"user_rating": 7
|
||||
}, {
|
||||
"id": "15084529",
|
||||
"mal_id": "35003",
|
||||
"chapters": {
|
||||
"read": 16,
|
||||
"total": "-"
|
||||
@ -63,7 +66,7 @@
|
||||
"url": "https:\/\/kitsu.io\/manga\/yamada-kun-to-7-nin-no-majo",
|
||||
"type": "manga",
|
||||
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/11777\/small.jpg?1438784325",
|
||||
"genres": []
|
||||
"genres": ["Comedy", "Ecchi", "Gender Bender", "Romance", "School", "Sports", "Supernatural"]
|
||||
},
|
||||
"reading_status": "current",
|
||||
"notes": "",
|
||||
@ -72,6 +75,7 @@
|
||||
"user_rating": 9
|
||||
}, {
|
||||
"id": "15312827",
|
||||
"mal_id": "78523",
|
||||
"chapters": {
|
||||
"read": 68,
|
||||
"total": "-"
|
||||
@ -87,7 +91,7 @@
|
||||
"url": "https:\/\/kitsu.io\/manga\/relife",
|
||||
"type": "manga",
|
||||
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/27175\/small.jpg?1464379411",
|
||||
"genres": []
|
||||
"genres": ["Romance", "School", "Slice of Life"]
|
||||
},
|
||||
"reading_status": "current",
|
||||
"notes": "",
|
||||
@ -95,33 +99,10 @@
|
||||
"reread": 0,
|
||||
"user_rating": "-"
|
||||
}, {
|
||||
"id": "15084772",
|
||||
"id": "15084769",
|
||||
"mal_id": "60815",
|
||||
"chapters": {
|
||||
"read": 28,
|
||||
"total": 62
|
||||
},
|
||||
"volumes": {
|
||||
"read": "-",
|
||||
"total": 10
|
||||
},
|
||||
"manga": {
|
||||
"titles": ["Usagi Drop", "Bunny Drop"],
|
||||
"alternate_title": null,
|
||||
"slug": "usagi-drop",
|
||||
"url": "https:\/\/kitsu.io\/manga\/usagi-drop",
|
||||
"type": "manga",
|
||||
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/7629\/small.jpg?1434265873",
|
||||
"genres": []
|
||||
},
|
||||
"reading_status": "on_hold",
|
||||
"notes": "",
|
||||
"rereading": false,
|
||||
"reread": 0,
|
||||
"user_rating": 8
|
||||
}, {
|
||||
"id": "15251749",
|
||||
"chapters": {
|
||||
"read": 1,
|
||||
"read": 43,
|
||||
"total": "-"
|
||||
},
|
||||
"volumes": {
|
||||
@ -129,111 +110,15 @@
|
||||
"total": "-"
|
||||
},
|
||||
"manga": {
|
||||
"titles": ["Shishunki Bitter Change"],
|
||||
"titles": ["Joshikausei"],
|
||||
"alternate_title": null,
|
||||
"slug": "shishunki-bitter-change",
|
||||
"url": "https:\/\/kitsu.io\/manga\/shishunki-bitter-change",
|
||||
"slug": "joshikausei",
|
||||
"url": "https:\/\/kitsu.io\/manga\/joshikausei",
|
||||
"type": "manga",
|
||||
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/25512\/small.jpg?1434305092",
|
||||
"genres": []
|
||||
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/25491\/small.jpg?1434305043",
|
||||
"genres": ["Comedy", "School", "Slice of Life"]
|
||||
},
|
||||
"reading_status": "planned",
|
||||
"notes": "",
|
||||
"rereading": false,
|
||||
"reread": 0,
|
||||
"user_rating": "-"
|
||||
}, {
|
||||
"id": "15312881",
|
||||
"chapters": {
|
||||
"read": 0,
|
||||
"total": "-"
|
||||
},
|
||||
"volumes": {
|
||||
"read": "-",
|
||||
"total": "-"
|
||||
},
|
||||
"manga": {
|
||||
"titles": ["Kuragehime", "Princess Jellyfish"],
|
||||
"alternate_title": null,
|
||||
"slug": "kuragehime",
|
||||
"url": "https:\/\/kitsu.io\/manga\/kuragehime",
|
||||
"type": "manga",
|
||||
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/5531\/small.jpg?1434261214",
|
||||
"genres": []
|
||||
},
|
||||
"reading_status": "planned",
|
||||
"notes": "",
|
||||
"rereading": false,
|
||||
"reread": 0,
|
||||
"user_rating": "-"
|
||||
}, {
|
||||
"id": "15315190",
|
||||
"chapters": {
|
||||
"read": 0,
|
||||
"total": 80
|
||||
},
|
||||
"volumes": {
|
||||
"read": "-",
|
||||
"total": 9
|
||||
},
|
||||
"manga": {
|
||||
"titles": ["Boku wa Mari no Naka", "Inside Mari"],
|
||||
"alternate_title": null,
|
||||
"slug": "boku-wa-mari-no-naka",
|
||||
"url": "https:\/\/kitsu.io\/manga\/boku-wa-mari-no-naka",
|
||||
"type": "manga",
|
||||
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/14261\/small.jpg?1434280674",
|
||||
"genres": []
|
||||
},
|
||||
"reading_status": "planned",
|
||||
"notes": null,
|
||||
"rereading": false,
|
||||
"reread": 0,
|
||||
"user_rating": "-"
|
||||
}, {
|
||||
"id": "15315189",
|
||||
"chapters": {
|
||||
"read": 0,
|
||||
"total": "-"
|
||||
},
|
||||
"volumes": {
|
||||
"read": "-",
|
||||
"total": "-"
|
||||
},
|
||||
"manga": {
|
||||
"titles": ["Aizawa-san Zoushoku"],
|
||||
"alternate_title": null,
|
||||
"slug": "aizawa-san-zoushoku",
|
||||
"url": "https:\/\/kitsu.io\/manga\/aizawa-san-zoushoku",
|
||||
"type": "manga",
|
||||
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/25316\/small.jpg?1434304656",
|
||||
"genres": []
|
||||
},
|
||||
"reading_status": "planned",
|
||||
"notes": null,
|
||||
"rereading": false,
|
||||
"reread": 0,
|
||||
"user_rating": "-"
|
||||
}, {
|
||||
"id": "15288185",
|
||||
"chapters": {
|
||||
"read": 28,
|
||||
"total": "-"
|
||||
},
|
||||
"volumes": {
|
||||
"read": "-",
|
||||
"total": "-"
|
||||
},
|
||||
"manga": {
|
||||
"titles": ["Tonari no Seki-kun", "My Neighbour Seki"],
|
||||
"alternate_title": null,
|
||||
"slug": "tonari-no-seki-kun",
|
||||
"url": "https:\/\/kitsu.io\/manga\/tonari-no-seki-kun",
|
||||
"type": "manga",
|
||||
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/21733\/small.jpg?1434297086",
|
||||
"genres": []
|
||||
},
|
||||
"reading_status": "on_hold",
|
||||
"reading_status": "current",
|
||||
"notes": "",
|
||||
"rereading": false,
|
||||
"reread": 0,
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user