From 3b3156e78a48882fd27879dab9005ca97c7c4503 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Wed, 8 Aug 2018 13:05:38 -0400 Subject: [PATCH] More refactoring, fix snapshot tests --- app/views/manga/cover.php | 2 +- app/views/manga/edit.php | 8 +- app/views/manga/list.php | 2 +- index.php | 9 +- public/css.js | 2 +- public/js.php | 11 +- public/js/cache/.gitkeep | 0 src/API/Kitsu/Model.php | 18 +- .../Transformer/MangaListTransformer.php | 45 ++-- .../Kitsu/Transformer/MangaTransformer.php | 14 +- src/API/MAL/Model.php | 6 +- src/Model/Anime.php | 2 +- src/Model/Manga.php | 34 ++- src/Types/AbstractType.php | 11 + src/Types/AnimeFormItem.php | 6 +- src/Types/AnimeFormItemData.php | 10 +- src/Types/FormItem.php | 27 ++ src/Types/FormItemData.php | 30 +++ src/Types/MangaFormItem.php | 23 ++ src/Types/MangaFormItemData.php | 19 ++ src/Types/MangaListItem.php | 40 +++ src/Types/MangaListItemDetail.php | 31 +++ src/Types/MangaPage.php | 35 +++ .../Transformer/MangaListTransformerTest.php | 12 +- ...eListTransformerTest__testTransform__1.php | 65 +++-- ...t__testUntransform with data set #0__1.php | 28 +- ...t__testUntransform with data set #1__1.php | 28 +- ...t__testUntransform with data set #2__1.php | 27 +- ...AnimeTransformerTest__testTransform__1.php | 42 +-- ...aListTransformerTest__testTransform__1.php | 247 +++++++++--------- ...MangaTransformerTest__testTransform__1.php | 34 ++- 31 files changed, 549 insertions(+), 319 deletions(-) mode change 100644 => 100755 public/js/cache/.gitkeep create mode 100644 src/Types/FormItem.php create mode 100644 src/Types/FormItemData.php create mode 100644 src/Types/MangaFormItem.php create mode 100644 src/Types/MangaFormItemData.php create mode 100644 src/Types/MangaListItem.php create mode 100644 src/Types/MangaListItemDetail.php create mode 100644 src/Types/MangaPage.php diff --git a/app/views/manga/cover.php b/app/views/manga/cover.php index 90d02e97..6ced8cae 100644 --- a/app/views/manga/cover.php +++ b/app/views/manga/cover.php @@ -26,7 +26,7 @@ " />
- html(array_shift($item['manga']['titles'])) ?> + html($item['manga']['title']) ?>
diff --git a/app/views/manga/edit.php b/app/views/manga/edit.php index 14105b2e..12b3c077 100644 --- a/app/views/manga/edit.php +++ b/app/views/manga/edit.php @@ -8,7 +8,7 @@ -

html(array_shift($item['manga']['titles'])) ?>

+

html($item['manga']['title']) ?>

html($title) ?>

