Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
6 changed files with 2203 additions and 0 deletions
Showing only changes of commit da4163bc6a - Show all commits

View File

@ -0,0 +1,71 @@
<?php declare(strict_types=1);
namespace Aviat\AnimeClient\Tests\API\Kitsu\Transformer;
use AnimeClient_TestCase;
use Aviat\AnimeClient\API\JsonAPI;
use Aviat\AnimeClient\API\Kitsu\Transformer\MangaListTransformer;
use Aviat\Ion\Json;
class MangaListTransformerTest extends AnimeClient_TestCase {
public function setUp()
{
parent::setUp();
$this->dir = AnimeClient_TestCase::TEST_DATA_DIR . '/Kitsu';
$rawBefore = Json::decodeFile("{$this->dir}/mangaListBeforeTransform.json");
$this->beforeTransform = JsonAPI::inlineRawIncludes($rawBefore, 'manga');
$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",
'chapters_read' => 67,
'manga' => [
'titles' => ["Bokura wa Minna Kawaisou"],
'alternate_title' => NULL,
'slug' => "bokura-wa-minna-kawaisou",
'url' => "https://kitsu.io/manga/bokura-wa-minna-kawaisou",
'type' => 'manga',
'image' => 'https://media.kitsu.io/manga/poster_images/20286/small.jpg?1434293999',
'genres' => [],
],
'status' => 'current',
'notes' => '',
'rereading' => false,
'reread_count' => 0,
'new_rating' => 9,
];
$actual = $this->transformer->untransform($input);
$expected = [
'id' => '15084773',
'data' => [
'status' => 'current',
'progress' => 67,
'reconsuming' => false,
'reconsumeCount' => 0,
'notes' => '',
'rating' => 4.5
]
];
$this->assertEquals($expected, $actual);
}
}

View File

@ -0,0 +1,34 @@
<?php declare(strict_types=1);
namespace Aviat\AnimeClient\Tests\API\Kitsu\Transformer;
use AnimeClient_TestCase;
use Aviat\AnimeClient\API\JsonAPI;
use Aviat\AnimeClient\API\Kitsu\Transformer\MangaTransformer;
use Aviat\Ion\Json;
class MangaTransformerTest extends AnimeClient_TestCase {
public function setUp()
{
parent::setUp();
$this->dir = AnimeClient_TestCase::TEST_DATA_DIR . '/Kitsu';
$data = Json::decodeFile("{$this->dir}/mangaBeforeTransform.json");
$baseData = $data['data'][0]['attributes'];
$baseData['included'] = $data['included'];
$this->beforeTransform = $baseData;
$this->afterTransform = Json::decodeFile("{$this->dir}/mangaAfterTransform.json");
$this->transformer = new MangaTransformer();
}
public function testTransform()
{
$actual = $this->transformer->transform($this->beforeTransform);
$expected = $this->afterTransform;
//Json::encodeFile("{$this->dir}/mangaAfterTransform.json", $actual);
$this->assertEquals($expected, $actual);
}
}

View File

@ -0,0 +1,12 @@
{
"title": "Bokura wa Minna Kawaisou",
"en_title": null,
"jp_title": "Bokura wa Minna Kawaisou",
"cover_image": "https:\/\/media.kitsu.io\/manga\/poster_images\/20286\/small.jpg?1434293999",
"manga_type": "manga",
"chapter_count": "-",
"volume_count": "-",
"synopsis": "Usa, a high-school student aspiring to begin a bachelor lifestyle, moves into a new apartment only to discover that he not only shares a room with a perverted roommate that has an obsession for underaged girls, but also that another girl, Ritsu, a love-at-first-sight, is living in the same building as well!\n(Source: Kirei Cake)",
"url": "https:\/\/kitsu.io\/manga\/bokura-wa-minna-kawaisou",
"genres": ["Comedy","Romance","School","Slice of Life","Thriller"]
}

View File

