From 8d559dc664d89fdf68816433ab53fb8955b12e8f Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Tue, 10 Jan 2017 21:13:44 -0500 Subject: [PATCH] Fix unit tests --- composer.json | 4 +- public/css/base.css | 1 + public/css/base.myth.css | 1 + src/API/JsonAPI.php | 66 +++++++++++++++++++ src/API/Kitsu/Enum/AnimeShowType.php | 32 --------- src/API/Kitsu/KitsuModel.php | 21 +++--- .../Transformer/AnimeListTransformer.php | 2 +- tests/AnimeClient_TestCase.php | 4 ++ 8 files changed, 87 insertions(+), 44 deletions(-) create mode 100644 src/API/JsonAPI.php delete mode 100644 src/API/Kitsu/Enum/AnimeShowType.php diff --git a/composer.json b/composer.json index f5599fab..5381e2d1 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "aura/router": "3.*", "aura/session": "2.*", "aviat/banker": "dev-master", - "aviat/ion": "dev-master", + "aviat/ion": "1.0.*", "filp/whoops": "2.0.*", "guzzlehttp/guzzle": "6.*", "monolog/monolog": "1.*", @@ -44,6 +44,6 @@ "squizlabs/php_codesniffer": "^3.0.0@beta" }, "scripts": { - + "build:css": "cd public && npm run build && cd .." } } \ No newline at end of file diff --git a/public/css/base.css b/public/css/base.css index a2483688..13befd89 100644 --- a/public/css/base.css +++ b/public/css/base.css @@ -1226,6 +1226,7 @@ a:hover, a:active { height:100%; width:100%; vertical-align:middle; + line-height: 1.25em; } #series_list .name small { diff --git a/public/css/base.myth.css b/public/css/base.myth.css index 6e243f99..80b0902f 100644 --- a/public/css/base.myth.css +++ b/public/css/base.myth.css @@ -488,6 +488,7 @@ a:hover, a:active { height:100%; width:100%; vertical-align:middle; + line-height: 1.25em; } #series_list .name small { color: #fff; diff --git a/src/API/JsonAPI.php b/src/API/JsonAPI.php new file mode 100644 index 00000000..5e727f4f --- /dev/null +++ b/src/API/JsonAPI.php @@ -0,0 +1,66 @@ + + * @copyright 2015 - 2016 Timothy J. Warren + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @version 4.0 + * @link https://github.com/timw4mail/HummingBirdAnimeClient + */ + +namespace Aviat\AnimeClient\API; + +/** + * Class encapsulating Json API data structure for a request or response + */ +class JsonAPI { + + /** + * The full data array + * + * Basic structure is generally like so: + * @example [ + * 'id' => '12016665', + * 'type' => 'libraryEntries', + * 'links' => [ + * 'self' => 'https://kitsu.io/api/edge/library-entries/13016665' + * ], + * 'attributes' => [ + * + * ] + * ] + * + * @var array + */ + protected $data = []; + + /** + * Related objects included with the request + * + * @var array + */ + protected $included = []; + + /** + * Pagination links + * + * @var array + */ + protected $links = []; + + /** + * Parse a JsonAPI response into its components + * + * @param array $data + */ + public function parse(array $data) + { + + } +} \ No newline at end of file diff --git a/src/API/Kitsu/Enum/AnimeShowType.php b/src/API/Kitsu/Enum/AnimeShowType.php deleted file mode 100644 index 9fb37260..00000000 --- a/src/API/Kitsu/Enum/AnimeShowType.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright 2015 - 2016 Timothy J. Warren - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @version 4.0 - * @link https://github.com/timw4mail/HummingBirdAnimeClient - */ - -namespace Aviat\AnimeClient\API\Kitsu\Enum; - -use Aviat\Ion\Enum as BaseEnum; - -/** - * Type of Anime - */ -class AnimeShowType extends BaseEnum { - const TV = 'TV'; - const MOVIE = 'Movie'; - const OVA = 'OVA'; - const ONA = 'ONA'; - const SPECIAL = 'Special'; - const MUSIC = 'Music'; -} -// End of AnimeShowType.php diff --git a/src/API/Kitsu/KitsuModel.php b/src/API/Kitsu/KitsuModel.php index ea624b42..d87899fa 100644 --- a/src/API/Kitsu/KitsuModel.php +++ b/src/API/Kitsu/KitsuModel.php @@ -220,9 +220,12 @@ class KitsuModel { 'query' => [ 'filter' => [ 'text' => $query - ] - ], - 'include' => 'media' + ], + 'page' => [ + 'offset' => 0, + 'limit' => 20 + ], + ] ]; $raw = $this->getRequest($type, $options); @@ -236,6 +239,12 @@ class KitsuModel { return $raw; } + public function createListItem(array $data): bool + { + $data['user_id'] = $this->getUserIdByUsername($this->getUsername()); + return $this->listItem->create($data); + } + public function getListItem(string $listId): array { $baseData = $this->listItem->get($listId); @@ -255,12 +264,6 @@ class KitsuModel { } } - public function createListItem(array $data): bool - { - $data['user_id'] = $this->getUserIdByUsername($this->getUsername()); - return $this->listItem->create($data); - } - public function updateListItem(array $data) { try diff --git a/src/API/Kitsu/Transformer/AnimeListTransformer.php b/src/API/Kitsu/Transformer/AnimeListTransformer.php index 2143378b..7103e3ba 100644 --- a/src/API/Kitsu/Transformer/AnimeListTransformer.php +++ b/src/API/Kitsu/Transformer/AnimeListTransformer.php @@ -40,7 +40,7 @@ class AnimeListTransformer extends AbstractTransformer { $rating = (int) 2 * $item['attributes']['rating']; - $total_episodes = array_key_exists('episodeCount', $anime) + $total_episodes = array_key_exists('episodeCount', $anime) && (int) $anime['episodeCount'] !== 0 ? (int) $anime['episodeCount'] : '-'; diff --git a/tests/AnimeClient_TestCase.php b/tests/AnimeClient_TestCase.php index 2b7311bd..d565c738 100644 --- a/tests/AnimeClient_TestCase.php +++ b/tests/AnimeClient_TestCase.php @@ -51,6 +51,10 @@ class AnimeClient_TestCase extends PHPUnit_Framework_TestCase { 'asset_path' => '//localhost/assets/', 'img_cache_path' => _dir(ROOT_DIR, 'public/images'), 'data_cache_path' => _dir(TEST_DATA_DIR, 'cache'), + 'cache' => [ + 'driver' => 'null', + 'connection' => [] + ], 'database' => [ 'collection' => [ 'type' => 'sqlite',