mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
added search by status tests
This commit is contained in:
parent
1ccda15af0
commit
aca707a508
@ -159,10 +159,10 @@ class AnimeFactory extends JikanModelFactory
|
||||
$statuses = [
|
||||
"complete" => "Finished Airing",
|
||||
"airing" => "Currently Airing",
|
||||
"upcoming" => "Upcoming"
|
||||
"upcoming" => "Not yet aired"
|
||||
];
|
||||
|
||||
$overrides["status"] = $this->faker->randomElement(array_diff(array_keys($statuses), [$additionalParams["status"]]));
|
||||
$overrides["status"] = $this->faker->randomElement(array_diff(array_keys($statuses), [strtolower($additionalParams["status"])]));
|
||||
}
|
||||
|
||||
if (($additionalParams->has("genres") && $additionalParams->has("genres_exclude")) || (
|
||||
@ -266,10 +266,10 @@ class AnimeFactory extends JikanModelFactory
|
||||
}
|
||||
|
||||
if ($additionalParams->has("status")) {
|
||||
$overrides["status"] = match ($additionalParams["status"]) {
|
||||
$overrides["status"] = match (strtolower($additionalParams["status"])) {
|
||||
"complete" => "Finished Airing",
|
||||
"airing" => "Currently Airing",
|
||||
"upcoming" => "Upcoming"
|
||||
"upcoming" => "Not yet aired"
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,18 @@ class AnimeSearchEndpointTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function statusParameterProvider(): array
|
||||
{
|
||||
return [
|
||||
[["status" => "airing"]],
|
||||
[["status" => "complete"]],
|
||||
[["status" => "upcoming"]],
|
||||
[["status" => "Airing"]],
|
||||
[["status" => "Complete"]],
|
||||
[["status" => "Upcoming"]],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
@ -265,6 +277,22 @@ class AnimeSearchEndpointTest extends TestCase
|
||||
$this->assertCount(5, $content["data"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider statusParameterProvider
|
||||
*/
|
||||
public function testSearchByStatus($params)
|
||||
{
|
||||
$this->generateFiveSpecificAndTenRandomElementsInDb($params);
|
||||
|
||||
$content = $this->getJsonResponse($params);
|
||||
|
||||
$this->seeStatusCode(200);
|
||||
$this->assertPaginationData(5);
|
||||
$this->assertIsArray($content["data"]);
|
||||
// we created 5 elements according to parameters, so we expect 5 of them.
|
||||
$this->assertCount(5, $content["data"]);
|
||||
}
|
||||
|
||||
public function testTypeSenseSearchPagination()
|
||||
{
|
||||
// this should test https://github.com/jikan-me/jikan-rest/issues/298
|
||||
|
Loading…
x
Reference in New Issue
Block a user