@ -0,0 +1,197 @@
{
"data": [{
"id": "20286",
"type": "manga",
"links": {
"self": "https://kitsu.io/api/edge/manga/20286"
},
"attributes": {
"slug": "bokura-wa-minna-kawaisou",
"synopsis": "Usa, a high-school student aspiring to begin a bachelor lifestyle, moves into a new apartment only to discover that he not only shares a room with a perverted roommate that has an obsession for underaged girls, but also that another girl, Ritsu, a love-at-first-sight, is living in the same building as well!\n(Source: Kirei Cake)",
"coverImageTopOffset": 40,
"titles": {
"en": null,
"en_jp": "Bokura wa Minna Kawaisou"
},
"canonicalTitle": "Bokura wa Minna Kawaisou",
"abbreviatedTitles": null,
"averageRating": 4.12281805954249,
"ratingFrequencies": {
"0.5": "0",
"1.0": "1",
"1.5": "0",
"2.0": "1",
"2.5": "2",
"3.0": "6",
"3.5": "21",
"4.0": "38",
"4.5": "35",
"5.0": "43",
"nil": "16"
},
"favoritesCount": 0,
"startDate": "2010-01-01",
"endDate": null,
"popularityRank": 262,
"ratingRank": 127,
"ageRating": "PG",
"ageRatingGuide": null,
"posterImage": {
"tiny": "https://media.kitsu.io/manga/poster_images/20286/tiny.jpg?1434293999",
"small": "https://media.kitsu.io/manga/poster_images/20286/small.jpg?1434293999",
"medium": "https://media.kitsu.io/manga/poster_images/20286/medium.jpg?1434293999",
"large": "https://media.kitsu.io/manga/poster_images/20286/large.jpg?1434293999",
"original": "https://media.kitsu.io/manga/poster_images/20286/original.jpg?1434293999"
},
"coverImage": {
"small": "https://media.kitsu.io/manga/cover_images/20286/small.jpg?1430793688",
"large": "https://media.kitsu.io/manga/cover_images/20286/large.jpg?1430793688",
"original": "https://media.kitsu.io/manga/cover_images/20286/original.jpg?1430793688"
},
"subtype": "manga",
"chapterCount": null,
"volumeCount": 0,
"serialization": "Young King Ours",
"mangaType": "manga"
},
"relationships": {
"genres": {
"links": {
"self": "https://kitsu.io/api/edge/manga/20286/relationships/genres",
"related": "https://kitsu.io/api/edge/manga/20286/genres"
},
"data": [{
"type": "genres",
"id": "3"
}, {
"type": "genres",
"id": "24"
}, {
"type": "genres",
"id": "16"
}, {
"type": "genres",
"id": "14"
}, {
"type": "genres",
"id": "18"
}]
},
"castings": {
"links": {
"self": "https://kitsu.io/api/edge/manga/20286/relationships/castings",
"related": "https://kitsu.io/api/edge/manga/20286/castings"
}
},
"installments": {
"links": {
"self": "https://kitsu.io/api/edge/manga/20286/relationships/installments",
"related": "https://kitsu.io/api/edge/manga/20286/installments"
}
},
"mappings": {
"links": {
"self": "https://kitsu.io/api/edge/manga/20286/relationships/mappings",
"related": "https://kitsu.io/api/edge/manga/20286/mappings"
},
"data": [{
"type": "mappings",
"id": "48014"
}]
},
"reviews": {
"links": {
"self": "https://kitsu.io/api/edge/manga/20286/relationships/reviews",
"related": "https://kitsu.io/api/edge/manga/20286/reviews"
}
},
"mediaRelationships": {
"links": {
"self": "https://kitsu.io/api/edge/manga/20286/relationships/media-relationships",
"related": "https://kitsu.io/api/edge/manga/20286/media-relationships"
}
}
}
}],
"included": [{
"id": "3",
"type": "genres",
"links": {
"self": "https://kitsu.io/api/edge/genres/3"
},
"attributes": {
"name": "Comedy",
"slug": "comedy",
"description": null
}
}, {
"id": "24",
"type": "genres",
"links": {
"self": "https://kitsu.io/api/edge/genres/24"
},
"attributes": {
"name": "School",
"slug": "school",
"description": null
}
}, {
"id": "16",
"type": "genres",
"links": {
"self": "https://kitsu.io/api/edge/genres/16"
},
"attributes": {
"name": "Slice of Life",
"slug": "slice-of-life",
"description": ""
}
}, {
"id": "14",
"type": "genres",
"links": {
"self": "https://kitsu.io/api/edge/genres/14"
},
"attributes": {
"name": "Romance",
"slug": "romance",
"description": ""
}
}, {
"id": "18",
"type": "genres",
"links": {
"self": "https://kitsu.io/api/edge/genres/18"
},
"attributes": {
"name": "Thriller",
"slug": "thriller",
"description": null
}
}, {
"id": "48014",
"type": "mappings",
"links": {
"self": "https://kitsu.io/api/edge/mappings/48014"
},
"attributes": {
"externalSite": "myanimelist/manga",
"externalId": "26769"
},
"relationships": {
"media": {
"links": {
"self": "https://kitsu.io/api/edge/mappings/48014/relationships/media",
"related": "https://kitsu.io/api/edge/mappings/48014/media"
}
}
}
}],
"meta": {
"count": 1
},
"links": {
"first": "https://kitsu.io/api/edge/manga?filter%5Bslug%5D=bokura-wa-minna-kawaisou&include=genres%2Cmappings&page%5Blimit%5D=10&page%5Boffset%5D=0",
"last": "https://kitsu.io/api/edge/manga?filter%5Bslug%5D=bokura-wa-minna-kawaisou&include=genres%2Cmappings&page%5Blimit%5D=10&page%5Boffset%5D=0"
}
}

