Fix tests, and category list for Manga detail page

This commit is contained in:
Timothy Warren 2018-10-16 14:32:52 -04:00
parent 12dfb491bc
commit fccc794528
3 changed files with 135 additions and 132 deletions

View File

@ -35,9 +35,12 @@ final class MangaTransformer extends AbstractTransformer {
{ {
$genres = []; $genres = [];
foreach($included['categories'] as $cat) foreach($item['included'] as $included)
{ {
$genres[] = $cat['title']; if ($included['type'] === 'categories')
{
$genres[] = $included['attributes']['title'];
}
} }
sort($genres); sort($genres);

View File

@ -115,19 +115,19 @@
"showType": "TV", "showType": "TV",
"nsfw": false, "nsfw": false,
"relationships": { "relationships": {
"genres": { "categories": {
"3": { "3": {
"name": "Comedy", "title": "Comedy",
"slug": "comedy", "slug": "comedy",
"description": null "description": null
}, },
"11": { "11": {
"name": "Fantasy", "title": "Fantasy",
"slug": "fantasy", "slug": "fantasy",
"description": "" "description": ""
}, },
"16": { "16": {
"name": "Slice of Life", "title": "Slice of Life",
"slug": "slice-of-life", "slug": "slice-of-life",
"description": "" "description": ""
} }
@ -189,24 +189,24 @@
"showType": "TV", "showType": "TV",
"nsfw": false, "nsfw": false,
"relationships": { "relationships": {
"genres": { "categories": {
"8": { "8": {
"name": "Magic", "title": "Magic",
"slug": "magic", "slug": "magic",
"description": null "description": null
}, },
"40": { "40": {
"name": "Kids", "title": "Kids",
"slug": "kids", "slug": "kids",
"description": null "description": null
}, },
"47": { "47": {
"name": "Mahou Shoujo", "title": "Mahou Shoujo",
"slug": "mahou-shoujo", "slug": "mahou-shoujo",
"description": "Magical Girls" "description": "Magical Girls"
}, },
"11": { "11": {
"name": "Fantasy", "title": "Fantasy",
"slug": "fantasy", "slug": "fantasy",
"description": "" "description": ""
} }
@ -265,9 +265,9 @@
"showType": "TV", "showType": "TV",
"nsfw": false, "nsfw": false,
"relationships": { "relationships": {
"genres": { "categories": {
"35": { "35": {
"name": "Music", "title": "Music",
"slug": "music", "slug": "music",
"description": null "description": null
} }
@ -325,19 +325,19 @@
"showType": "TV", "showType": "TV",
"nsfw": false, "nsfw": false,
"relationships": { "relationships": {
"genres": { "categories": {
"3": { "3": {
"name": "Comedy", "title": "Comedy",
"slug": "comedy", "slug": "comedy",
"description": null "description": null
}, },
"9": { "9": {
"name": "Supernatural", "title": "Supernatural",
"slug": "supernatural", "slug": "supernatural",
"description": null "description": null
}, },
"24": { "24": {
"name": "School", "title": "School",
"slug": "school", "slug": "school",
"description": null "description": null
} }
@ -399,29 +399,29 @@
"showType": "TV", "showType": "TV",
"nsfw": false, "nsfw": false,
"relationships": { "relationships": {
"genres": { "categories": {
"2": { "2": {
"name": "Adventure", "title": "Adventure",
"slug": "adventure", "slug": "adventure",
"description": null "description": null
}, },
"3": { "3": {
"name": "Comedy", "title": "Comedy",
"slug": "comedy", "slug": "comedy",
"description": null "description": null
}, },
"8": { "8": {
"name": "Magic", "title": "Magic",
"slug": "magic", "slug": "magic",
"description": null "description": null
}, },
"9": { "9": {
"name": "Supernatural", "title": "Supernatural",
"slug": "supernatural", "slug": "supernatural",
"description": null "description": null
}, },
"11": { "11": {
"name": "Fantasy", "title": "Fantasy",
"slug": "fantasy", "slug": "fantasy",
"description": "" "description": ""
} }
@ -479,14 +479,14 @@
"showType": "TV", "showType": "TV",
"nsfw": false, "nsfw": false,
"relationships": { "relationships": {
"genres": { "categories": {
"3": { "3": {
"name": "Comedy", "title": "Comedy",
"slug": "comedy", "slug": "comedy",
"description": null "description": null
}, },
"16": { "16": {
"name": "Slice of Life", "title": "Slice of Life",
"slug": "slice-of-life", "slug": "slice-of-life",
"description": "" "description": ""
} }
@ -547,24 +547,24 @@
"showType": "TV", "showType": "TV",
"nsfw": false, "nsfw": false,
"relationships": { "relationships": {
"genres": { "categories": {
"3": { "3": {
"name": "Comedy", "title": "Comedy",
"slug": "comedy", "slug": "comedy",
"description": null "description": null
}, },
"24": { "24": {
"name": "School", "title": "School",
"slug": "school", "slug": "school",
"description": null "description": null
}, },
"34": { "34": {
"name": "Harem", "title": "Harem",
"slug": "harem", "slug": "harem",
"description": null "description": null
}, },
"14": { "14": {
"name": "Romance", "title": "Romance",
"slug": "romance", "slug": "romance",
"description": "" "description": ""
} }
@ -619,19 +619,19 @@
"showType": "TV", "showType": "TV",
"nsfw": false, "nsfw": false,
"relationships": { "relationships": {
"genres": { "categories": {
"3": { "3": {
"name": "Comedy", "title": "Comedy",
"slug": "comedy", "slug": "comedy",
"description": null "description": null
}, },
"9": { "9": {
"name": "Supernatural", "title": "Supernatural",
"slug": "supernatural", "slug": "supernatural",
"description": null "description": null
}, },
"24": { "24": {
"name": "School", "title": "School",
"slug": "school", "slug": "school",
"description": null "description": null
} }
@ -689,24 +689,24 @@
"showType": "special", "showType": "special",
"nsfw": false, "nsfw": false,
"relationships": { "relationships": {
"genres": { "categories": {
"8": { "8": {
"name": "Magic", "title": "Magic",
"slug": "magic", "slug": "magic",
"description": null "description": null
}, },
"9": { "9": {
"name": "Supernatural", "title": "Supernatural",
"slug": "supernatural", "slug": "supernatural",
"description": null "description": null
}, },
"11": { "11": {
"name": "Fantasy", "title": "Fantasy",
"slug": "fantasy", "slug": "fantasy",
"description": "" "description": ""
}, },
"1": { "1": {
"name": "Action", "title": "Action",
"slug": "action", "slug": "action",
"description": "" "description": ""
} }
@ -764,14 +764,14 @@
"showType": "TV", "showType": "TV",
"nsfw": false, "nsfw": false,
"relationships": { "relationships": {
"genres": { "categories": {
"3": { "3": {
"name": "Comedy", "title": "Comedy",
"slug": "comedy", "slug": "comedy",
"description": null "description": null
}, },
"35": { "35": {
"name": "Music", "title": "Music",
"slug": "music", "slug": "music",
"description": null "description": null
} }
@ -829,29 +829,29 @@
"showType": "TV", "showType": "TV",
"nsfw": false, "nsfw": false,
"relationships": { "relationships": {
"genres": { "categories": {
"8": { "8": {
"name": "Magic", "title": "Magic",
"slug": "magic", "slug": "magic",
"description": null "description": null
}, },
"27": { "27": {
"name": "Historical", "title": "Historical",
"slug": "historical", "slug": "historical",
"description": null "description": null
}, },
"28": { "28": {
"name": "Military", "title": "Military",
"slug": "military", "slug": "military",
"description": null "description": null
}, },
"4": { "4": {
"name": "Drama", "title": "Drama",
"slug": "drama", "slug": "drama",
"description": "" "description": ""
}, },
"1": { "1": {
"name": "Action", "title": "Action",
"slug": "action", "slug": "action",
"description": "" "description": ""
} }
@ -913,9 +913,9 @@
"showType": "TV", "showType": "TV",
"nsfw": false, "nsfw": false,
"relationships": { "relationships": {
"genres": { "categories": {
"3": { "3": {
"name": "Comedy", "title": "Comedy",
"slug": "comedy", "slug": "comedy",
"description": null "description": null
} }
@ -977,24 +977,24 @@
"showType": "TV", "showType": "TV",
"nsfw": false, "nsfw": false,
"relationships": { "relationships": {
"genres": { "categories": {
"7": { "7": {
"name": "Mystery", "title": "Mystery",
"slug": "mystery", "slug": "mystery",
"description": null "description": null
}, },
"9": { "9": {
"name": "Supernatural", "title": "Supernatural",
"slug": "supernatural", "slug": "supernatural",
"description": null "description": null
}, },
"4": { "4": {
"name": "Drama", "title": "Drama",
"slug": "drama", "slug": "drama",
"description": "" "description": ""
}, },
"1": { "1": {
"name": "Action", "title": "Action",
"slug": "action", "slug": "action",
"description": "" "description": ""
} }
@ -1056,29 +1056,29 @@
"showType": "TV", "showType": "TV",
"nsfw": false, "nsfw": false,
"relationships": { "relationships": {
"genres": { "categories": {
"9": { "9": {
"name": "Supernatural", "title": "Supernatural",
"slug": "supernatural", "slug": "supernatural",
"description": null "description": null
}, },
"21": { "21": {
"name": "Thriller", "title": "Thriller",
"slug": "thriller", "slug": "thriller",
"description": null "description": null
}, },
"47": { "47": {
"name": "Mahou Shoujo", "title": "Mahou Shoujo",
"slug": "mahou-shoujo", "slug": "mahou-shoujo",
"description": "Magical Girls" "description": "Magical Girls"
}, },
"11": { "11": {
"name": "Fantasy", "title": "Fantasy",
"slug": "fantasy", "slug": "fantasy",
"description": "" "description": ""
}, },
"1": { "1": {
"name": "Action", "title": "Action",
"slug": "action", "slug": "action",
"description": "" "description": ""
} }

View File

@ -419,30 +419,30 @@
"mangaType": "manga" "mangaType": "manga"
}, },
"relationships": { "relationships": {
"genres": { "categories": {
"links": { "links": {
"self": "https://kitsu.io/api/edge/manga/20286/relationships/genres", "self": "https://kitsu.io/api/edge/manga/20286/relationships/categories",
"related": "https://kitsu.io/api/edge/manga/20286/genres" "related": "https://kitsu.io/api/edge/manga/20286/categories"
}, },
"data": [ "data": [
{ {
"type": "genres", "type": "categories",
"id": "3" "id": "3"
}, },
{ {
"type": "genres", "type": "categories",
"id": "21" "id": "21"
}, },
{ {
"type": "genres", "type": "categories",
"id": "24" "id": "24"
}, },
{ {
"type": "genres", "type": "categories",
"id": "16" "id": "16"
}, },
{ {
"type": "genres", "type": "categories",
"id": "14" "id": "14"
} }
] ]
@ -554,30 +554,30 @@
"mangaType": "manga" "mangaType": "manga"
}, },
"relationships": { "relationships": {
"genres": { "categories": {
"links": { "links": {
"self": "https://kitsu.io/api/edge/manga/47/relationships/genres", "self": "https://kitsu.io/api/edge/manga/47/relationships/categories",
"related": "https://kitsu.io/api/edge/manga/47/genres" "related": "https://kitsu.io/api/edge/manga/47/categories"
}, },
"data": [ "data": [
{ {
"type": "genres", "type": "categories",
"id": "3" "id": "3"
}, },
{ {
"type": "genres", "type": "categories",
"id": "13" "id": "13"
}, },
{ {
"type": "genres", "type": "categories",
"id": "34" "id": "34"
}, },
{ {
"type": "genres", "type": "categories",
"id": "14" "id": "14"
}, },
{ {
"type": "genres", "type": "categories",
"id": "25" "id": "25"
} }
] ]
@ -689,38 +689,38 @@
"mangaType": "manga" "mangaType": "manga"
}, },
"relationships": { "relationships": {
"genres": { "categories": {
"links": { "links": {
"self": "https://kitsu.io/api/edge/manga/11777/relationships/genres", "self": "https://kitsu.io/api/edge/manga/11777/relationships/categories",
"related": "https://kitsu.io/api/edge/manga/11777/genres" "related": "https://kitsu.io/api/edge/manga/11777/categories"
}, },
"data": [ "data": [
{ {
"type": "genres", "type": "categories",
"id": "3" "id": "3"
}, },
{ {
"type": "genres", "type": "categories",
"id": "9" "id": "9"
}, },
{ {
"type": "genres", "type": "categories",
"id": "13" "id": "13"
}, },
{ {
"type": "genres", "type": "categories",
"id": "24" "id": "24"
}, },
{ {
"type": "genres", "type": "categories",
"id": "45" "id": "45"
}, },
{ {
"type": "genres", "type": "categories",
"id": "14" "id": "14"
}, },
{ {
"type": "genres", "type": "categories",
"id": "25" "id": "25"
} }
] ]
@ -832,22 +832,22 @@
"mangaType": "manga" "mangaType": "manga"
}, },
"relationships": { "relationships": {
"genres": { "categories": {
"links": { "links": {
"self": "https://kitsu.io/api/edge/manga/27175/relationships/genres", "self": "https://kitsu.io/api/edge/manga/27175/relationships/categories",
"related": "https://kitsu.io/api/edge/manga/27175/genres" "related": "https://kitsu.io/api/edge/manga/27175/categories"
}, },
"data": [ "data": [
{ {
"type": "genres", "type": "categories",
"id": "24" "id": "24"
}, },
{ {
"type": "genres", "type": "categories",
"id": "16" "id": "16"
}, },
{ {
"type": "genres", "type": "categories",
"id": "14" "id": "14"
} }
] ]
@ -954,22 +954,22 @@
"mangaType": "manga" "mangaType": "manga"
}, },
"relationships": { "relationships": {
"genres": { "categories": {
"links": { "links": {
"self": "https://kitsu.io/api/edge/manga/25491/relationships/genres", "self": "https://kitsu.io/api/edge/manga/25491/relationships/categories",
"related": "https://kitsu.io/api/edge/manga/25491/genres" "related": "https://kitsu.io/api/edge/manga/25491/categories"
}, },
"data": [ "data": [
{ {
"type": "genres", "type": "categories",
"id": "3" "id": "3"
}, },
{ {
"type": "genres", "type": "categories",
"id": "24" "id": "24"
}, },
{ {
"type": "genres", "type": "categories",
"id": "16" "id": "16"
} }
] ]
@ -1026,120 +1026,120 @@
}, },
{ {
"id": "3", "id": "3",
"type": "genres", "type": "categories",
"links": { "links": {
"self": "https://kitsu.io/api/edge/genres/3" "self": "https://kitsu.io/api/edge/categories/3"
}, },
"attributes": { "attributes": {
"name": "Comedy", "title": "Comedy",
"slug": "comedy", "slug": "comedy",
"description": null "description": null
} }
}, },
{ {
"id": "21", "id": "21",
"type": "genres", "type": "categories",
"links": { "links": {
"self": "https://kitsu.io/api/edge/genres/21" "self": "https://kitsu.io/api/edge/categories/21"
}, },
"attributes": { "attributes": {
"name": "Thriller", "title": "Thriller",
"slug": "thriller", "slug": "thriller",
"description": null "description": null
} }
}, },
{ {
"id": "24", "id": "24",
"type": "genres", "type": "categories",
"links": { "links": {
"self": "https://kitsu.io/api/edge/genres/24" "self": "https://kitsu.io/api/edge/categories/24"
}, },
"attributes": { "attributes": {
"name": "School", "title": "School",
"slug": "school", "slug": "school",
"description": null "description": null
} }
}, },
{ {
"id": "16", "id": "16",
"type": "genres", "type": "categories",
"links": { "links": {
"self": "https://kitsu.io/api/edge/genres/16" "self": "https://kitsu.io/api/edge/categories/16"
}, },
"attributes": { "attributes": {
"name": "Slice of Life", "title": "Slice of Life",
"slug": "slice-of-life", "slug": "slice-of-life",
"description": "" "description": ""
} }
}, },
{ {
"id": "14", "id": "14",
"type": "genres", "type": "categories",
"links": { "links": {
"self": "https://kitsu.io/api/edge/genres/14" "self": "https://kitsu.io/api/edge/categories/14"
}, },
"attributes": { "attributes": {
"name": "Romance", "title": "Romance",
"slug": "romance", "slug": "romance",
"description": "" "description": ""
} }
}, },
{ {
"id": "13", "id": "13",
"type": "genres", "type": "categories",
"links": { "links": {
"self": "https://kitsu.io/api/edge/genres/13" "self": "https://kitsu.io/api/edge/categories/13"
}, },
"attributes": { "attributes": {
"name": "Sports", "title": "Sports",
"slug": "sports", "slug": "sports",
"description": null "description": null
} }
}, },
{ {
"id": "34", "id": "34",
"type": "genres", "type": "categories",
"links": { "links": {
"self": "https://kitsu.io/api/edge/genres/34" "self": "https://kitsu.io/api/edge/categories/34"
}, },
"attributes": { "attributes": {
"name": "Harem", "title": "Harem",
"slug": "harem", "slug": "harem",
"description": null "description": null
} }
}, },
{ {
"id": "25", "id": "25",
"type": "genres", "type": "categories",
"links": { "links": {
"self": "https://kitsu.io/api/edge/genres/25" "self": "https://kitsu.io/api/edge/categories/25"
}, },
"attributes": { "attributes": {
"name": "Ecchi", "title": "Ecchi",
"slug": "ecchi", "slug": "ecchi",
"description": "" "description": ""
} }
}, },
{ {
"id": "9", "id": "9",
"type": "genres", "type": "categories",
"links": { "links": {
"self": "https://kitsu.io/api/edge/genres/9" "self": "https://kitsu.io/api/edge/categories/9"
}, },
"attributes": { "attributes": {
"name": "Supernatural", "title": "Supernatural",
"slug": "supernatural", "slug": "supernatural",
"description": null "description": null
} }
}, },
{ {
"id": "45", "id": "45",
"type": "genres", "type": "categories",
"links": { "links": {
"self": "https://kitsu.io/api/edge/genres/45" "self": "https://kitsu.io/api/edge/categories/45"
}, },
"attributes": { "attributes": {
"name": "Gender Bender", "title": "Gender Bender",
"slug": "gender-bender", "slug": "gender-bender",
"description": "" "description": ""
} }
@ -1244,7 +1244,7 @@
"count": 5 "count": 5
}, },
"links": { "links": {
"first": "https://kitsu.io/api/edge/library-entries?fields%5Busers%5D=id&filter%5Bmedia_type%5D=Manga&filter%5Bstatus%5D=1&filter%5Buser_id%5D=2644&include=media%2Cmedia.genres%2Cmedia.mappings&page%5Blimit%5D=200&page%5Boffset%5D=0&sort=-updated_at", "first": "https://kitsu.io/api/edge/library-entries?fields%5Busers%5D=id&filter%5Bmedia_type%5D=Manga&filter%5Bstatus%5D=1&filter%5Buser_id%5D=2644&include=media%2Cmedia.categories%2Cmedia.mappings&page%5Blimit%5D=200&page%5Boffset%5D=0&sort=-updated_at",
"last": "https://kitsu.io/api/edge/library-entries?fields%5Busers%5D=id&filter%5Bmedia_type%5D=Manga&filter%5Bstatus%5D=1&filter%5Buser_id%5D=2644&include=media%2Cmedia.genres%2Cmedia.mappings&page%5Blimit%5D=200&page%5Boffset%5D=0&sort=-updated_at" "last": "https://kitsu.io/api/edge/library-entries?fields%5Busers%5D=id&filter%5Bmedia_type%5D=Manga&filter%5Bstatus%5D=1&filter%5Buser_id%5D=2644&include=media%2Cmedia.categories%2Cmedia.mappings&page%5Blimit%5D=200&page%5Boffset%5D=0&sort=-updated_at"
} }
} }