diff --git a/composer.json b/composer.json index 925e8f64..43a97f41 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,9 @@ }, "autoload-dev": { "psr-4": { - "JikanTest\\": "test/JikanTest/" + "JikanTest\\": [ + "test/unit" + ] } }, "require": { diff --git a/grumphp.yml b/grumphp.yml index 31f39c39..f803d4fc 100644 --- a/grumphp.yml +++ b/grumphp.yml @@ -13,4 +13,4 @@ grumphp: - 'die' paratest: always_execute: true - phplint: ~ \ No newline at end of file + phplint: ~ diff --git a/phpunit.xml b/phpunit.xml index 5a0d5699..a9782dd1 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,13 +1,22 @@ - - - - - src - - + + - - ./test/JikanTest + + test/unit + + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a51f1cae..ed2efffa 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ - ./test/JikanTest + ./test/unit diff --git a/test/JikanTest/Helper/JStringTest.php b/test/unit/Helper/JStringTest.php similarity index 97% rename from test/JikanTest/Helper/JStringTest.php rename to test/unit/Helper/JStringTest.php index 06856ffb..841bc514 100644 --- a/test/JikanTest/Helper/JStringTest.php +++ b/test/unit/Helper/JStringTest.php @@ -1,9 +1,9 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/anime/35073/Overlord_II/characters'); $this->parser = new CharacterListItemParser( diff --git a/test/JikanTest/Parser/Character/CharacterParserTest.php b/test/unit/Parser/Character/CharacterParserTest.php similarity index 97% rename from test/JikanTest/Parser/Character/CharacterParserTest.php rename to test/unit/Parser/Character/CharacterParserTest.php index c1e64a40..8a7fbc6e 100644 --- a/test/JikanTest/Parser/Character/CharacterParserTest.php +++ b/test/unit/Parser/Character/CharacterParserTest.php @@ -1,9 +1,9 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/anime/35073/_/characters'); $this->parser = new \Jikan\Parser\Anime\StaffListItemParser( diff --git a/test/JikanTest/Parser/Character/VoiceActorParserTest.php b/test/unit/Parser/Character/VoiceActorParserTest.php similarity index 94% rename from test/JikanTest/Parser/Character/VoiceActorParserTest.php rename to test/unit/Parser/Character/VoiceActorParserTest.php index c41b3a41..55cb4b94 100644 --- a/test/JikanTest/Parser/Character/VoiceActorParserTest.php +++ b/test/unit/Parser/Character/VoiceActorParserTest.php @@ -1,9 +1,9 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/anime/genre/1'); $this->parser = new AnimeGenreParser($crawler); } diff --git a/test/JikanTest/Parser/Genre/MangaGenreParserTest.php b/test/unit/Parser/Genre/MangaGenreParserTest.php similarity index 89% rename from test/JikanTest/Parser/Genre/MangaGenreParserTest.php rename to test/unit/Parser/Genre/MangaGenreParserTest.php index efb4a5f5..f47a64eb 100644 --- a/test/JikanTest/Parser/Genre/MangaGenreParserTest.php +++ b/test/unit/Parser/Genre/MangaGenreParserTest.php @@ -1,11 +1,11 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/manga/genre/1'); $this->parser = new MangaGenreParser($crawler); } diff --git a/test/JikanTest/Parser/Magazine/MagazineParserTest.php b/test/unit/Parser/Magazine/MagazineParserTest.php similarity index 84% rename from test/JikanTest/Parser/Magazine/MagazineParserTest.php rename to test/unit/Parser/Magazine/MagazineParserTest.php index a96f3298..c784d01e 100644 --- a/test/JikanTest/Parser/Magazine/MagazineParserTest.php +++ b/test/unit/Parser/Magazine/MagazineParserTest.php @@ -1,10 +1,10 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/manga/magazine/1'); $this->parser = new MagazineParser($crawler); } diff --git a/test/JikanTest/Parser/Manga/CharactersParserTest.php b/test/unit/Parser/Manga/CharactersParserTest.php similarity index 91% rename from test/JikanTest/Parser/Manga/CharactersParserTest.php rename to test/unit/Parser/Manga/CharactersParserTest.php index 6cff8255..fe5ee21e 100644 --- a/test/JikanTest/Parser/Manga/CharactersParserTest.php +++ b/test/unit/Parser/Manga/CharactersParserTest.php @@ -1,10 +1,10 @@ parser->getDate()->format('Y-m-d H:i')); + self::assertEquals('2024-06-07 00:33', $this->parser->getDate()->format('Y-m-d H:i')); } /** diff --git a/test/JikanTest/Parser/Person/PersonParserTest.php b/test/unit/Parser/Person/PersonParserTest.php similarity index 96% rename from test/JikanTest/Parser/Person/PersonParserTest.php rename to test/unit/Parser/Person/PersonParserTest.php index dad8fef6..68b465be 100644 --- a/test/JikanTest/Parser/Person/PersonParserTest.php +++ b/test/unit/Parser/Person/PersonParserTest.php @@ -1,9 +1,9 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/manga/50145/jikan/pics'); $this->mangaParser = new PicturesPageParser($crawler); $pictures = $this->mangaParser->getModel(); @@ -63,7 +63,7 @@ public function it_gets_anime_pictures() { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/anime/22147/jikan/pics'); $this->animeParser = new PicturesPageParser($crawler); $pictures = $this->animeParser->getModel(); @@ -87,7 +87,7 @@ public function it_gets_person_pictures() { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/people/11162/jikan/pics'); $this->personParser = new PicturesPageParser($crawler); $pictures = $this->personParser->getModel(); @@ -111,7 +111,7 @@ public function it_gets_character_pictures() { parent::setUp(); - $client = new Client($this->httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/character/105591/jikan/pics'); $this->characterParser = new PicturesPageParser($crawler); $pictures = $this->characterParser->getModel(); diff --git a/test/JikanTest/Parser/Producer/ProducerParserTest.php b/test/unit/Parser/Producer/ProducerParserTest.php similarity index 90% rename from test/JikanTest/Parser/Producer/ProducerParserTest.php rename to test/unit/Parser/Producer/ProducerParserTest.php index 69d0b080..e4345519 100644 --- a/test/JikanTest/Parser/Producer/ProducerParserTest.php +++ b/test/unit/Parser/Producer/ProducerParserTest.php @@ -1,11 +1,11 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/anime/producer/1'); $this->parser = new ProducerParser($crawler); } @@ -41,7 +41,7 @@ public function it_gets_url() public function it_gets_anime() { $anime = $this->parser->getResults(); - self::assertCount(306, $anime); + self::assertCount(309, $anime); self::assertContainsOnlyInstancesOf(\Jikan\Model\Common\AnimeCard::class, $anime); } @@ -73,7 +73,7 @@ public function it_gets_established() public function it_gets_favorites() { self::assertEquals( - 4476, + 4805, $this->parser->getFavorites() ); } @@ -95,7 +95,7 @@ public function it_gets_about() public function it_gets_count() { self::assertEquals( - 306, + 309, $this->parser->getAnimeCount() ); } diff --git a/test/JikanTest/Parser/Schedule/ScheduleParserTest.php b/test/unit/Parser/Schedule/ScheduleParserTest.php similarity index 81% rename from test/JikanTest/Parser/Schedule/ScheduleParserTest.php rename to test/unit/Parser/Schedule/ScheduleParserTest.php index 67fb7278..114bdef6 100644 --- a/test/JikanTest/Parser/Schedule/ScheduleParserTest.php +++ b/test/unit/Parser/Schedule/ScheduleParserTest.php @@ -1,11 +1,11 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/anime/season/schedule'); $this->parser = new ScheduleParser($crawler); } @@ -33,7 +33,7 @@ public function it_gets_mondays() { $monday = $this->parser->getShedule('monday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $monday); - self::assertCount(9, $monday); + self::assertCount(11, $monday); } /** @@ -43,7 +43,7 @@ public function it_gets_tuesdays() { $tuesday = $this->parser->getShedule('tuesday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $tuesday); - self::assertCount(5, $tuesday); + self::assertCount(7, $tuesday); } /** @@ -53,7 +53,7 @@ public function it_gets_wednesdays() { $wednesday = $this->parser->getShedule('wednesday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $wednesday); - self::assertCount(11, $wednesday); + self::assertCount(9, $wednesday); } /** @@ -63,7 +63,7 @@ public function it_gets_thursdays() { $thursday = $this->parser->getShedule('thursday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $thursday); - self::assertCount(6, $thursday); + self::assertCount(9, $thursday); } /** @@ -73,7 +73,7 @@ public function it_gets_fridays() { $friday = $this->parser->getShedule('friday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $friday); - self::assertCount(9, $friday); + self::assertCount(14, $friday); } /** @@ -83,7 +83,7 @@ public function it_gets_saturdays() { $saturday = $this->parser->getShedule('saturday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $saturday); - self::assertCount(14, $saturday); + self::assertCount(17, $saturday); } /** @@ -93,7 +93,7 @@ public function it_gets_sundays() { $sunday = $this->parser->getShedule('sunday'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $sunday); - self::assertCount(21, $sunday); + self::assertCount(27, $sunday); } /** @@ -103,7 +103,7 @@ public function it_gets_all() { $all = $this->parser->getShedule('all'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $all); - self::assertCount(115, $all); + self::assertCount(144, $all); } /** @@ -113,7 +113,7 @@ public function it_gets_other() { $other = $this->parser->getShedule('other'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $other); - self::assertCount(10, $other); + self::assertCount(12, $other); } /** @@ -123,6 +123,6 @@ public function it_gets_unknown() { $unknown = $this->parser->getShedule('unknown'); self::assertContainsOnlyInstancesOf(AnimeCard::class, $unknown); - self::assertCount(21, $unknown); + self::assertCount(29, $unknown); } } diff --git a/test/JikanTest/Parser/Search/AnimeSearchAiringTest.php b/test/unit/Parser/Search/AnimeSearchAiringTest.php similarity index 94% rename from test/JikanTest/Parser/Search/AnimeSearchAiringTest.php rename to test/unit/Parser/Search/AnimeSearchAiringTest.php index 6e8e0467..1e46f13a 100644 --- a/test/JikanTest/Parser/Search/AnimeSearchAiringTest.php +++ b/test/unit/Parser/Search/AnimeSearchAiringTest.php @@ -1,10 +1,10 @@ anime->getMembers()); + self::assertEquals(1106026, $this->anime->getMembers()); } /** @@ -116,6 +116,6 @@ public function it_gets_the_rated() */ public function it_gets_the_score() { - self::assertEquals(8.56, $this->anime->getScore()); + self::assertEquals(8.55, $this->anime->getScore()); } } diff --git a/test/JikanTest/Parser/Search/CharacterSearchTest.php b/test/unit/Parser/Search/CharacterSearchTest.php similarity index 97% rename from test/JikanTest/Parser/Search/CharacterSearchTest.php rename to test/unit/Parser/Search/CharacterSearchTest.php index 5f00d913..21983328 100644 --- a/test/JikanTest/Parser/Search/CharacterSearchTest.php +++ b/test/unit/Parser/Search/CharacterSearchTest.php @@ -1,10 +1,10 @@ manga->getMembers(), 6906); + self::assertEquals($this->manga->getMembers(), 7680); } /** diff --git a/test/JikanTest/Parser/Search/PersonSearchTest.php b/test/unit/Parser/Search/PersonSearchTest.php similarity index 95% rename from test/JikanTest/Parser/Search/PersonSearchTest.php rename to test/unit/Parser/Search/PersonSearchTest.php index 121ef0d5..9b60e9f8 100644 --- a/test/JikanTest/Parser/Search/PersonSearchTest.php +++ b/test/unit/Parser/Search/PersonSearchTest.php @@ -1,9 +1,9 @@ parser->getYear()); + self::assertEquals(2024, $this->parser->getYear()); } /** diff --git a/test/JikanTest/Parser/SeasonList/SeasonListParserTest.php b/test/unit/Parser/SeasonList/SeasonListParserTest.php similarity index 83% rename from test/JikanTest/Parser/SeasonList/SeasonListParserTest.php rename to test/unit/Parser/SeasonList/SeasonListParserTest.php index 2ffe056a..4ef619b2 100644 --- a/test/JikanTest/Parser/SeasonList/SeasonListParserTest.php +++ b/test/unit/Parser/SeasonList/SeasonListParserTest.php @@ -1,11 +1,11 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', $request->getPath()); $this->parser = new SeasonListParser($crawler); } diff --git a/test/JikanTest/Parser/Seasonal/SeasonalAnimeParserTest.php b/test/unit/Parser/Seasonal/SeasonalAnimeParserTest.php similarity index 98% rename from test/JikanTest/Parser/Seasonal/SeasonalAnimeParserTest.php rename to test/unit/Parser/Seasonal/SeasonalAnimeParserTest.php index 50827025..dd9ff5d8 100644 --- a/test/JikanTest/Parser/Seasonal/SeasonalAnimeParserTest.php +++ b/test/unit/Parser/Seasonal/SeasonalAnimeParserTest.php @@ -1,11 +1,11 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/topanime.php'); $this->parser = new TopListItemParser( diff --git a/test/JikanTest/Parser/Top/TopCharacterParserTest.php b/test/unit/Parser/Top/TopCharacterParserTest.php similarity index 93% rename from test/JikanTest/Parser/Top/TopCharacterParserTest.php rename to test/unit/Parser/Top/TopCharacterParserTest.php index a9e192b3..e247cf71 100644 --- a/test/JikanTest/Parser/Top/TopCharacterParserTest.php +++ b/test/unit/Parser/Top/TopCharacterParserTest.php @@ -1,11 +1,11 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/character.php'); $this->parser = new TopListItemParser( diff --git a/test/JikanTest/Parser/Top/TopMangaParserTest.php b/test/unit/Parser/Top/TopMangaParserTest.php similarity index 94% rename from test/JikanTest/Parser/Top/TopMangaParserTest.php rename to test/unit/Parser/Top/TopMangaParserTest.php index c702ba4f..34206006 100644 --- a/test/JikanTest/Parser/Top/TopMangaParserTest.php +++ b/test/unit/Parser/Top/TopMangaParserTest.php @@ -1,11 +1,11 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $this->crawler = $crawler = $client->request('GET', 'https://myanimelist.net/topmanga.php'); $this->parser = new TopListItemParser( diff --git a/test/JikanTest/Parser/Top/TopPeopleParserTest.php b/test/unit/Parser/Top/TopPeopleParserTest.php similarity index 92% rename from test/JikanTest/Parser/Top/TopPeopleParserTest.php rename to test/unit/Parser/Top/TopPeopleParserTest.php index 9a3103c1..bfbeb053 100644 --- a/test/JikanTest/Parser/Top/TopPeopleParserTest.php +++ b/test/unit/Parser/Top/TopPeopleParserTest.php @@ -1,10 +1,10 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/people.php'); $this->parser = new TopListItemParser( diff --git a/test/JikanTest/Parser/UserFriend/FriendParserTest.php b/test/unit/Parser/UserFriend/FriendParserTest.php similarity index 69% rename from test/JikanTest/Parser/UserFriend/FriendParserTest.php rename to test/unit/Parser/UserFriend/FriendParserTest.php index 20b82b74..14c96e14 100644 --- a/test/JikanTest/Parser/UserFriend/FriendParserTest.php +++ b/test/unit/Parser/UserFriend/FriendParserTest.php @@ -1,23 +1,23 @@ httpClient); - $crawler = $client->request('GET', 'https://myanimelist.net/profile/morshuwarrior/friends'); + $crawler = $client->request('GET', 'https://myanimelist.net/profile/nekomata1037/friends'); $this->parser = new \Jikan\Parser\User\Friends\FriendParser( $crawler->filterXPath( '//div[contains(@class, "boxlist-container")]/div[contains(@class, "boxlist")][3]' @@ -30,7 +30,7 @@ public function setUp(): void */ public function it_gets_the_name() { - self::assertEquals('EmperorKaido', $this->parser->getName()); + self::assertEquals('sandshark', $this->parser->getName()); } /** @@ -38,7 +38,7 @@ public function it_gets_the_name() */ public function it_gets_the_url() { - self::assertEquals('https://myanimelist.net/profile/EmperorKaido', $this->parser->getUrl()); + self::assertEquals('https://myanimelist.net/profile/sandshark', $this->parser->getUrl()); } /** @@ -47,7 +47,7 @@ public function it_gets_the_url() public function it_gets_the_avatar() { self::assertEquals( - 'https://cdn.myanimelist.net/images/userimages/5229794.jpg?t=1664642400', + 'https://cdn.myanimelist.net/s/common/userimages/7168664d-c9f3-4e6c-9936-bf7b3cb25e6b_76w?s=2f3e2ce6c0bed17cb41fd558d269f311', $this->parser->getAvatar() ); } @@ -58,7 +58,7 @@ public function it_gets_the_avatar() public function it_gets_friends_since() { self::assertEquals( - '2019-11-14 12:08', + '2018-07-26 08:45', $this->parser->getFriendsSince()->format('Y-m-d H:i') ); } diff --git a/test/JikanTest/Parser/UserHistory/UserHistoryParserTest.php b/test/unit/Parser/UserHistory/UserHistoryParserTest.php similarity index 91% rename from test/JikanTest/Parser/UserHistory/UserHistoryParserTest.php rename to test/unit/Parser/UserHistory/UserHistoryParserTest.php index 391c2a7b..b268402b 100644 --- a/test/JikanTest/Parser/UserHistory/UserHistoryParserTest.php +++ b/test/unit/Parser/UserHistory/UserHistoryParserTest.php @@ -1,9 +1,9 @@ parser->getImageUrl() ); } diff --git a/test/JikanTest/Parser/Video/AnimeVideoParserTest.php b/test/unit/Parser/Video/AnimeVideoParserTest.php similarity index 86% rename from test/JikanTest/Parser/Video/AnimeVideoParserTest.php rename to test/unit/Parser/Video/AnimeVideoParserTest.php index a2d5926f..d81a02f3 100644 --- a/test/JikanTest/Parser/Video/AnimeVideoParserTest.php +++ b/test/unit/Parser/Video/AnimeVideoParserTest.php @@ -1,13 +1,13 @@ httpClient); + $client = new HttpClientWrapper($this->httpClient); $crawler = $client->request('GET', 'https://myanimelist.net/anime/1/_/video'); $this->parser = new VideosParser($crawler); } diff --git a/test/JikanTest/TestCase.php b/test/unit/TestCase.php similarity index 87% rename from test/JikanTest/TestCase.php rename to test/unit/TestCase.php index 3f096eeb..37c69cf2 100644 --- a/test/JikanTest/TestCase.php +++ b/test/unit/TestCase.php @@ -4,13 +4,20 @@ use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Contracts\HttpClient\HttpClientInterface; +/** + * + */ abstract class TestCase extends \PHPUnit\Framework\TestCase { + /** - * @var HttpClientInterface + * @var HttpClientInterface|MockHttpClient */ protected HttpClientInterface|MockHttpClient $httpClient; + /** + * @return void + */ protected function setUp(): void { parent::setUp();