Update transformer tests

This commit is contained in:
Timothy Warren 2017-01-13 16:48:08 -05:00
parent 496eb68078
commit 9e30783ecb
6 changed files with 1392 additions and 133 deletions

View File

@ -12,10 +12,10 @@ class AnimeListTransformerTest extends AnimeClient_TestCase {
public function setUp()
{
parent::setUp();
$dir = AnimeClient_TestCase::TEST_DATA_DIR . '/Kitsu';
$this->dir = AnimeClient_TestCase::TEST_DATA_DIR . '/Kitsu';
$this->beforeTransform = Json::decodeFile("{$dir}/animeListItemBeforeTransform.json");
$this->afterTransform = Json::decodeFile("{$dir}/animeListItemAfterTransform.json");
$this->beforeTransform = Json::decodeFile("{$this->dir}/animeListItemBeforeTransform.json");
$this->afterTransform = Json::decodeFile("{$this->dir}/animeListItemAfterTransform.json");
$this->transformer = new AnimeListTransformer();
}
@ -25,6 +25,8 @@ class AnimeListTransformerTest extends AnimeClient_TestCase {
$expected = $this->afterTransform;
$actual = $this->transformer->transform($this->beforeTransform);
// Json::encodeFile("{$this->dir}/animeListItemAfterTransform.json", $actual);
$this->assertEquals($expected, $actual);
}

View File

@ -12,19 +12,20 @@ class AnimeTransformerTest extends AnimeClient_TestCase {
public function setUp()
{
parent::setUp();
$dir = AnimeClient_TestCase::TEST_DATA_DIR . '/Kitsu';
$this->dir = AnimeClient_TestCase::TEST_DATA_DIR . '/Kitsu';
//$this->beforeTransform = Json::decodeFile("{$dir}/animeBeforeTransform.json");
//$this->afterTransform = Json::decodeFile("{$dir}/animeAfterTransform.json");
$this->beforeTransform = Json::decodeFile("{$this->dir}/animeBeforeTransform.json");
$this->afterTransform = Json::decodeFile("{$this->dir}/animeAfterTransform.json");
$this->transformer = new AnimeTransformer();
}
public function testTransform()
{
/*$expected = $this->afterTransform;
$expected = $this->afterTransform;
$actual = $this->transformer->transform($this->beforeTransform);
// Json::encodeFile("{$this->dir}/animeAfterTransform.json", $actual);
$this->assertEquals($expected, $actual);*/
$this->assertEquals($expected, $actual);
}
}

View File

@ -0,0 +1,51 @@
{
"title": "Attack on Titan",
"titles": ["Attack on Titan", "Shingeki no Kyojin", "\u9032\u6483\u306e\u5de8\u4eba"],
"status": "Finished Airing",
"cover_image": "https:\/\/media.kitsu.io\/anime\/poster_images\/7442\/small.jpg?1418580054",
"show_type": "TV",
"episode_count": 25,
"episode_length": 24,
"synopsis": "Several hundred years ago, humans were nearly exterminated by titans. Titans are typically several stories tall, seem to have no intelligence, devour human beings and, worst of all, seem to do it for the pleasure rather than as a food source. A small percentage of humanity survived by enclosing themselves in a city protected by extremely high walls, even taller than the biggest of titans. Flash forward to the present and the city has not seen a titan in over 100 years. Teenage boy Eren and his foster sister Mikasa witness something horrific as the city walls are destroyed by a colossal titan that appears out of thin air. As the smaller titans flood the city, the two kids watch in horror as their mother is eaten alive. Eren vows that he will murder every single titan and take revenge for all of mankind.\n\n(Source: ANN)",
"age_rating": "R",
"age_rating_guide": "Violence, Profanity",
"url": "https:\/\/kitsu.io\/anime\/attack-on-titan",
"genres": ["Action", "Drama", "Fantasy", "Super Power"],
"streaming_links": [{
"meta": {
"name": "Crunchyroll",
"link": true,
"logo": "<svg width=\"50\" height=\"50\" viewBox=\"0 0 50 50\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><g fill=\"#F78B24\" fill-rule=\"evenodd\"><path d=\"M22.549 49.145c-.815-.077-2.958-.456-3.753-.663-6.873-1.79-12.693-6.59-15.773-13.009C1.335 31.954.631 28.807.633 24.788c.003-4.025.718-7.235 2.38-10.686 1.243-2.584 2.674-4.609 4.706-6.66 3.8-3.834 8.614-6.208 14.067-6.936 1.783-.239 5.556-.161 7.221.148 3.463.642 6.571 1.904 9.357 3.797 5.788 3.934 9.542 9.951 10.52 16.861.21 1.48.332 4.559.19 4.816-.077.14-.117-.007-.167-.615-.25-3.015-1.528-6.66-3.292-9.388C40.253 7.836 30.249 4.32 20.987 7.467c-7.15 2.43-12.522 8.596-13.997 16.06-.73 3.692-.51 7.31.658 10.882a21.426 21.426 0 0 0 13.247 13.518c1.475.515 3.369.944 4.618 1.047 1.496.122 1.119.239-.727.224-1.006-.008-2.013-.032-2.237-.053z\"><\/path><path d=\"M27.685 46.1c-7.731-.575-14.137-6.455-15.474-14.204-.243-1.41-.29-4.047-.095-5.345 1.16-7.706 6.97-13.552 14.552-14.639 1.537-.22 4.275-.143 5.746.162 1.28.266 2.7.737 3.814 1.266l.865.411-.814.392c-2.936 1.414-4.748 4.723-4.323 7.892.426 3.173 2.578 5.664 5.667 6.56 1.112.322 2.812.322 3.925 0 1.438-.417 2.566-1.1 3.593-2.173.346-.362.652-.621.68-.576.027.046.106.545.176 1.11.171 1.395.07 4.047-.204 5.371-.876 4.218-3.08 7.758-6.463 10.374-3.2 2.476-7.434 3.711-11.645 3.399z\"><\/path><\/g><\/svg>"
},
"link": "http:\/\/www.crunchyroll.com\/attack-on-titan",
"subs": ["en"],
"dubs": ["ja"]
}, {
"meta": {
"name": "Hulu",
"link": true,
"logo": "<svg width=\"50\" height=\"50\" viewBox=\"0 0 34 50\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><path d=\"M22.222 13.889h-11.11V0H0v50h11.111V27.778c0-1.39 1.111-2.778 2.778-2.778h5.555c1.39 0 2.778 1.111 2.778 2.778V50h11.111V25c0-6.111-5-11.111-11.11-11.111z\" fill=\"#8BC34A\" fill-rule=\"evenodd\"><\/path><\/svg>"
},
"link": "http:\/\/www.hulu.com\/attack-on-titan",
"subs": ["en"],
"dubs": ["ja"]
}, {
"meta": {
"name": "Funimation",
"link": true,
"logo": "<svg width=\"50\" height=\"50\" viewBox=\"0 0 50 50\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><path d=\"M24.066.017a24.922 24.922 0 0 1 13.302 3.286 25.098 25.098 0 0 1 7.833 7.058 24.862 24.862 0 0 1 4.207 9.575c.82 4.001.641 8.201-.518 12.117a24.946 24.946 0 0 1-4.868 9.009 24.98 24.98 0 0 1-7.704 6.118 24.727 24.727 0 0 1-10.552 2.718A24.82 24.82 0 0 1 13.833 47.3c-5.815-2.872-10.408-8.107-12.49-14.25-2.162-6.257-1.698-13.375 1.303-19.28C5.483 8.07 10.594 3.55 16.602 1.435A24.94 24.94 0 0 1 24.066.017zm-8.415 33.31c.464 2.284 1.939 4.358 3.99 5.48 2.174 1.217 4.765 1.444 7.202 1.181 2.002-.217 3.986-.992 5.455-2.397 1.173-1.151 2.017-2.648 2.33-4.267-1.189-.027-2.378 0-3.566-.03-.568.082-1.137-.048-1.705.014-1.232.012-2.465.003-3.697-.01-.655.066-1.309-.035-1.963.013-1.166-.053-2.334.043-3.5-.025-1.515.08-3.03-.035-4.546.042z\" fill=\"#411299\" fill-rule=\"evenodd\"><\/path><\/svg>"
},
"link": "http:\/\/www.funimation.com\/shows\/attack-on-titan\/videos\/episodes",
"subs": ["en"],
"dubs": ["ja"]
}, {
"meta": {
"name": "Netflix",
"link": false,
"logo": "<svg width=\"50\" height=\"50\" viewBox=\"0 0 26 50\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><path d=\"M.057.258C2.518.253 4.982.263 7.446.253c2.858 7.76 5.621 15.556 8.456 23.324.523 1.441 1.003 2.897 1.59 4.312.078-9.209.01-18.42.034-27.631h7.763v46.36c-2.812.372-5.637.627-8.457.957-1.203-3.451-2.396-6.902-3.613-10.348-1.796-5.145-3.557-10.302-5.402-15.428.129 8.954.015 17.912.057 26.871-2.603.39-5.227.637-7.815 1.119C.052 33.279.06 16.768.057.258z\" fill=\"#E21221\" fill-rule=\"evenodd\"><\/path><\/svg>"
},
"link": "t",
"subs": ["en"],
"dubs": ["ja"]
}]
}

View File

@ -0,0 +1,291 @@
{
"slug": "attack-on-titan",
"synopsis": "Several hundred years ago, humans were nearly exterminated by titans. Titans are typically several stories tall, seem to have no intelligence, devour human beings and, worst of all, seem to do it for the pleasure rather than as a food source. A small percentage of humanity survived by enclosing themselves in a city protected by extremely high walls, even taller than the biggest of titans. Flash forward to the present and the city has not seen a titan in over 100 years. Teenage boy Eren and his foster sister Mikasa witness something horrific as the city walls are destroyed by a colossal titan that appears out of thin air. As the smaller titans flood the city, the two kids watch in horror as their mother is eaten alive. Eren vows that he will murder every single titan and take revenge for all of mankind.\n\n(Source: ANN)",
"coverImageTopOffset": 263,
"titles": {
"en": "Attack on Titan",
"en_jp": "Shingeki no Kyojin",
"ja_jp": "\u9032\u6483\u306e\u5de8\u4eba"
},
"canonicalTitle": "Attack on Titan",
"abbreviatedTitles": null,
"averageRating": 4.2678183033371,
"ratingFrequencies": {
"0.0": "3",
"0.5": "126",
"1.0": "292",
"1.5": "172",
"2.0": "394",
"2.5": "817",
"3.0": "2423",
"3.5": "3210",
"4.0": "5871",
"4.5": "6159",
"5.0": "13117",
"nil": "18571",
"0.479": "-1",
"4.658": "-3",
"4.726": "-1",
"4.932": "-1",
"2.05479452054794": "1",
"2.53424657534247": "1",
"4.10958904109589": "1",
"4.65753424657534": "3",
"4.72602739726027": "3",
"4.86301369863014": "1",
"4.93150684931507": "2",
"0.273972602739726": "1",
"0.410958904109589": "2",
"0.479452054794521": "1",
"0.684931506849315": "1"
},
"startDate": "2013-04-07",
"endDate": "2013-09-28",
"posterImage": {
"tiny": "https:\/\/media.kitsu.io\/anime\/poster_images\/7442\/tiny.jpg?1418580054",
"small": "https:\/\/media.kitsu.io\/anime\/poster_images\/7442\/small.jpg?1418580054",
"medium": "https:\/\/media.kitsu.io\/anime\/poster_images\/7442\/medium.jpg?1418580054",
"large": "https:\/\/media.kitsu.io\/anime\/poster_images\/7442\/large.jpg?1418580054",
"original": "https:\/\/media.kitsu.io\/anime\/poster_images\/7442\/original.jpg?1418580054"
},
"coverImage": {
"small": "https:\/\/media.kitsu.io\/anime\/cover_images\/7442\/small.jpg?1471880659",
"large": "https:\/\/media.kitsu.io\/anime\/cover_images\/7442\/large.jpg?1471880659",
"original": "https:\/\/media.kitsu.io\/anime\/cover_images\/7442\/original.png?1471880659"
},
"episodeCount": 25,
"episodeLength": 24,
"subtype": "TV",
"youtubeVideoId": "n4Nj6Y_SNYI",
"ageRating": "R",
"ageRatingGuide": "Violence, Profanity",
"showType": "TV",
"nsfw": false,
"included": [
{
"id": "23",
"type": "genres",
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/genres\/23"
},
"attributes": {
"name": "Super Power",
"slug": "super-power",
"description": null
}
},
{
"id": "11",
"type": "genres",
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/genres\/11"
},
"attributes": {
"name": "Fantasy",
"slug": "fantasy",
"description": ""
}
},
{
"id": "4",
"type": "genres",
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/genres\/4"
},
"attributes": {
"name": "Drama",
"slug": "drama",
"description": ""
}
},
{
"id": "1",
"type": "genres",
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/genres\/1"
},
"attributes": {
"name": "Action",
"slug": "action",
"description": ""
}
},
{
"id": "5686",
"type": "mappings",
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/mappings\/5686"
},
"attributes": {
"externalSite": "myanimelist\/anime",
"externalId": "16498"
},
"relationships": {
"media": {
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/mappings\/5686\/relationships\/media",
"related": "https:\/\/kitsu.io\/api\/edge\/mappings\/5686\/media"
}
}
}
},
{
"id": "14153",
"type": "mappings",
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/mappings\/14153"
},
"attributes": {
"externalSite": "thetvdb\/series",
"externalId": "267440"
},
"relationships": {
"media": {
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/mappings\/14153\/relationships\/media",
"related": "https:\/\/kitsu.io\/api\/edge\/mappings\/14153\/media"
}
}
}
},
{
"id": "15073",
"type": "mappings",
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/mappings\/15073"
},
"attributes": {
"externalSite": "thetvdb\/season",
"externalId": "514060"
},
"relationships": {
"media": {
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/mappings\/15073\/relationships\/media",
"related": "https:\/\/kitsu.io\/api\/edge\/mappings\/15073\/media"
}
}
}
},
{
"id": "103",
"type": "streamingLinks",
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/103"
},
"attributes": {
"url": "http:\/\/www.crunchyroll.com\/attack-on-titan",
"subs": [
"en"
],
"dubs": [
"ja"
]
},
"relationships": {
"streamer": {
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/103\/relationships\/streamer",
"related": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/103\/streamer"
}
},
"media": {
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/103\/relationships\/media",
"related": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/103\/media"
}
}
}
},
{
"id": "102",
"type": "streamingLinks",
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/102"
},
"attributes": {
"url": "http:\/\/www.hulu.com\/attack-on-titan",
"subs": [
"en"
],
"dubs": [
"ja"
]
},
"relationships": {
"streamer": {
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/102\/relationships\/streamer",
"related": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/102\/streamer"
}
},
"media": {
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/102\/relationships\/media",
"related": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/102\/media"
}
}
}
},
{
"id": "101",
"type": "streamingLinks",
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/101"
},
"attributes": {
"url": "http:\/\/www.funimation.com\/shows\/attack-on-titan\/videos\/episodes",
"subs": [
"en"
],
"dubs": [
"ja"
]
},
"relationships": {
"streamer": {
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/101\/relationships\/streamer",
"related": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/101\/streamer"
}
},
"media": {
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/101\/relationships\/media",
"related": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/101\/media"
}
}
}
},
{
"id": "100",
"type": "streamingLinks",
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/100"
},
"attributes": {
"url": "t",
"subs": [
"en"
],
"dubs": [
"ja"
]
},
"relationships": {
"streamer": {
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/100\/relationships\/streamer",
"related": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/100\/streamer"
}
},
"media": {
"links": {
"self": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/100\/relationships\/media",
"related": "https:\/\/kitsu.io\/api\/edge\/streaming-links\/100\/media"
}
}
}
}
]
}

