diff --git a/app/Http/Middleware/DatabaseResolver.php b/app/Http/Middleware/DatabaseResolver.php index b5c826d..d32a115 100644 --- a/app/Http/Middleware/DatabaseResolver.php +++ b/app/Http/Middleware/DatabaseResolver.php @@ -20,6 +20,7 @@ use Jenssegers\Mongodb\MongodbServiceProvider; use MongoDB\BSON\UTCDateTime; use MongoDB\Client; use MongoDB\Collection; +use r\Queries\Control\Http; class DatabaseResolver { @@ -118,6 +119,8 @@ class DatabaseResolver $this->insertCache($response); } + + if ( $this->queueable && $expiresAt < time()) { $queueHighPriority = \in_array($this->route, self::HIGH_PRIORITY_QUEUE); diff --git a/bootstrap/app.php b/bootstrap/app.php index 8b96282..5042b07 100755 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -117,7 +117,7 @@ if (env('SOURCE_BAD_HEALTH_FAILOVER') && env('DB_CACHING')) { /** * Load Blacklist into Redis */ -//\App\Http\Middleware\Blacklist::loadList(); causing issues on high load todo: add it as a one time init +//\App\HttpV3\Middleware\Blacklist::loadList(); causing issues on high load todo: add it as a one time init /* |-------------------------------------------------------------------------- diff --git a/composer.lock b/composer.lock index 6b9fffb..ff42ae9 100755 --- a/composer.lock +++ b/composer.lock @@ -2210,16 +2210,16 @@ }, { "name": "jikan-me/jikan", - "version": "v3.0.0-alpha.5", + "version": "v3.0.0-alpha.6", "source": { "type": "git", "url": "https://github.com/jikan-me/jikan.git", - "reference": "e1d11d663669a6e6e5d7ac536138834846764596" + "reference": "0c9075c63711ae61239ae987b1f94f7d510591f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/jikan-me/jikan/zipball/e1d11d663669a6e6e5d7ac536138834846764596", - "reference": "e1d11d663669a6e6e5d7ac536138834846764596", + "url": "https://api.github.com/repos/jikan-me/jikan/zipball/0c9075c63711ae61239ae987b1f94f7d510591f5", + "reference": "0c9075c63711ae61239ae987b1f94f7d510591f5", "shasum": "" }, "require": { @@ -2256,7 +2256,7 @@ } ], "description": "Jikan is an unofficial MyAnimeList API", - "time": "2020-05-26T18:52:10+00:00" + "time": "2020-05-29T08:55:44+00:00" }, { "name": "jms/metadata", diff --git a/routes/web.v4.php b/routes/web.v4.php index d3009da..f069761 100755 --- a/routes/web.v4.php +++ b/routes/web.v4.php @@ -63,7 +63,7 @@ $router->group( 'uses' => 'AnimeController@news' ]); - $router->get('/topics', [ + $router->get('/forum', [ 'uses' => 'AnimeController@forum' ]); @@ -114,7 +114,7 @@ $router->group( 'uses' => 'MangaController@news' ]); - $router->get('/topics', [ + $router->get('/forum', [ 'uses' => 'MangaController@forum' ]); diff --git a/tests/Http/Controllers/AnimeControllerTest.php b/tests/HttpV3/Controllers/AnimeControllerTest.php old mode 100755 new mode 100644 similarity index 100% rename from tests/Http/Controllers/AnimeControllerTest.php rename to tests/HttpV3/Controllers/AnimeControllerTest.php diff --git a/tests/Http/Controllers/CharacterControllerTest.php b/tests/HttpV3/Controllers/CharacterControllerTest.php old mode 100755 new mode 100644 similarity index 100% rename from tests/Http/Controllers/CharacterControllerTest.php rename to tests/HttpV3/Controllers/CharacterControllerTest.php diff --git a/tests/Http/Controllers/ClubControllerTest.php b/tests/HttpV3/Controllers/ClubControllerTest.php old mode 100755 new mode 100644 similarity index 100% rename from tests/Http/Controllers/ClubControllerTest.php rename to tests/HttpV3/Controllers/ClubControllerTest.php diff --git a/tests/Http/Controllers/GenreControllerTest.php b/tests/HttpV3/Controllers/GenreControllerTest.php old mode 100755 new mode 100644 similarity index 100% rename from tests/Http/Controllers/GenreControllerTest.php rename to tests/HttpV3/Controllers/GenreControllerTest.php diff --git a/tests/Http/Controllers/MagazineControllerTest.php b/tests/HttpV3/Controllers/MagazineControllerTest.php old mode 100755 new mode 100644 similarity index 100% rename from tests/Http/Controllers/MagazineControllerTest.php rename to tests/HttpV3/Controllers/MagazineControllerTest.php diff --git a/tests/Http/Controllers/MangaControllerTest.php b/tests/HttpV3/Controllers/MangaControllerTest.php old mode 100755 new mode 100644 similarity index 100% rename from tests/Http/Controllers/MangaControllerTest.php rename to tests/HttpV3/Controllers/MangaControllerTest.php diff --git a/tests/Http/Controllers/PersonControllerTest.php b/tests/HttpV3/Controllers/PersonControllerTest.php old mode 100755 new mode 100644 similarity index 100% rename from tests/Http/Controllers/PersonControllerTest.php rename to tests/HttpV3/Controllers/PersonControllerTest.php diff --git a/tests/Http/Controllers/ProducerControllerTest.php b/tests/HttpV3/Controllers/ProducerControllerTest.php old mode 100755 new mode 100644 similarity index 100% rename from tests/Http/Controllers/ProducerControllerTest.php rename to tests/HttpV3/Controllers/ProducerControllerTest.php diff --git a/tests/Http/Controllers/ScheduleControllerTest.php b/tests/HttpV3/Controllers/ScheduleControllerTest.php old mode 100755 new mode 100644 similarity index 100% rename from tests/Http/Controllers/ScheduleControllerTest.php rename to tests/HttpV3/Controllers/ScheduleControllerTest.php diff --git a/tests/Http/Controllers/SearchControllerTest.php b/tests/HttpV3/Controllers/SearchControllerTest.php old mode 100755 new mode 100644 similarity index 100% rename from tests/Http/Controllers/SearchControllerTest.php rename to tests/HttpV3/Controllers/SearchControllerTest.php diff --git a/tests/Http/Controllers/SeasonControllerTest.php b/tests/HttpV3/Controllers/SeasonControllerTest.php old mode 100755 new mode 100644 similarity index 100% rename from tests/Http/Controllers/SeasonControllerTest.php rename to tests/HttpV3/Controllers/SeasonControllerTest.php diff --git a/tests/Http/Controllers/TopControllerTest.php b/tests/HttpV3/Controllers/TopControllerTest.php old mode 100755 new mode 100644 similarity index 100% rename from tests/Http/Controllers/TopControllerTest.php rename to tests/HttpV3/Controllers/TopControllerTest.php diff --git a/tests/Http/Controllers/UserControllerTest.php b/tests/HttpV3/Controllers/UserControllerTest.php old mode 100755 new mode 100644 similarity index 100% rename from tests/Http/Controllers/UserControllerTest.php rename to tests/HttpV3/Controllers/UserControllerTest.php diff --git a/tests/HttpV4/Controllers/AnimeControllerTest.php b/tests/HttpV4/Controllers/AnimeControllerTest.php new file mode 100644 index 0000000..f85fbcd --- /dev/null +++ b/tests/HttpV4/Controllers/AnimeControllerTest.php @@ -0,0 +1,422 @@ +get('/v4/anime/1') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'mal_id', + 'url', + 'image_url', + 'trailer' => [ + 'youtube_id', + 'url', + 'embed_url', + 'images' => [ + 'default_image_url', + 'small_image_url', + 'medium_image_url', + 'large_image_url', + 'maximum_image_url', + ] + ], + 'title', + 'title_english', + 'title_japanese', + 'title_synonyms', + 'type', + 'source', + 'episodes', + 'status', + 'airing', + 'aired' => [ + 'from', + 'to', + 'prop' => [ + 'from' => [ + 'day', + 'month', + 'year' + ], + 'to' => [ + 'day', + 'month', + 'year' + ] + ], + 'string' + ], + 'duration', + 'rating', + 'score', + 'scored_by', + 'rank', + 'popularity', + 'members', + 'favorites', + 'synopsis', + 'background', + 'premiered', + 'broadcast', + 'related' => [ + [ + 'relation', + 'items' => [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ] + ], + 'producers' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'licensors' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'studios' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'genres' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'opening_themes', + 'ending_themes' + ]); + } + + public function testCharactersStaff() + { + $this->get('/v4/anime/1/characters_staff') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'characters' => [ + [ + 'mal_id', + 'url', + 'image_url', + 'name', + 'voice_actors' => [ + [ + 'mal_id', + 'name', + 'image_url', + 'language' + ] + ] + ] + ], + 'staff' => [ + [ + 'mal_id', + 'url', + 'name', + 'image_url', + 'positions' + ] + ], + ]); + } + + public function testEpisodes() + { + $this->get('/v4/anime/1/episodes') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'last_visible_page', + 'hast_next_page', + 'episodes' => [ + [ + 'episode_id', + 'title', + 'title_japanese', + 'title_romanji', + 'aired', + 'filler', + 'recap', + 'video_url', + 'forum_url' + ] + ] + ]); + + $this->get('/v4/anime/21/episodes?page=2') + ->seeStatusCode(200) + ->seeJson([ + 'last_visible_page', + 'hast_next_page', + 'episodes' => [ + [ + 'episode_id', + 'title', + 'title_japanese', + 'title_romanji', + 'aired', + 'filler', + 'recap', + 'video_url', + 'forum_url' + ] + ] + ]) + ->seeJsonContains([ + 'episodes' => [ + [ + 'mal_id' => 101, + 'title' => 'Showdown in a Heat Haze! Ace vs. the Gallant Scorpion!' + ] + ] + ]);; + } + + public function testEpisode() + { + $this->get('/v4/anime/21/episodes/1') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'mal_id', + 'url', + 'title', + 'title_japanese', + 'title_romanji', + 'duration', + 'aired', + 'aired', + 'filler', + 'recap', + 'synopsis' + ]); + } + + public function testNews() + { + $this->get('/v4/anime/1/news') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'articles' => [ + [ + 'mal_id', + 'url', + 'title', + 'date', + 'author_name', + 'author_url', + 'forum_url', + 'image_url', + 'comments', + 'excerpt' + ] + ] + ]); + } + + public function testPictures() + { + $this->get('/v4/anime/1/pictures') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'images' => [ + [ + 'large_image_url', + 'small_image_url', + ] + ] + ]); + } + + public function testVideos() + { + $this->get('/v4/anime/1/videos') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'promos' => [ + [ + 'title', + 'image_url', + 'trailer' => [ + 'youtube_id', + 'url', + 'embed_url', + 'images' => [ + 'default_image_url', + 'small_image_url', + 'medium_image_url', + 'large_image_url', + 'maximum_image_url', + ] + ], + ] + ], + 'episodes' => [ + [ + 'mal_id', + 'title', + 'episode', + 'url', + 'image_url', + ] + ] + ]); + } + + public function testStats() + { + $this->get('/v4/anime/21/statistics') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'watching', + 'completed', + 'on_hold', + 'dropped', + 'plan_to_watch', + 'total', + 'scores' => [ + 1 => [ + 'votes', + 'percentage' + ] + ] + ]); + } + + public function testForum() + { + $this->get('/v4/anime/1/forum') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'topics' => [ + [ + 'mal_id', + 'url', + 'title', + 'date', + 'author_name', + 'author_url', + 'replies', + 'last_comment' => [ + 'url', + 'author_name', + 'author_url', + 'date' + ] + ] + ] + ]); + } + + public function testMoreInfo() + { + $this->get('/v4/anime/1/moreinfo') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'moreinfo' + ]); + } + + public function testReviews() + { + $this->get('/v4/anime/1/reviews') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'reviews' => [ + [ + 'mal_id', + 'url', + 'helpful_count', + 'date', + 'scores' => [ + 'overall', + 'story', + 'animation', + 'sound', + 'character', + 'enjoyment' + ], + 'content', + 'reviewer' => [ + 'url', + 'image_url', + 'username', + 'episodes_seen' + ] + ] + ] + ]); + + $this->get('/v3/anime/1/reviews/100') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'reviews' => [] + ]); + } + + public function testRecommendations() + { + $this->get('/v4/anime/1/recommendations') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'recommendations' => [ + [ + 'mal_id', + 'url', + 'image_url', + 'recommendation_url', + 'title', + 'recommendation_count' + ] + ] + ]); + } + + public function testUserUpdates() + { + $this->get('/v4/anime/1/userupdates') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'recommendations' => [ + [ + 'username', + 'url', + 'image_url', + 'score', + 'status', + 'episodes_seen', + 'episodes_total', + 'date' + ] + ] + ]); + + $this->get('/v4/anime/1/userupdates/1000') + ->seeStatusCode(404); + } + + public function test404() + { + $this->get('/v4/anime/2') + ->seeStatusCode(404); + } +} diff --git a/tests/HttpV4/Controllers/CharacterControllerTest.php b/tests/HttpV4/Controllers/CharacterControllerTest.php new file mode 100644 index 0000000..dac6e06 --- /dev/null +++ b/tests/HttpV4/Controllers/CharacterControllerTest.php @@ -0,0 +1,67 @@ +get('/v3/character/1') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'mal_id', + 'url', + 'image_url', + 'name', + 'name_kanji', + 'nicknames', + 'about', + 'member_favorites', + 'animeography' => [ + [ + 'mal_id', + 'name', + 'url', + 'image_url', + 'role' + ] + ], + 'mangaography' => [ + [ + 'mal_id', + 'name', + 'url', + 'image_url', + 'role' + ] + ], + 'voice_actors' => [ + [ + 'mal_id', + 'name', + 'url', + 'image_url', + 'language' + ] + ] + ]); + } + + public function testPictures() + { + $this->get('/v3/character/1/pictures') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'pictures' => [ + [ + 'large', + 'small', + ] + ] + ]); + } + + public function test404() + { + $this->get('/v3/character/1000000') + ->seeStatusCode(404); + } +} diff --git a/tests/HttpV4/Controllers/ClubControllerTest.php b/tests/HttpV4/Controllers/ClubControllerTest.php new file mode 100644 index 0000000..c36eef4 --- /dev/null +++ b/tests/HttpV4/Controllers/ClubControllerTest.php @@ -0,0 +1,77 @@ +get('/v3/club/1') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'mal_id', + 'url', + 'image_url', + 'title', + 'members_count', + 'pictures_count', + 'category', + 'created', + 'type', + 'staff' => [ + [ + 'mal_id', + 'type', + 'name', + 'url', + ] + ], + 'anime_relations' => [ + [ + 'mal_id', + 'type', + 'name', + 'url', + ] + ], + 'manga_relations' => [ + [ + 'mal_id', + 'type', + 'name', + 'url', + ] + ], + 'character_relations' => [ + [ + 'mal_id', + 'type', + 'name', + 'url', + ] + ], + ]); + } + + public function testMembers() + { + $this->get('/v3/club/1/members') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'members' => [ + [ + 'username', + 'url', + 'image_url' + ] + ] + ]); + + $this->get('/v3/club/1/members/1000') + ->seeStatusCode(404); + } + + public function test404() + { + $this->get('/v3/club/1000000') + ->seeStatusCode(404); + } +} diff --git a/tests/HttpV4/Controllers/GenreControllerTest.php b/tests/HttpV4/Controllers/GenreControllerTest.php new file mode 100644 index 0000000..8931db6 --- /dev/null +++ b/tests/HttpV4/Controllers/GenreControllerTest.php @@ -0,0 +1,112 @@ +get('/v3/genre/anime/1') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'mal_url' => [ + 'mal_id', + 'type', + 'name', + 'url' + ], + 'item_count', + 'anime' => [ + [ + 'mal_id', + 'url', + 'title', + 'image_url', + 'synopsis', + 'type', + 'airing_start', + 'episodes', + 'members', + 'genres' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'source', + 'producers' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'score', + 'licensors', + 'r18', + 'kids' + ] + ] + ]); + } + + public function testMangaGenre() + { + $this->get('/v3/genre/manga/1') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'mal_url' => [ + 'mal_id', + 'type', + 'name', + 'url' + ], + 'item_count', + 'manga' => [ + [ + 'mal_id', + 'url', + 'title', + 'image_url', + 'synopsis', + 'type', + 'publishing_start', + 'volumes', + 'members', + 'genres' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'authors' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'score', + 'serialization', +// 'r18', todo ? + ] + ] + ]); + } + + public function test404() + { + $this->get('/v3/genre/anime/1/1000') + ->seeStatusCode(404); + $this->get('/v3/genre/manga/1/1000') + ->seeStatusCode(404); + $this->get('/v3/genre/anime/100') + ->seeStatusCode(404); + $this->get('/v3/genre/manga/100') + ->seeStatusCode(404); + } +} diff --git a/tests/HttpV4/Controllers/MagazineControllerTest.php b/tests/HttpV4/Controllers/MagazineControllerTest.php new file mode 100644 index 0000000..79bac7c --- /dev/null +++ b/tests/HttpV4/Controllers/MagazineControllerTest.php @@ -0,0 +1,62 @@ +get('/v3/magazine/1') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'meta' => [ + 'mal_id', + 'type', + 'name', + 'url' + ], + 'manga' => [ + [ + 'mal_id', + 'url', + 'title', + 'image_url', + 'synopsis', + 'type', + 'publishing_start', + 'volumes', + 'members', + 'genres' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'authors' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'score', + 'serialization', +// 'r18', todo ? + ] + ] + ]); + } + + public function test404() + { + $this->get('/v3/magazine/1/1000') + ->seeStatusCode(404); + $this->get('/v3/magazine/1/1000') + ->seeStatusCode(404); + $this->get('/v3/magazine/100000') + ->seeStatusCode(404); + $this->get('/v3/magazine/100000') + ->seeStatusCode(404); + } +} diff --git a/tests/HttpV4/Controllers/MangaControllerTest.php b/tests/HttpV4/Controllers/MangaControllerTest.php new file mode 100644 index 0000000..89ae68b --- /dev/null +++ b/tests/HttpV4/Controllers/MangaControllerTest.php @@ -0,0 +1,276 @@ +get('/v4/manga/1') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'mal_id', + 'url', + 'image_url', + 'title', + 'title_english', + 'title_japanese', + 'title_synonyms', + 'type', + 'volumes', + 'chapters', + 'status', + 'publishing', + 'published' => [ + 'from', + 'to', + 'prop' => [ + 'from' => [ + 'day', + 'month', + 'year' + ], + 'to' => [ + 'day', + 'month', + 'year' + ] + ], + 'string' + ], + 'score', + 'scored_by', + 'rank', + 'popularity', + 'members', + 'favorites', + 'synopsis', + 'background', + 'related' => [ + [ + 'relation', + 'items' => [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ] + ], + 'authors' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'serializations' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'genres' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ] + ]); + } + + public function testCharacters() + { + $this->get('/v4/manga/1/characters') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'characters' => [ + [ + 'mal_id', + 'url', + 'image_url', + 'name', + 'role' + ] + ] + ]); + } + + public function testNews() + { + $this->get('/v4/manga/1/news') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'articles' => [ + [ + 'url', + 'title', + 'date', + 'author_name', + 'author_url', + 'forum_url', + 'image_url', + 'comments', + 'excerpt' + ] + ] + ]); + } + + public function testPictures() + { + $this->get('/v4/manga/1/pictures') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'images' => [ + [ + 'large_image_url', + 'small_image_url', + ] + ] + ]); + } + + public function testStats() + { + $this->get('/v4/manga/1/statistics') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'reading', + 'completed', + 'on_hold', + 'dropped', + 'plan_to_read', + 'total', + 'scores' => [ + 1 => [ + 'votes', + 'percentage' + ] + ] + ]); + } + + public function testForum() + { + $this->get('/v4/manga/1/forum') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'topics' => [ + [ + 'mal_id', + 'url', + 'title', + 'date', + 'author_name', + 'author_url', + 'replies', + 'last_comment' => [ + 'url', + 'author_name', + 'author_url', + 'date' + ] + ] + ] + ]); + } + + public function testMoreInfo() + { + $this->get('/v4/manga/1/moreinfo') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'moreinfo' + ]); + } + + public function testReviews() + { + $this->get('/v4/manga/1/reviews') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'reviews' => [ + [ + 'mal_id', + 'url', + 'helpful_count', + 'date', + 'scores' => [ + 'overall', + 'story', + 'animation', + 'sound', + 'character', + 'enjoyment' + ], + 'content', + 'reviewer' => [ + 'url', + 'image_url', + 'username', + 'episodes_seen' + ] + ] + ] + ]); + + $this->get('/v4/manga/1/reviews/100') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'reviews' => [] + ]); + } + + public function testRecommendations() + { + $this->get('/v4/manga/1/recommendations') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'recommendations' => [ + [ + 'mal_id', + 'url', + 'image_url', + 'recommendation_url', + 'title', + 'recommendation_count' + ] + ] + ]); + } + + public function testUserUpdates() + { + $this->get('/v4/manga/1/userupdates') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'users' => [ + [ + 'username', + 'url', + 'image_url', + 'score', + 'status', + 'volumes_read', + 'volumes_total', + 'chapters_read', + 'chapters_total', + 'date' + ] + ] + ]); + + $this->get('/v4/manga/1/userupdates/1000') + ->seeStatusCode(404); + } + + public function test404() + { + $this->get('/v4/manga/1000000') + ->seeStatusCode(404); + } +} diff --git a/tests/HttpV4/Controllers/PersonControllerTest.php b/tests/HttpV4/Controllers/PersonControllerTest.php new file mode 100644 index 0000000..55969e0 --- /dev/null +++ b/tests/HttpV4/Controllers/PersonControllerTest.php @@ -0,0 +1,72 @@ +get('/v3/person/1') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'mal_id', + 'url', + 'image_url', + 'website_url', + 'name', + 'given_name', + 'family_name', + 'alternate_names', + 'birthday', + 'about', + 'member_favorites', + 'voice_acting_roles' => [ + [ + 'role', + 'anime' => [ + 'mal_id', + 'url', + 'image_url', + 'name' + ], + 'character' => [ + 'mal_id', + 'url', + 'image_url', + 'name' + ] + ] + ], + 'anime_staff_positions' => [ + [ + 'position', + 'anime' => [ + 'mal_id', + 'url', + 'image_url', + 'name' + ], + ] + ], + 'published_manga' => [] + ]); + } + + public function testPictures() + { + $this->get('/v3/person/1/pictures') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'pictures' => [ + [ + 'large', + 'small', + ] + ] + ]); + } + + public function test404() + { + $this->get('/v3/person/1000000') + ->seeStatusCode(404); + } +} diff --git a/tests/HttpV4/Controllers/ProducerControllerTest.php b/tests/HttpV4/Controllers/ProducerControllerTest.php new file mode 100644 index 0000000..ea7836f --- /dev/null +++ b/tests/HttpV4/Controllers/ProducerControllerTest.php @@ -0,0 +1,64 @@ +get('/v3/producer/1') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'meta' => [ + 'mal_id', + 'type', + 'name', + 'url' + ], + 'anime' => [ + [ + 'mal_id', + 'url', + 'title', + 'image_url', + 'synopsis', + 'type', + 'airing_start', + 'episodes', + 'members', + 'genres' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'source', + 'producers' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'score', + 'licensors', + 'r18', + 'kids' + ] + ] + ]); + } + + public function test404() + { + $this->get('/v3/producer/1/1000') + ->seeStatusCode(404); + $this->get('/v3/producer/1/1000') + ->seeStatusCode(404); + $this->get('/v3/producer/100000') + ->seeStatusCode(404); + $this->get('/v3/producer/100000') + ->seeStatusCode(404); + } +} diff --git a/tests/HttpV4/Controllers/ScheduleControllerTest.php b/tests/HttpV4/Controllers/ScheduleControllerTest.php new file mode 100644 index 0000000..4d31ded --- /dev/null +++ b/tests/HttpV4/Controllers/ScheduleControllerTest.php @@ -0,0 +1,59 @@ +get('/v3/schedule') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'monday' => [ + [ + 'mal_id', + 'url', + 'title', + 'synopsis', + 'type', + 'airing_start', + 'episodes', + 'members', + 'genres' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'source', + 'producers' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'score', + 'licensors', + 'r18', + 'kids' + ] + ], + 'tuesday', + 'wednesday', + 'thursday', + 'friday', + 'saturday', + 'sunday', + 'other', + 'unknown' + ]); + } + + public function test400() + { + $this->get('/v3/schedule/asdjkhas') + ->seeStatusCode(400); + } +} diff --git a/tests/HttpV4/Controllers/SearchControllerTest.php b/tests/HttpV4/Controllers/SearchControllerTest.php new file mode 100644 index 0000000..57a1c59 --- /dev/null +++ b/tests/HttpV4/Controllers/SearchControllerTest.php @@ -0,0 +1,102 @@ +get('/v3/search/anime?order_by=id&sort=asc') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'results' => [ + [ + 'mal_id', + 'url', + 'image_url', + 'title', + 'airing', + 'synopsis', + 'type', + 'episodes', + 'score', + 'start_date', + 'end_date', + 'members', + 'rated' + ] + ] + ]) + ; + } + + public function testMangaSearch() + { + $this->get('/v3/search/manga?order_by=id&sort=asc') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'results' => [ + [ + 'mal_id', + 'url', + 'image_url', + 'title', + 'publishing', + 'synopsis', + 'type', + 'chapters', + 'volumes', + 'score', + 'start_date', + 'end_date', + 'members', + ] + ] + ]) + ; + } + + public function testPeopleSearch() + { + $this->get('/v3/search/people?q=Sawano') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'results' => [ + [ + 'mal_id', + 'url', + 'image_url', + 'name', + 'alternative_names', + ] + ] + ]) + ; + } + + public function testCharacterSearch() + { + $this->get('/v3/search/character?q=Okabe,%20Rintarou') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'results' => [ + [ + 'mal_id', + 'url', + 'image_url', + 'name', + 'alternative_names', + 'anime' => [ + [ + 'mal_id', + 'type', + 'name', // todo should be `title` + 'url' + ] + ], + 'manga' => [], + ] + ], + 'last_page' + ]) + ; + } +} diff --git a/tests/HttpV4/Controllers/SeasonControllerTest.php b/tests/HttpV4/Controllers/SeasonControllerTest.php new file mode 100644 index 0000000..d63f2cb --- /dev/null +++ b/tests/HttpV4/Controllers/SeasonControllerTest.php @@ -0,0 +1,49 @@ +get('/v3/season') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'season_name', + 'season_year', + 'anime' => [ + [ + 'mal_id', + 'url', + 'title', + 'image_url', + 'synopsis', + 'type', + 'airing_start', + 'episodes', + 'members', + 'genres' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'source', + 'producers' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'score', + 'licensors', + 'r18', + 'kids', + 'continuing' + ] + ] + ]); + } +} diff --git a/tests/HttpV4/Controllers/TopControllerTest.php b/tests/HttpV4/Controllers/TopControllerTest.php new file mode 100644 index 0000000..5a431b2 --- /dev/null +++ b/tests/HttpV4/Controllers/TopControllerTest.php @@ -0,0 +1,111 @@ +get('/v3/top/anime') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'top' => [ + [ + 'mal_id', + 'rank', + 'title', + 'url', + 'image_url', + 'type', + 'start_date', + 'end_date', + 'members', + 'score', + ] + ] + ]); + } + + public function testTopManga() + { + $this->get('/v3/top/manga') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'top' => [ + [ + 'mal_id', + 'rank', + 'title', + 'url', + 'type', + 'volumes', + 'start_date', + 'end_date', + 'members', + 'score', + 'image_url', + ] + ] + ]); + } + + public function testTopPeople() + { + $this->get('/v3/top/people') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'top' => [ + [ + 'mal_id', + 'rank', + 'title', // todo should be `name` + 'url', + 'name_kanji', + 'favorites', + 'image_url', + 'birthday', + ] + ] + ]); + } + + public function testTopCharacters() + { + $this->get('/v3/top/characters') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'top' => [ + [ + 'mal_id', + 'rank', + 'title', // todo should be `name` + 'url', + 'name_kanji', + + 'animeography' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'mangaography' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'favorites', + 'image_url', + ] + ] + ]); + } + + public function test404() + { + $this->get('/v3/top/anime/999') + ->seeStatusCode(404); + } +} diff --git a/tests/HttpV4/Controllers/UserControllerTest.php b/tests/HttpV4/Controllers/UserControllerTest.php new file mode 100644 index 0000000..5e56a01 --- /dev/null +++ b/tests/HttpV4/Controllers/UserControllerTest.php @@ -0,0 +1,171 @@ +get('/v3/user/nekomata1037') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'username', + 'url', + 'image_url', + 'last_online', + 'gender', + 'birthday', + 'location', + 'joined', + 'anime_stats' => [ + 'days_watched', + 'mean_score', + 'watching', + 'completed', + 'on_hold', + 'dropped', + 'plan_to_watch', + 'total_entries', + 'rewatched', + 'episodes_watched' + ], + 'manga_stats' => [ + 'days_read', + 'mean_score', + 'reading', + 'completed', + 'on_hold', + 'dropped', + 'plan_to_read', + 'total_entries', + 'reread', + 'chapters_read', + 'volumes_read' + ], + 'favorites' => [ + 'anime' => [ + [ + 'mal_id', + 'url', + 'image_url', + 'name' // todo should be `title` + ] + ], + 'manga' => [], + 'characters' => [ + [ + 'mal_id', + 'url', + 'image_url', + 'name' + ] + ], + 'people' => [ + [ + 'mal_id', + 'url', + 'image_url', + 'name' + ] + ], + ], + 'about' + ]); + } + + public function testUserHistory() + { + $this->get('/v3/user/nekomata1037/history') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'history' => [ + [ + 'meta' => [ + 'mal_id', + 'type', + 'name', + 'url' + ], + 'increment', + 'date' + ] + ] + ]); + } + + public function testUserFriends() + { + $this->get('/v3/user/nekomata1037/friends') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'friends' => [ + [ + 'url', + 'username', + 'image_url', + 'last_online', + 'friends_since' + ] + ] + ]); + } + + public function testUserAnimeList() + { + $this->get('/v3/user/nekomata1037/animelist?order_by=last_updated&sort=descending') + ->seeStatusCode(200) + ->seeJsonStructure([ + 'anime' => [ + [ + 'mal_id', + 'title', + 'video_url', + 'url', + 'image_url', + 'type', + 'watching_status', + 'score', + 'watched_episodes', + 'total_episodes', + 'airing_status', + 'season_name', + 'season_year', + 'has_episode_video', + 'has_promo_video', + 'has_video', + 'is_rewatching', + 'tags', + 'rating', + 'start_date', + 'end_date', + 'watch_start_date', + 'watch_end_date', + 'days', + 'storage', + 'priority', + 'added_to_list', + 'studios' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + 'licensors' => [ + [ + 'mal_id', + 'type', + 'name', + 'url' + ] + ], + ] + ] + ]); + } + + public function testUserMangaList() + { + $this->get('/v3/user/nekomata1037/mangalist?order_by=last_updated&sort=descending') + ->seeStatusCode(400); + } +}