View File

@ -0,0 +1,241 @@
[{
"id": "15084773",
"chapters": {
"read": 67,
"total": "-"
},
"volumes": {
"read": "-",
"total": "-"
},
"manga": {
"titles": ["Bokura wa Minna Kawaisou"],
"alternate_title": null,
"slug": "bokura-wa-minna-kawaisou",
"url": "https:\/\/kitsu.io\/manga\/bokura-wa-minna-kawaisou",
"type": "manga",
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/20286\/small.jpg?1434293999",
"genres": []
},
"reading_status": "current",
"notes": "",
"rereading": false,
"reread": 0,
"user_rating": 9
}, {
"id": "15085607",
"chapters": {
"read": 17,
"total": 120
},
"volumes": {
"read": "-",
"total": 14
},
"manga": {
"titles": ["Love Hina"],
"alternate_title": null,
"slug": "love-hina",
"url": "https:\/\/kitsu.io\/manga\/love-hina",
"type": "manga",
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/47\/small.jpg?1434249493",
"genres": []
},
"reading_status": "current",
"notes": "",
"rereading": false,
"reread": 0,
"user_rating": 7
}, {
"id": "15084529",
"chapters": {
"read": 16,
"total": "-"
},
"volumes": {
"read": "-",
"total": "-"
},
"manga": {
"titles": ["Yamada-kun to 7-nin no Majo", "Yamada-kun and the Seven Witches"],
"alternate_title": null,
"slug": "yamada-kun-to-7-nin-no-majo",
"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": []
},
"reading_status": "current",
"notes": "",
"rereading": false,
"reread": 0,
"user_rating": 9
}, {
"id": "15312827",
"chapters": {
"read": 68,
"total": "-"
},
"volumes": {
"read": "-",
"total": "-"
},
"manga": {
"titles": ["ReLIFE"],
"alternate_title": null,
"slug": "relife",
"url": "https:\/\/kitsu.io\/manga\/relife",
"type": "manga",
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/27175\/small.jpg?1464379411",
"genres": []
},
"reading_status": "current",
"notes": "",
"rereading": false,
"reread": 0,
"user_rating": "-"
}, {
"id": "15084772",
"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,
"total": "-"
},
"volumes": {
"read": "-",
"total": "-"
},
"manga": {
"titles": ["Shishunki Bitter Change"],
"alternate_title": null,
"slug": "shishunki-bitter-change",
"url": "https:\/\/kitsu.io\/manga\/shishunki-bitter-change",
"type": "manga",
"image": "https:\/\/media.kitsu.io\/manga\/poster_images\/25512\/small.jpg?1434305092",
"genres": []
},
"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",
"notes": "",
"rereading": false,
"reread": 0,
"user_rating": 8
}]

File diff suppressed because it is too large Load Diff