Fix tests

This commit is contained in:
Timothy Warren 2017-03-29 13:42:40 -04:00
parent 15b26d8e39
commit ec7e0cc93b
3 changed files with 1275 additions and 1780 deletions

View File

@ -32,10 +32,21 @@ class MangaListTransformerTest extends AnimeClientTestCase {
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$kitsuModel = $this->container->get('kitsu-model');
$this->dir = AnimeClientTestCase::TEST_DATA_DIR . '/Kitsu'; $this->dir = AnimeClientTestCase::TEST_DATA_DIR . '/Kitsu';
// Prep for transform
$rawBefore = Json::decodeFile("{$this->dir}/mangaListBeforeTransform.json"); $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->afterTransform = Json::decodeFile("{$this->dir}/mangaListAfterTransform.json");
$this->transformer = new MangaListTransformer(); $this->transformer = new MangaListTransformer();
@ -54,7 +65,8 @@ class MangaListTransformerTest extends AnimeClientTestCase {
public function testUntransform() public function testUntransform()
{ {
$input = [ $input = [
'id' => "15084773", 'id' => '15084773',
'mal_id' => '26769',
'chapters_read' => 67, 'chapters_read' => 67,
'manga' => [ 'manga' => [
'titles' => ["Bokura wa Minna Kawaisou"], 'titles' => ["Bokura wa Minna Kawaisou"],
@ -75,6 +87,7 @@ class MangaListTransformerTest extends AnimeClientTestCase {
$actual = $this->transformer->untransform($input); $actual = $this->transformer->untransform($input);
$expected = [ $expected = [
'id' => '15084773', 'id' => '15084773',
'mal_id' => '26769',
'data' => [ 'data' => [
'status' => 'current', 'status' => 'current',
'progress' => 67, 'progress' => 67,

View File

@ -1,5 +1,6 @@
[{ [{
"id": "15084773", "id": "15084773",
"mal_id": "26769",
"chapters": { "chapters": {
"read": 67, "read": 67,
"total": "-" "total": "-"
@ -15,7 +16,7 @@
"url": "https:\/\/kitsu.io\/manga\/bokura-wa-minna-kawaisou", "url": "https:\/\/kitsu.io\/manga\/bokura-wa-minna-kawaisou",
"type": "manga", "type": "manga",
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/20286\/small.jpg?1434293999", "image": "https:\/\/media.kitsu.io\/manga\/poster_images\/20286\/small.jpg?1434293999",
"genres": [] "genres": ["Comedy", "Romance", "School", "Slice of Life", "Thriller"]
}, },
"reading_status": "current", "reading_status": "current",
"notes": "", "notes": "",
@ -24,6 +25,7 @@
"user_rating": 9 "user_rating": 9
}, { }, {
"id": "15085607", "id": "15085607",
"mal_id": "16",
"chapters": { "chapters": {
"read": 17, "read": 17,
"total": 120 "total": 120
@ -39,7 +41,7 @@
"url": "https:\/\/kitsu.io\/manga\/love-hina", "url": "https:\/\/kitsu.io\/manga\/love-hina",
"type": "manga", "type": "manga",
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/47\/small.jpg?1434249493", "image": "https:\/\/media.kitsu.io\/manga\/poster_images\/47\/small.jpg?1434249493",
"genres": [] "genres": ["Comedy", "Ecchi", "Harem", "Romance", "Sports"]
}, },
"reading_status": "current", "reading_status": "current",
"notes": "", "notes": "",
@ -48,6 +50,7 @@
"user_rating": 7 "user_rating": 7
}, { }, {
"id": "15084529", "id": "15084529",
"mal_id": "35003",
"chapters": { "chapters": {
"read": 16, "read": 16,
"total": "-" "total": "-"
@ -63,7 +66,7 @@
"url": "https:\/\/kitsu.io\/manga\/yamada-kun-to-7-nin-no-majo", "url": "https:\/\/kitsu.io\/manga\/yamada-kun-to-7-nin-no-majo",
"type": "manga", "type": "manga",
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/11777\/small.jpg?1438784325", "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", "reading_status": "current",
"notes": "", "notes": "",
@ -72,6 +75,7 @@
"user_rating": 9 "user_rating": 9
}, { }, {
"id": "15312827", "id": "15312827",
"mal_id": "78523",
"chapters": { "chapters": {
"read": 68, "read": 68,
"total": "-" "total": "-"
@ -87,7 +91,7 @@
"url": "https:\/\/kitsu.io\/manga\/relife", "url": "https:\/\/kitsu.io\/manga\/relife",
"type": "manga", "type": "manga",
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/27175\/small.jpg?1464379411", "image": "https:\/\/media.kitsu.io\/manga\/poster_images\/27175\/small.jpg?1464379411",
"genres": [] "genres": ["Romance", "School", "Slice of Life"]
}, },
"reading_status": "current", "reading_status": "current",
"notes": "", "notes": "",
@ -95,33 +99,10 @@
"reread": 0, "reread": 0,
"user_rating": "-" "user_rating": "-"
}, { }, {
"id": "15084772", "id": "15084769",
"mal_id": "60815",
"chapters": { "chapters": {
"read": 28, "read": 43,
"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,
"total": "-" "total": "-"
}, },
"volumes": { "volumes": {
@ -129,111 +110,15 @@
"total": "-" "total": "-"
}, },
"manga": { "manga": {
"titles": ["Shishunki Bitter Change"], "titles": ["Joshikausei"],
"alternate_title": null, "alternate_title": null,
"slug": "shishunki-bitter-change", "slug": "joshikausei",
"url": "https:\/\/kitsu.io\/manga\/shishunki-bitter-change", "url": "https:\/\/kitsu.io\/manga\/joshikausei",
"type": "manga", "type": "manga",
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/25512\/small.jpg?1434305092", "image": "https:\/\/media.kitsu.io\/manga\/poster_images\/25491\/small.jpg?1434305043",
"genres": [] "genres": ["Comedy", "School", "Slice of Life"]
}, },
"reading_status": "planned", "reading_status": "current",
"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",
"notes": "", "notes": "",
"rereading": false, "rereading": false,
"reread": 0, "reread": 0,

File diff suppressed because it is too large Load Diff