@@ -44,12 +44,12 @@ / - + - / + / - */ ?> + diff --git a/app/views/manga/list.php b/app/views/manga/list.php index 89c2fe19..e7c81ed2 100644 --- a/app/views/manga/list.php +++ b/app/views/manga/list.php @@ -39,7 +39,7 @@
- +
diff --git a/index.php b/index.php index b13fc9ac..a23462f7 100644 --- a/index.php +++ b/index.php @@ -28,9 +28,12 @@ if ($timezone === '' || $timezone === FALSE) // Load composer autoloader require_once __DIR__ . '/vendor/autoload.php'; -$whoops = new \Whoops\Run; -$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler); -$whoops->register(); +// if (array_key_exists('ENV', $_ENV) && $_ENV['ENV'] === 'development') +{ + $whoops = new \Whoops\Run; + $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler); + $whoops->register(); +} // Define base directories $APP_DIR = _dir(__DIR__, 'app'); diff --git a/public/css.js b/public/css.js index 1db6c13e..df99fd96 100644 --- a/public/css.js +++ b/public/css.js @@ -7,7 +7,7 @@ const atImport = require('postcss-import'); const cssNext = require('postcss-cssnext'); const cssNano = require('cssnano'); -const css = fs.readFileSync('css/base.css', 'utf8'); +const css = fs.readFileSync('css/base.css', 'utf-8'); postcss() .use(atImport()) diff --git a/public/js.php b/public/js.php index cc9eaed6..8370c65d 100644 --- a/public/js.php +++ b/public/js.php @@ -22,7 +22,7 @@ use Aviat\AnimeClient\API\HummingbirdClient; use Aviat\Ion\{Json, JsonException}; // Include Amp and Artax -require_once('../vendor/autoload.php'); +require_once '../vendor/autoload.php'; //Creative rewriting of /g/groupname to ?g=groupname $pi = $_SERVER['PATH_INFO']; @@ -318,10 +318,11 @@ class JSMin { $lastModifiedDate = gmdate('D, d M Y H:i:s', $lastModified); $expiresDate = gmdate('D, d M Y H:i:s', $expires); - header("Content-Type: {$mimeType}; charset=utf8"); - header("Cache-control: public, max-age=691200, must-revalidate"); - header("Last-Modified: {$lastModifiedDate} GMT"); + header("Content-Type: {$mimeType}; charset=utf-8"); + header('Cache-control: public, max-age=691200, must-revalidate'); header("Expires: {$expiresDate} GMT"); + header("Last-Modified: {$lastModifiedDate} GMT"); + header('X-Content-Type-Options: no-sniff'); echo $content; @@ -335,7 +336,7 @@ class JSMin { */ public static function send304() { - header("status: 304 Not Modified", true, 304); + header('status: 304 Not Modified', true, 304); } } diff --git a/public/js/cache/.gitkeep b/public/js/cache/.gitkeep old mode 100644 new mode 100755 diff --git a/src/API/Kitsu/Model.php b/src/API/Kitsu/Model.php index 63e2e021..42963390 100644 --- a/src/API/Kitsu/Model.php +++ b/src/API/Kitsu/Model.php @@ -37,9 +37,11 @@ use Aviat\AnimeClient\API\Kitsu\Transformer\{ MangaListTransformer }; use Aviat\AnimeClient\Types\{ + AbstractType, Anime, - AnimeFormItem, - AnimeListItem + FormItem, + AnimeListItem, + MangaPage }; use Aviat\Ion\{Di\ContainerAware, Json}; @@ -562,15 +564,15 @@ final class Model { * Get information about a particular manga * * @param string $slug - * @return array + * @return MangaPage */ - public function getManga(string $slug): array + public function getManga(string $slug): MangaPage { $baseData = $this->getRawMediaData('manga', $slug); if (empty($baseData)) { - return []; + return new MangaPage([]); } $transformed = $this->mangaTransformer->transform($baseData); @@ -584,7 +586,7 @@ final class Model { * @param string $mangaId * @return array */ - public function getMangaById(string $mangaId): array + public function getMangaById(string $mangaId): MangaPage { $baseData = $this->getRawMediaDataById('manga', $mangaId); return $this->mangaTransformer->transform($baseData); @@ -837,10 +839,10 @@ final class Model { /** * Modify a list item * - * @param AnimeFormItem $data + * @param FormItem $data * @return Request */ - public function updateListItem(AnimeFormItem $data): Request + public function updateListItem(FormItem $data): Request { return $this->listItem->update($data['id'], $data['data']); } diff --git a/src/API/Kitsu/Transformer/MangaListTransformer.php b/src/API/Kitsu/Transformer/MangaListTransformer.php index 60ce4d19..b41bd805 100644 --- a/src/API/Kitsu/Transformer/MangaListTransformer.php +++ b/src/API/Kitsu/Transformer/MangaListTransformer.php @@ -17,6 +17,10 @@ namespace Aviat\AnimeClient\API\Kitsu\Transformer; use Aviat\AnimeClient\API\Kitsu; +use Aviat\AnimeClient\Types\{ + MangaFormItem, MangaFormItemData, + MangaListItem, MangaListItemDetail +}; use Aviat\Ion\StringWrapper; use Aviat\Ion\Transformer\AbstractTransformer; @@ -31,9 +35,9 @@ final class MangaListTransformer extends AbstractTransformer { * Remap zipped anime data to a more logical form * * @param array $item manga entry item - * @return array + * @return MangaListItem */ - public function transform($item): array + public function transform($item): MangaListItem { $included = $item['included']; $mangaId = $item['relationships']['media']['data']['id']; @@ -72,7 +76,10 @@ final class MangaListTransformer extends AbstractTransformer { } } - $map = [ + $titles = Kitsu::filterTitles($manga); + $title = array_shift($titles); + + $map = new MangaListItem([ 'id' => $item['id'], 'mal_id' => $MALid, 'chapters' => [ @@ -83,22 +90,22 @@ final class MangaListTransformer extends AbstractTransformer { 'read' => '-', //$item['attributes']['volumes_read'], 'total' => $totalVolumes ], - 'manga' => [ - 'id' => $mangaId, - 'titles' => Kitsu::filterTitles($manga), - 'alternate_title' => NULL, - 'slug' => $manga['slug'], - 'url' => 'https://kitsu.io/manga/' . $manga['slug'], - 'type' => $manga['mangaType'], - 'image' => $manga['posterImage']['small'], + 'manga' => new MangaListItemDetail([ 'genres' => $genres, - ], + 'id' => $mangaId, + 'image' => $manga['posterImage']['small'], + 'slug' => $manga['slug'], + 'title' => $title, + 'titles' => $titles, + 'type' => $manga['mangaType'], + 'url' => 'https://kitsu.io/manga/' . $manga['slug'], + ]), 'reading_status' => $item['attributes']['status'], 'notes' => $item['attributes']['notes'], 'rereading' => (bool)$item['attributes']['reconsuming'], 'reread' => $item['attributes']['reconsumeCount'], 'user_rating' => $rating, - ]; + ]); return $map; } @@ -107,22 +114,22 @@ final class MangaListTransformer extends AbstractTransformer { * Untransform data to update the api * * @param array $item - * @return array + * @return MangaFormItem */ - public function untransform($item): array + public function untransform($item): MangaFormItem { $rereading = array_key_exists('rereading', $item) && (bool)$item['rereading']; - $map = [ + $map = new MangaFormItem([ 'id' => $item['id'], 'mal_id' => $item['mal_id'], - 'data' => [ + 'data' => new MangaFormItemData([ 'status' => $item['status'], 'reconsuming' => $rereading, 'reconsumeCount' => (int)$item['reread_count'], 'notes' => $item['notes'], - ], - ]; + ]), + ]); if (is_numeric($item['chapters_read']) && $item['chapters_read'] > 0) { diff --git a/src/API/Kitsu/Transformer/MangaTransformer.php b/src/API/Kitsu/Transformer/MangaTransformer.php index 532b37a1..afd468d5 100644 --- a/src/API/Kitsu/Transformer/MangaTransformer.php +++ b/src/API/Kitsu/Transformer/MangaTransformer.php @@ -16,6 +16,7 @@ namespace Aviat\AnimeClient\API\Kitsu\Transformer; +use Aviat\AnimeClient\Types\MangaPage; use Aviat\Ion\Transformer\AbstractTransformer; /** @@ -28,23 +29,24 @@ final class MangaTransformer extends AbstractTransformer { * logical and workable structure * * @param array $item API library item - * @return array + * @return MangaPage */ - public function transform($item) + public function transform($item): MangaPage { + // \dump($item); $genres = []; foreach($item['included'] as $included) { - if ($included['type'] === 'genres') + if ($included['type'] === 'categories') { - $genres[] = $included['attributes']['name']; + $genres[] = $included['attributes']['title']; } } sort($genres); - return [ + return new MangaPage([ 'id' => $item['id'], 'title' => $item['canonicalTitle'], 'en_title' => $item['titles']['en'], @@ -56,7 +58,7 @@ final class MangaTransformer extends AbstractTransformer { 'synopsis' => $item['synopsis'], 'url' => "https://kitsu.io/manga/{$item['slug']}", 'genres' => $genres, - ]; + ]); } private function count(int $value = NULL) diff --git a/src/API/MAL/Model.php b/src/API/MAL/Model.php index b8160e00..0f245d81 100644 --- a/src/API/MAL/Model.php +++ b/src/API/MAL/Model.php @@ -24,7 +24,7 @@ use Aviat\AnimeClient\API\MAL\{ }; use Aviat\AnimeClient\API\XML; use Aviat\AnimeClient\API\Mapping\{AnimeWatchingStatus, MangaReadingStatus}; -use Aviat\AnimeClient\Types\{Anime, AnimeFormItem}; +use Aviat\AnimeClient\Types\{Anime, FormItem}; use Aviat\Ion\Di\ContainerAware; /** @@ -148,11 +148,11 @@ final class Model { /** * Update a list item * - * @param AnimeFormItem $data + * @param FormItem $data * @param string $type "anime" or "manga" * @return Request */ - public function updateListItem(AnimeFormItem $data, string $type = 'anime'): Request + public function updateListItem(FormItem $data, string $type = 'anime'): Request { $updateData = []; diff --git a/src/Model/Anime.php b/src/Model/Anime.php index 3c943bb1..34a5b366 100644 --- a/src/Model/Anime.php +++ b/src/Model/Anime.php @@ -29,7 +29,7 @@ use Aviat\Ion\Json; /** * Model for handling requests dealing with the anime list */ -final class Anime extends API { +class Anime extends API { /** * Model for making requests to Kitsu API * diff --git a/src/Model/Manga.php b/src/Model/Manga.php index 85c050c7..2cee710a 100644 --- a/src/Model/Manga.php +++ b/src/Model/Manga.php @@ -21,14 +21,18 @@ use Aviat\AnimeClient\API\{ Mapping\MangaReadingStatus, ParallelAPIRequest }; +use Aviat\AnimeClient\Types\{ + MangaFormItem, + MangaListItem, + MangaPage +}; use Aviat\Ion\Di\ContainerInterface; use Aviat\Ion\Json; /** * Model for handling requests dealing with the manga list */ -final class Manga extends API -{ +class Manga extends API { /** * Model for making requests to Kitsu API * @var \Aviat\AnimeClient\API\Kitsu\Model @@ -71,17 +75,18 @@ final class Manga extends API } $APIstatus = MangaReadingStatus::TITLE_TO_KITSU[$status]; - $data = $this->kitsuModel->getMangaList($APIstatus); - return $this->mapByStatus($data)[$status]; + $data = + $this->mapByStatus($this->kitsuModel->getMangaList($APIstatus)); + return $data[$status]; } /** * Get the details of a manga * * @param string $manga_id - * @return array + * @return MangaPage */ - public function getManga($manga_id): array + public function getManga($manga_id): MangaPage { return $this->kitsuModel->getManga($manga_id); } @@ -90,9 +95,9 @@ final class Manga extends API * Get anime by its kitsu id * * @param string $animeId - * @return array + * @return MangaPage */ - public function getMangaById(string $animeId): array + public function getMangaById(string $animeId): MangaPage { return $this->kitsuModel->getMangaById($animeId); } @@ -102,9 +107,9 @@ final class Manga extends API * for editing/updating that item * * @param string $itemId - * @return array + * @return MangaListItem */ - public function getLibraryItem(string $itemId): array + public function getLibraryItem(string $itemId): MangaListItem { return $this->kitsuModel->getListItem($itemId); } @@ -141,10 +146,10 @@ final class Manga extends API /** * Update a list entry * - * @param array $data + * @param MangaFormItem $data * @return array */ - public function updateLibraryItem(array $data): array + public function updateLibraryItem(MangaFormItem $data): array { $requester = new ParallelAPIRequest(); @@ -221,7 +226,10 @@ final class Manga extends API $output[$key][] = $entry; } - foreach ($output as &$val) { + unset($entry); + + foreach ($output as &$val) + { $this->sortByName($val, 'manga'); } diff --git a/src/Types/AbstractType.php b/src/Types/AbstractType.php index bbb3ed41..664f3fde 100644 --- a/src/Types/AbstractType.php +++ b/src/Types/AbstractType.php @@ -20,6 +20,17 @@ use ArrayAccess; use LogicException; abstract class AbstractType implements ArrayAccess { + /** + * Populate values for unserializing data + * + * @param $properties + * @return mixed + */ + public static function __set_state($properties) + { + return new static($properties); + } + /** * Sets the properties by using the constructor * diff --git a/src/Types/AnimeFormItem.php b/src/Types/AnimeFormItem.php index af02e058..69a72881 100644 --- a/src/Types/AnimeFormItem.php +++ b/src/Types/AnimeFormItem.php @@ -19,8 +19,4 @@ namespace Aviat\AnimeClient\Types; /** * Type representing an Anime object for display */ -final class AnimeFormItem extends AbstractType { - public $data; - public $id; - public $mal_id; -} +final class AnimeFormItem extends FormItem { } diff --git a/src/Types/AnimeFormItemData.php b/src/Types/AnimeFormItemData.php index 88eb2a13..3befff10 100644 --- a/src/Types/AnimeFormItemData.php +++ b/src/Types/AnimeFormItemData.php @@ -19,12 +19,4 @@ namespace Aviat\AnimeClient\Types; /** * Type representing an Anime object for display */ -final class AnimeFormItemData extends AbstractType { - public $notes; - public $private; - public $progress; - public $rating; - public $reconsumeCount; - public $reconsuming; - public $status; -} +final class AnimeFormItemData extends FormItemData {} diff --git a/src/Types/FormItem.php b/src/Types/FormItem.php new file mode 100644 index 00000000..084a1578 --- /dev/null +++ b/src/Types/FormItem.php @@ -0,0 +1,27 @@ + + * @copyright 2015 - 2018 Timothy J. Warren + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @version 4.0 + * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient + */ + +namespace Aviat\AnimeClient\Types; + +/** + * Type representing an Anime object for display + */ +abstract class FormItem extends AbstractType { + public $id; + public $mal_id; + public $data; +} + diff --git a/src/Types/FormItemData.php b/src/Types/FormItemData.php new file mode 100644 index 00000000..1539733e --- /dev/null +++ b/src/Types/FormItemData.php @@ -0,0 +1,30 @@ + + * @copyright 2015 - 2018 Timothy J. Warren + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @version 4.0 + * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient + */ + +namespace Aviat\AnimeClient\Types; + +/** + * Type representing an Anime object for display + */ +abstract class FormItemData extends AbstractType { + public $notes; + public $private; + public $progress; + public $rating; + public $reconsumeCount; + public $reconsuming; + public $status; +} diff --git a/src/Types/MangaFormItem.php b/src/Types/MangaFormItem.php new file mode 100644 index 00000000..ecc0dcb9 --- /dev/null +++ b/src/Types/MangaFormItem.php @@ -0,0 +1,23 @@ + + * @copyright 2015 - 2018 Timothy J. Warren + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @version 4.0 + * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient + */ + +namespace Aviat\AnimeClient\Types; + +/** + * Form data for updating a Manga List item + */ +final class MangaFormItem extends FormItem { } + diff --git a/src/Types/MangaFormItemData.php b/src/Types/MangaFormItemData.php new file mode 100644 index 00000000..64c9632d --- /dev/null +++ b/src/Types/MangaFormItemData.php @@ -0,0 +1,19 @@ + + * @copyright 2015 - 2018 Timothy J. Warren + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @version 4.0 + * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient + */ + +namespace Aviat\AnimeClient\Types; + +final class MangaFormItemData extends FormItemData {} diff --git a/src/Types/MangaListItem.php b/src/Types/MangaListItem.php new file mode 100644 index 00000000..2da37135 --- /dev/null +++ b/src/Types/MangaListItem.php @@ -0,0 +1,40 @@ + + * @copyright 2015 - 2018 Timothy J. Warren + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @version 4.0 + * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient + */ + +namespace Aviat\AnimeClient\Types; + +/** + * Type representing an Anime object for display + */ +final class MangaListItem extends AbstractType { + public $id; + public $mal_id; + public $chapters = [ + 'read' => 0, + 'total' => 0, + ]; + public $volumes = [ + 'read' => '-', + 'total' => 0, + ]; + public $manga; + public $reading_status; + public $notes; + public $rereading; + public $reread; + public $user_rating; +} + diff --git a/src/Types/MangaListItemDetail.php b/src/Types/MangaListItemDetail.php new file mode 100644 index 00000000..163901a6 --- /dev/null +++ b/src/Types/MangaListItemDetail.php @@ -0,0 +1,31 @@ + + * @copyright 2015 - 2018 Timothy J. Warren + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @version 4.0 + * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient + */ + +namespace Aviat\AnimeClient\Types; + +/** + * Type representing the manga represented by the list item + */ +final class MangaListItemDetail extends AbstractType { + public $genres; + public $id; + public $image; + public $slug; + public $title; + public $titles; + public $type; + public $url; +} diff --git a/src/Types/MangaPage.php b/src/Types/MangaPage.php new file mode 100644 index 00000000..5734d1a5 --- /dev/null +++ b/src/Types/MangaPage.php @@ -0,0 +1,35 @@ + + * @copyright 2015 - 2018 Timothy J. Warren + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @version 4.0 + * @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient + */ + +namespace Aviat\AnimeClient\Types; + +/** + * Type representing an Anime object for display + */ +final class MangaPage extends AbstractType { + public $chapter_count; + public $cover_image; + public $en_title; + public $genres; + public $id; + public $included; + public $jp_title; + public $manga_type; + public $synopsis; + public $title; + public $url; + public $volume_count; +} diff --git a/tests/API/Kitsu/Transformer/MangaListTransformerTest.php b/tests/API/Kitsu/Transformer/MangaListTransformerTest.php index b68db9d7..8ad6b632 100644 --- a/tests/API/Kitsu/Transformer/MangaListTransformerTest.php +++ b/tests/API/Kitsu/Transformer/MangaListTransformerTest.php @@ -19,6 +19,10 @@ namespace Aviat\AnimeClient\Tests\API\Kitsu\Transformer; use Aviat\AnimeClient\API\JsonAPI; use Aviat\AnimeClient\API\Kitsu\Transformer\MangaListTransformer; use Aviat\AnimeClient\Tests\AnimeClientTestCase; +use Aviat\AnimeClient\Types\{ + MangaFormItem, + MangaFormItemData, +}; use Aviat\Ion\Json; class MangaListTransformerTest extends AnimeClientTestCase { @@ -82,18 +86,18 @@ class MangaListTransformerTest extends AnimeClientTestCase { ]; $actual = $this->transformer->untransform($input); - $expected = [ + $expected = new MangaFormItem([ 'id' => '15084773', 'mal_id' => '26769', - 'data' => [ + 'data' => new MangaFormItemData([ 'status' => 'current', 'progress' => 67, 'reconsuming' => false, 'reconsumeCount' => 0, 'notes' => '', 'rating' => 4.5 - ] - ]; + ]) + ]); $this->assertEquals($expected, $actual); } diff --git a/tests/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testTransform__1.php b/tests/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testTransform__1.php index 0d1ac07b..d790a572 100644 --- a/tests/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testTransform__1.php +++ b/tests/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testTransform__1.php @@ -1,46 +1,53 @@ - '15839442', - 'mal_id' => '33206', - 'episodes' => + '15839442', + 'mal_id' => '33206', + 'episodes' => array ( 'watched' => '-', 'total' => '-', 'length' => NULL, ), - 'airing' => + 'airing' => array ( 'status' => 'Currently Airing', 'started' => '2017-01-12', 'ended' => NULL, ), - 'anime' => - array ( - 'id' => '12243', - 'age_rating' => NULL, - 'title' => 'Kobayashi-san Chi no Maid Dragon', - 'titles' => - array ( - 0 => 'Kobayashi-san Chi no Maid Dragon', - 1 => 'Miss Kobayashi\'s Dragon Maid', - 2 => '小林さんちのメイドラゴン', - ), - 'slug' => 'kobayashi-san-chi-no-maid-dragon', - 'type' => 'TV', - 'image' => 'https://media.kitsu.io/anime/poster_images/12243/small.jpg?1481144116', - 'genres' => + 'anime' => + Aviat\AnimeClient\Types\Anime::__set_state(array( + 'age_rating' => NULL, + 'age_rating_guide' => NULL, + 'cover_image' => 'https://media.kitsu.io/anime/poster_images/12243/small.jpg?1481144116', + 'episode_count' => NULL, + 'episode_length' => NULL, + 'genres' => array ( 0 => 'Comedy', 1 => 'Fantasy', 2 => 'Slice of Life', ), - 'streaming_links' => + 'id' => '12243', + 'included' => NULL, + 'show_type' => 'TV', + 'slug' => 'kobayashi-san-chi-no-maid-dragon', + 'status' => NULL, + 'streaming_links' => array ( ), - ), - 'watching_status' => 'current', - 'notes' => NULL, - 'rewatching' => false, - 'rewatched' => 0, - 'user_rating' => '-', - 'private' => false, -); + 'synopsis' => NULL, + 'title' => 'Kobayashi-san Chi no Maid Dragon', + 'titles' => + array ( + 0 => 'Miss Kobayashi\'s Dragon Maid', + 1 => '小林さんちのメイドラゴン', + ), + 'trailer_id' => NULL, + 'url' => NULL, + )), + 'watching_status' => 'current', + 'notes' => NULL, + 'rewatching' => false, + 'rewatched' => 0, + 'user_rating' => '-', + 'private' => false, +)); diff --git a/tests/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set #0__1.php b/tests/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set #0__1.php index 2db06bc8..eef4044d 100644 --- a/tests/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set #0__1.php +++ b/tests/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set #0__1.php @@ -1,14 +1,14 @@ - 14047981, - 'mal_id' => NULL, - 'data' => - array ( - 'status' => 'current', - 'reconsuming' => false, - 'reconsumeCount' => 0, - 'notes' => 'Very formulaic.', - 'progress' => 38, - 'private' => false, - 'rating' => 4, - ), -); + 14047981, + 'mal_id' => NULL, + 'data' => + Aviat\AnimeClient\Types\AnimeFormItemData::__set_state(array( + 'notes' => 'Very formulaic.', + 'private' => false, + 'progress' => 38, + 'rating' => 4, + 'reconsumeCount' => 0, + 'reconsuming' => false, + 'status' => 'current', + )), +)); diff --git a/tests/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set #1__1.php b/tests/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set #1__1.php index de278585..05b25d9f 100644 --- a/tests/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set #1__1.php +++ b/tests/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set #1__1.php @@ -1,14 +1,14 @@ - 14047981, - 'mal_id' => '12345', - 'data' => - array ( - 'status' => 'current', - 'reconsuming' => true, - 'reconsumeCount' => 0, - 'notes' => 'Very formulaic.', - 'progress' => 38, - 'private' => true, - 'rating' => 4, - ), -); + 14047981, + 'mal_id' => '12345', + 'data' => + Aviat\AnimeClient\Types\AnimeFormItemData::__set_state(array( + 'notes' => 'Very formulaic.', + 'private' => true, + 'progress' => 38, + 'rating' => 4, + 'reconsumeCount' => 0, + 'reconsuming' => true, + 'status' => 'current', + )), +)); diff --git a/tests/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set #2__1.php b/tests/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set #2__1.php index 79fc5db2..5da554fb 100644 --- a/tests/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set #2__1.php +++ b/tests/API/Kitsu/Transformer/__snapshots__/AnimeListTransformerTest__testUntransform with data set #2__1.php @@ -1,13 +1,14 @@ - 14047983, - 'mal_id' => '12347', - 'data' => - array ( - 'status' => 'current', - 'reconsuming' => true, - 'reconsumeCount' => 0, - 'notes' => '', - 'progress' => 12, - 'private' => true, - ), -); + 14047983, + 'mal_id' => '12347', + 'data' => + Aviat\AnimeClient\Types\AnimeFormItemData::__set_state(array( + 'notes' => '', + 'private' => true, + 'progress' => 12, + 'rating' => NULL, + 'reconsumeCount' => 0, + 'reconsuming' => true, + 'status' => 'current', + )), +)); diff --git a/tests/API/Kitsu/Transformer/__snapshots__/AnimeTransformerTest__testTransform__1.php b/tests/API/Kitsu/Transformer/__snapshots__/AnimeTransformerTest__testTransform__1.php index b6f6582c..788c598b 100644 --- a/tests/API/Kitsu/Transformer/__snapshots__/AnimeTransformerTest__testTransform__1.php +++ b/tests/API/Kitsu/Transformer/__snapshots__/AnimeTransformerTest__testTransform__1.php @@ -1,17 +1,18 @@ - 'R', - 'age_rating_guide' => 'Violence, Profanity', - 'cover_image' => 'https://media.kitsu.io/anime/poster_images/7442/small.jpg?1418580054', - 'episode_count' => 25, - 'episode_length' => 24, - 'genres' => + 'R', + 'age_rating_guide' => 'Violence, Profanity', + 'cover_image' => 'https://media.kitsu.io/anime/poster_images/7442/small.jpg?1418580054', + 'episode_count' => 25, + 'episode_length' => 24, + 'genres' => array ( ), - 'id' => 32344, - 'show_type' => 'TV', - 'slug' => 'attack-on-titan', - 'status' => 'Finished Airing', - 'streaming_links' => + 'id' => 32344, + 'included' => NULL, + 'show_type' => 'TV', + 'slug' => 'attack-on-titan', + 'status' => 'Finished Airing', + 'streaming_links' => array ( 0 => array ( @@ -86,16 +87,15 @@ ), ), ), - '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. + '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. (Source: ANN)', - 'title' => 'Attack on Titan', - 'titles' => + 'title' => 'Attack on Titan', + 'titles' => array ( - 0 => 'Attack on Titan', - 1 => 'Shingeki no Kyojin', - 2 => '進撃の巨人', + 0 => 'Shingeki no Kyojin', + 1 => '進撃の巨人', ), - 'trailer_id' => 'n4Nj6Y_SNYI', - 'url' => 'https://kitsu.io/anime/attack-on-titan', -); + 'trailer_id' => 'n4Nj6Y_SNYI', + 'url' => 'https://kitsu.io/anime/attack-on-titan', +)); diff --git a/tests/API/Kitsu/Transformer/__snapshots__/MangaListTransformerTest__testTransform__1.php b/tests/API/Kitsu/Transformer/__snapshots__/MangaListTransformerTest__testTransform__1.php index 49334993..1757e57c 100644 --- a/tests/API/Kitsu/Transformer/__snapshots__/MangaListTransformerTest__testTransform__1.php +++ b/tests/API/Kitsu/Transformer/__snapshots__/MangaListTransformerTest__testTransform__1.php @@ -1,31 +1,21 @@ - array ( - 'id' => '15084773', - 'mal_id' => '26769', - 'chapters' => + Aviat\AnimeClient\Types\MangaListItem::__set_state(array( + 'id' => '15084773', + 'mal_id' => '26769', + 'chapters' => array ( 'read' => 67, 'total' => '-', ), - 'volumes' => + 'volumes' => array ( 'read' => '-', 'total' => '-', ), - 'manga' => - array ( - 'id' => '20286', - 'titles' => - array ( - 0 => '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' => + 'manga' => + Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array( + 'genres' => array ( 0 => 'Comedy', 1 => 'Romance', @@ -33,40 +23,39 @@ 3 => 'Slice of Life', 4 => 'Thriller', ), - ), - 'reading_status' => 'current', - 'notes' => '', - 'rereading' => false, - 'reread' => 0, - 'user_rating' => 9.0, - ), + 'id' => '20286', + 'image' => 'https://media.kitsu.io/manga/poster_images/20286/small.jpg?1434293999', + 'slug' => 'bokura-wa-minna-kawaisou', + 'title' => 'Bokura wa Minna Kawaisou', + 'titles' => + array ( + ), + 'type' => 'manga', + 'url' => 'https://kitsu.io/manga/bokura-wa-minna-kawaisou', + )), + 'reading_status' => 'current', + 'notes' => '', + 'rereading' => false, + 'reread' => 0, + 'user_rating' => 9.0, + )), 1 => - array ( - 'id' => '15085607', - 'mal_id' => '16', - 'chapters' => + Aviat\AnimeClient\Types\MangaListItem::__set_state(array( + 'id' => '15085607', + 'mal_id' => '16', + 'chapters' => array ( 'read' => 17, 'total' => 120, ), - 'volumes' => + 'volumes' => array ( 'read' => '-', 'total' => 14, ), - 'manga' => - array ( - 'id' => '47', - 'titles' => - array ( - 0 => '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' => + 'manga' => + Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array( + 'genres' => array ( 0 => 'Comedy', 1 => 'Ecchi', @@ -74,41 +63,39 @@ 3 => 'Romance', 4 => 'Sports', ), - ), - 'reading_status' => 'current', - 'notes' => '', - 'rereading' => false, - 'reread' => 0, - 'user_rating' => 7.0, - ), + 'id' => '47', + 'image' => 'https://media.kitsu.io/manga/poster_images/47/small.jpg?1434249493', + 'slug' => 'love-hina', + 'title' => 'Love Hina', + 'titles' => + array ( + ), + 'type' => 'manga', + 'url' => 'https://kitsu.io/manga/love-hina', + )), + 'reading_status' => 'current', + 'notes' => '', + 'rereading' => false, + 'reread' => 0, + 'user_rating' => 7.0, + )), 2 => - array ( - 'id' => '15084529', - 'mal_id' => '35003', - 'chapters' => + Aviat\AnimeClient\Types\MangaListItem::__set_state(array( + 'id' => '15084529', + 'mal_id' => '35003', + 'chapters' => array ( 'read' => 16, 'total' => '-', ), - 'volumes' => + 'volumes' => array ( 'read' => '-', 'total' => '-', ), - 'manga' => - array ( - 'id' => '11777', - 'titles' => - array ( - 0 => 'Yamada-kun to 7-nin no Majo', - 1 => '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' => + 'manga' => + Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array( + 'genres' => array ( 0 => 'Comedy', 1 => 'Ecchi', @@ -118,89 +105,97 @@ 5 => 'Sports', 6 => 'Supernatural', ), - ), - 'reading_status' => 'current', - 'notes' => '', - 'rereading' => false, - 'reread' => 0, - 'user_rating' => 9.0, - ), + 'id' => '11777', + 'image' => 'https://media.kitsu.io/manga/poster_images/11777/small.jpg?1438784325', + 'slug' => 'yamada-kun-to-7-nin-no-majo', + 'title' => 'Yamada-kun to 7-nin no Majo', + 'titles' => + array ( + 0 => 'Yamada-kun and the Seven Witches', + ), + 'type' => 'manga', + 'url' => 'https://kitsu.io/manga/yamada-kun-to-7-nin-no-majo', + )), + 'reading_status' => 'current', + 'notes' => '', + 'rereading' => false, + 'reread' => 0, + 'user_rating' => 9.0, + )), 3 => - array ( - 'id' => '15312827', - 'mal_id' => '78523', - 'chapters' => + Aviat\AnimeClient\Types\MangaListItem::__set_state(array( + 'id' => '15312827', + 'mal_id' => '78523', + 'chapters' => array ( 'read' => 68, 'total' => '-', ), - 'volumes' => + 'volumes' => array ( 'read' => '-', 'total' => '-', ), - 'manga' => - array ( - 'id' => '27175', - 'titles' => - array ( - 0 => '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' => + 'manga' => + Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array( + 'genres' => array ( 0 => 'Romance', 1 => 'School', 2 => 'Slice of Life', ), - ), - 'reading_status' => 'current', - 'notes' => '', - 'rereading' => false, - 'reread' => 0, - 'user_rating' => '-', - ), + 'id' => '27175', + 'image' => 'https://media.kitsu.io/manga/poster_images/27175/small.jpg?1464379411', + 'slug' => 'relife', + 'title' => 'ReLIFE', + 'titles' => + array ( + ), + 'type' => 'manga', + 'url' => 'https://kitsu.io/manga/relife', + )), + 'reading_status' => 'current', + 'notes' => '', + 'rereading' => false, + 'reread' => 0, + 'user_rating' => '-', + )), 4 => - array ( - 'id' => '15084769', - 'mal_id' => '60815', - 'chapters' => + Aviat\AnimeClient\Types\MangaListItem::__set_state(array( + 'id' => '15084769', + 'mal_id' => '60815', + 'chapters' => array ( 'read' => 43, 'total' => '-', ), - 'volumes' => + 'volumes' => array ( 'read' => '-', 'total' => '-', ), - 'manga' => - array ( - 'id' => '25491', - 'titles' => - array ( - 0 => 'Joshikausei', - ), - 'alternate_title' => NULL, - 'slug' => 'joshikausei', - 'url' => 'https://kitsu.io/manga/joshikausei', - 'type' => 'manga', - 'image' => 'https://media.kitsu.io/manga/poster_images/25491/small.jpg?1434305043', - 'genres' => + 'manga' => + Aviat\AnimeClient\Types\MangaListItemDetail::__set_state(array( + 'genres' => array ( 0 => 'Comedy', 1 => 'School', 2 => 'Slice of Life', ), - ), - 'reading_status' => 'current', - 'notes' => '', - 'rereading' => false, - 'reread' => 0, - 'user_rating' => 8.0, - ), + 'id' => '25491', + 'image' => 'https://media.kitsu.io/manga/poster_images/25491/small.jpg?1434305043', + 'slug' => 'joshikausei', + 'title' => 'Joshikausei', + 'titles' => + array ( + ), + 'type' => 'manga', + 'url' => 'https://kitsu.io/manga/joshikausei', + )), + 'reading_status' => 'current', + 'notes' => '', + 'rereading' => false, + 'reread' => 0, + 'user_rating' => 8.0, + )), ); diff --git a/tests/API/Kitsu/Transformer/__snapshots__/MangaTransformerTest__testTransform__1.php b/tests/API/Kitsu/Transformer/__snapshots__/MangaTransformerTest__testTransform__1.php index 9699bafe..ec814886 100644 --- a/tests/API/Kitsu/Transformer/__snapshots__/MangaTransformerTest__testTransform__1.php +++ b/tests/API/Kitsu/Transformer/__snapshots__/MangaTransformerTest__testTransform__1.php @@ -1,21 +1,17 @@ - '20286', - '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! -(Source: Kirei Cake)', - 'url' => 'https://kitsu.io/manga/bokura-wa-minna-kawaisou', - 'genres' => + '-', + 'cover_image' => 'https://media.kitsu.io/manga/poster_images/20286/small.jpg?1434293999', + 'en_title' => NULL, + 'genres' => array ( - 0 => 'Comedy', - 1 => 'Romance', - 2 => 'School', - 3 => 'Slice of Life', - 4 => 'Thriller', ), -); + 'id' => '20286', + 'included' => NULL, + 'jp_title' => 'Bokura wa Minna Kawaisou', + 'manga_type' => 'manga', + '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! +(Source: Kirei Cake)', + 'title' => 'Bokura wa Minna Kawaisou', + 'url' => 'https://kitsu.io/manga/bokura-wa-minna-kawaisou', + 'volume_count' => '-', +));