View File

@ -1,28 +1 @@
{
"id": "14047981",
"mal_id": null,
"episodes": {
"watched": 38,
"total": 48,
"length": 24
},
"airing": {
"status": "Finished Airing",
"started": "2012-02-05",
"ended": "2013-01-27"
},
"anime": {
"age_rating": "PG",
"titles": ["Smile Precure!", "Glitter Force", "\u30b9\u30de\u30a4\u30eb\u30d7\u30ea\u30ad\u30e5\u30a2\uff01"],
"slug": "smile-precure",
"type": "TV",
"image": "https:\/\/media.kitsu.io\/anime\/poster_images\/6687\/small.jpg?1408459122",
"genres": ["Magic", "Kids", "Mahou Shoujo", "Fantasy"]
},
"watching_status": "current",
"notes": "Very formulaic.",
"rewatching": false,
"rewatched": 0,
"user_rating": 8,
"private": false
}
{"id":"15839442","mal_id":"33206","episodes":{"watched":0,"total":"-","length":null},"airing":{"status":"Currently Airing","started":"2017-01-12","ended":null},"anime":{"age_rating":null,"titles":["Kobayashi-san Chi no Maid Dragon","Miss Kobayashi's Dragon Maid","\u5c0f\u6797\u3055\u3093\u3061\u306e\u30e1\u30a4\u30c9\u30e9\u30b4\u30f3"],"slug":"kobayashi-san-chi-no-maid-dragon","type":"TV","image":"https:\/\/media.kitsu.io\/anime\/poster_images\/12243\/small.jpg?1481144116","genres":["Comedy","Fantasy","Slice of Life"],"streaming_links":[]},"watching_status":"current","notes":null,"rewatching":false,"rewatched":0,"user_rating":"-","private":false}

File diff suppressed because it is too large Load Diff