mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
fixed tests across the board
This commit is contained in:
parent
26ca5b15d8
commit
56687ace50
@ -215,14 +215,13 @@ class AnimeSearchEndpointTest extends TestCase
|
||||
/**
|
||||
* @dataProvider emptyDateRangeProvider
|
||||
*/
|
||||
public function testSearchByEmptyDatesShouldRaiseValidationError($params)
|
||||
public function testSearchByEmptyDatesShouldNotRaiseValidationError($params)
|
||||
{
|
||||
$this->generateFiveSpecificAndTenRandomElementsInDb($params);
|
||||
|
||||
$content = $this->getJsonResponse($params);
|
||||
$this->getJsonResponse($params);
|
||||
|
||||
$this->seeStatusCode(400);
|
||||
$this->assertEquals("ValidationException", data_get($content, "type"));
|
||||
$this->seeStatusCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -196,14 +196,13 @@ class MangaSearchEndpointTest extends TestCase
|
||||
/**
|
||||
* @dataProvider emptyDateRangeProvider
|
||||
*/
|
||||
public function testSearchByEmptyDatesShouldRaiseValidationError($params)
|
||||
public function testSearchByEmptyDatesShouldNotRaiseValidationError($params)
|
||||
{
|
||||
$this->generateFiveSpecificAndTenRandomElementsInDb($params);
|
||||
|
||||
$content = $this->getJsonResponse($params);
|
||||
$this->getJsonResponse($params);
|
||||
|
||||
$this->seeStatusCode(400);
|
||||
$this->assertEquals("ValidationException", data_get($content, "type"));
|
||||
$this->seeStatusCode(200);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,17 +29,17 @@ class TopAnimeEndpointTest extends TestCase
|
||||
public function orderByFieldAndParamsData()
|
||||
{
|
||||
return [
|
||||
["rank", false, []],
|
||||
["rank", false, ["filter" => "airing"]],
|
||||
["rank", false, ["type" => "tv"]],
|
||||
["rank", false, ["type" => "movie"]],
|
||||
["rank", false, ["type" => "ova"]],
|
||||
["rank", false, ["type" => "ona"]],
|
||||
["rank", false, ["type" => "special"]],
|
||||
["rank", false, ["type" => "music"]],
|
||||
["rank", false, ["filter" => "upcoming"]],
|
||||
["members", true, ["filter" => "bypopularity"]],
|
||||
["favorites", true, ["filter" => "favorite"]]
|
||||
"empty query string" => ["score", true, []],
|
||||
"query string: ?filter=airing" => ["score", true, ["filter" => "airing"]],
|
||||
"query string: ?type=tv" => ["score", true, ["type" => "tv"]],
|
||||
"query string: ?type=movie" => ["score", true, ["type" => "movie"]],
|
||||
"query string: ?type=ova" => ["score", true, ["type" => "ova"]],
|
||||
"query string: ?type=ona" => ["score", true, ["type" => "ona"]],
|
||||
"query string: ?type=special" => ["score", true, ["type" => "special"]],
|
||||
"query string: ?type=music" => ["score", true, ["type" => "music"]],
|
||||
"query string: ?filter=upcoming" => ["members", true, ["filter" => "upcoming"]],
|
||||
"query string: ?filter=bypopularity" => ["members", true, ["filter" => "bypopularity"]],
|
||||
"query string: ?filter=favorite" => ["favorites", true, ["filter" => "favorite"]]
|
||||
];
|
||||
}
|
||||
|
||||
@ -57,10 +57,10 @@ class TopAnimeEndpointTest extends TestCase
|
||||
/*
|
||||
* Test whether the API orders the items correctly. It has to return items in similar order as MAL would
|
||||
* their search results.
|
||||
* No filters / query string parameters -> sorted by rank
|
||||
* filter = airing -> sorted by rank
|
||||
* type = tv/movie/ova/ona/special -> sorted by rank
|
||||
* filter = upcoming -> sorted by "members" attribute
|
||||
* No filters / query string parameters -> sorted by score
|
||||
* filter = airing -> sorted by score
|
||||
* type = tv/movie/ova/ona/special -> sorted by score
|
||||
* filter = upcoming -> sorted by "popularity" attribute
|
||||
* filter = favorites -> sorted by "favorites" attribute
|
||||
* filter = bypopular -> sorted by "members" attribute
|
||||
*/
|
||||
|
@ -13,6 +13,9 @@ use Jikan\Model\User\LastUpdates;
|
||||
use Jikan\Model\User\Profile as JikanProfile;
|
||||
use Jikan\Model\User\Reviews\UserReviews;
|
||||
use Jikan\MyAnimeList\MalClient;
|
||||
use Jikan\Parser\User\Profile\FavoritesParser;
|
||||
use Jikan\Parser\User\Profile\LastUpdatesParser;
|
||||
use Jikan\Parser\User\Profile\MangaStatsParser;
|
||||
use Jikan\Parser\User\Profile\UserProfileParser;
|
||||
use Jikan\Request\User\UserRecommendationsRequest;
|
||||
use Tests\TestCase;
|
||||
@ -103,8 +106,8 @@ class UserControllerTest extends TestCase
|
||||
$userProfileParser->allows()
|
||||
->getJoinDate()
|
||||
->andReturn(\DateTimeImmutable::createFromFormat(\DateTimeImmutable::RFC3339, "2000-10-01T00:00:00+00:00"));
|
||||
$animeStats = \Mockery::mock(AnimeStats::class)->makePartial();
|
||||
$animeStats->allows([
|
||||
$animeStatsParser = \Mockery::mock(\Jikan\Parser\User\Profile\AnimeStatsParser::class)->makePartial();
|
||||
$animeStatsParser->allows([
|
||||
"getDaysWatched" => 0,
|
||||
"getMeanScore" => 0,
|
||||
"getWatching" => 0,
|
||||
@ -116,11 +119,12 @@ class UserControllerTest extends TestCase
|
||||
"getRewatched" => 0,
|
||||
"getEpisodesWatched" => 0
|
||||
]);
|
||||
$animeStats = AnimeStats::fromParser($animeStatsParser);
|
||||
$userProfileParser->allows()
|
||||
->getAnimeStats()
|
||||
->andReturn($animeStats);
|
||||
$mangaStats = \Mockery::mock(MangaStats::class)->makePartial();
|
||||
$mangaStats->allows([
|
||||
$mangaStatsParser = \Mockery::mock(MangaStatsParser::class)->makePartial();
|
||||
$mangaStatsParser->allows([
|
||||
"getDaysRead" => 0,
|
||||
"getMeanScore" => 0,
|
||||
"getReading" => 0,
|
||||
@ -133,16 +137,18 @@ class UserControllerTest extends TestCase
|
||||
"getChaptersRead" => 0,
|
||||
"getVolumesRead" => 0
|
||||
]);
|
||||
$mangaStats = MangaStats::fromParser($mangaStatsParser);
|
||||
$userProfileParser->allows()
|
||||
->getMangaStats()
|
||||
->andReturn($mangaStats);
|
||||
$favorites = \Mockery::mock(\Jikan\Model\User\Favorites::class)->makePartial();
|
||||
$favorites->allows([
|
||||
$favoritesParser = \Mockery::mock(FavoritesParser::class)->makePartial();
|
||||
$favoritesParser->allows([
|
||||
"getAnime" => [],
|
||||
"getManga" => [],
|
||||
"getCharacters" => [],
|
||||
"getPeople" => []
|
||||
]);
|
||||
$favorites = \Jikan\Model\User\Favorites::fromParser($favoritesParser);
|
||||
$userProfileParser->allows()
|
||||
->getFavorites()
|
||||
->andReturn($favorites);
|
||||
@ -155,22 +161,25 @@ class UserControllerTest extends TestCase
|
||||
$userProfileParser->allows()
|
||||
->getAbout()
|
||||
->andReturn(null);
|
||||
$lastUpdates = \Mockery::mock(LastUpdates::class)->makePartial();
|
||||
$lastUpdates->allows()
|
||||
->getAnime()
|
||||
$lastUpdatesParser = \Mockery::mock(LastUpdatesParser::class)->makePartial();
|
||||
$lastUpdatesParser->allows()
|
||||
->getLastAnimeUpdates()
|
||||
->andReturn([]);
|
||||
$lastUpdates->allows()
|
||||
->getManga()
|
||||
$lastUpdatesParser->allows()
|
||||
->getLastMangaUpdates()
|
||||
->andReturn([]);
|
||||
|
||||
$lastUpdates = LastUpdates::fromParser($lastUpdatesParser);
|
||||
$userProfileParser->allows()
|
||||
->getUserLastUpdates()
|
||||
->andReturn($lastUpdates);
|
||||
|
||||
|
||||
$resultData = JikanProfile::fromParser($userProfileParser);
|
||||
/** @noinspection PhpParamsInspection */
|
||||
$jikanParser->allows()
|
||||
->getUserProfile(\Mockery::any())
|
||||
->andReturn(JikanProfile::fromParser($userProfileParser));
|
||||
->andReturn($resultData);
|
||||
|
||||
$this->app->instance('JikanParser', $jikanParser);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user