mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
fixed tests
This commit is contained in:
parent
10d25cc022
commit
df854f65a6
@ -83,7 +83,9 @@ class AppServiceProvider extends ServiceProvider
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->singleton(JikanConfig::class, fn() => new JikanConfig(config("jikan")));
|
||||
$this->app->singleton(\App\Contracts\SearchAnalyticsService::class, \App\Services\DefaultSearchAnalyticsService::class);
|
||||
$this->app->singleton(\App\Contracts\SearchAnalyticsService::class,
|
||||
env("APP_ENV") !== "testing" ? \App\Services\DefaultSearchAnalyticsService::class :
|
||||
\App\Services\DummySearchAnalyticsService::class);
|
||||
$this->app->alias(JikanConfig::class, "jikan-config");
|
||||
// cache options class is used to share the request scope level cache settings
|
||||
$this->app->singleton(CacheOptions::class);
|
||||
|
14
app/Services/DummySearchAnalyticsService.php
Normal file
14
app/Services/DummySearchAnalyticsService.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Contracts\SearchAnalyticsService;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
final class DummySearchAnalyticsService implements SearchAnalyticsService
|
||||
{
|
||||
public function logSearch(string $searchTerm, int $hitsCount, Collection $hits, string $indexName): void
|
||||
{
|
||||
// noop;
|
||||
}
|
||||
}
|
@ -68,7 +68,10 @@
|
||||
"phpunit": "@php ./vendor/bin/phpunit --no-coverage",
|
||||
"phpunit-cover": "@php ./vendor/bin/phpunit",
|
||||
"test": [
|
||||
"@phpunit"
|
||||
"@phpunit --testsuite unit"
|
||||
],
|
||||
"integration-test": [
|
||||
"@phpunit --testsuite integration"
|
||||
],
|
||||
"test-cover": [
|
||||
"@phpunit-cover"
|
||||
|
@ -68,7 +68,7 @@ class AnimeFactory extends JikanMediaModelFactory
|
||||
"synopsis" => "test",
|
||||
"approved" => true,
|
||||
"background" => "test",
|
||||
"premiered" => $this->faker->randomElement(["Winter", "Spring", "Fall", "Summer"]),
|
||||
"premiered" => $this->faker->randomElement(["Winter", "Spring", "Fall", "Summer"]) . " " . $this->faker->year(),
|
||||
"broadcast" => [
|
||||
"day" => "",
|
||||
"time" => "",
|
||||
|
@ -21,6 +21,7 @@ final class ProfileFactory extends JikanModelFactory
|
||||
return [
|
||||
"mal_id" => $mal_id,
|
||||
"username" => $username,
|
||||
"internal_username" => $username,
|
||||
"url" => $url,
|
||||
"request_hash" => sprintf("request:%s:%s", "users", $this->getItemTestUrl("users", $username)),
|
||||
"images" => [
|
||||
|
@ -98,9 +98,9 @@ class MangaSearchEndpointTest extends TestCase
|
||||
public function genresParameterCombinationsProvider(): array
|
||||
{
|
||||
return [
|
||||
[["genres" => "1,2"]],
|
||||
[["genres_exclude" => "4,5", "type" => "tv"]],
|
||||
[["genres" => "1,2", "genres_exclude" => "3", "min_score" => 8, "type" => "tv", "status" => "complete", "page" => 1]],
|
||||
"?genres=1,2" => [["genres" => "1,2"]],
|
||||
"?genres_exclude=4,5&type=manga" => [["genres_exclude" => "4,5", "type" => "manga"]],
|
||||
"?genres=1,2&genres_exclude=3&min_score=8&type=manga&status=complete" => [["genres" => "1,2", "genres_exclude" => "3", "min_score" => 8, "type" => "manga", "status" => "complete", "page" => 1]],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,10 @@ class UserControllerTest extends TestCase
|
||||
|
||||
public function testUserProfile()
|
||||
{
|
||||
$username = "nekomata1037";
|
||||
Profile::factory()->createOne([
|
||||
"username" => "nekomata1037"
|
||||
"username" => $username,
|
||||
"internal_username" => $username
|
||||
]);
|
||||
$this->get('/v4/users/nekomata1037')
|
||||
->seeStatusCode(200)
|
||||
@ -46,8 +48,10 @@ class UserControllerTest extends TestCase
|
||||
|
||||
public function testUserStatistics()
|
||||
{
|
||||
$username = "nekomata1037";
|
||||
Profile::factory()->createOne([
|
||||
"username" => "nekomata1037"
|
||||
"username" => $username,
|
||||
"internal_username" => $username
|
||||
]);
|
||||
$this->get('/v4/users/nekomata1037/statistics')
|
||||
->seeStatusCode(200)
|
||||
@ -83,8 +87,10 @@ class UserControllerTest extends TestCase
|
||||
|
||||
public function testUserAbout()
|
||||
{
|
||||
$username = "nekomata1037";
|
||||
Profile::factory()->createOne([
|
||||
"username" => "nekomata1037"
|
||||
"username" => $username,
|
||||
"internal_username" => $username
|
||||
]);
|
||||
$this->get('/v4/users/nekomata1037/about')
|
||||
->seeStatusCode(200)
|
||||
@ -95,8 +101,10 @@ class UserControllerTest extends TestCase
|
||||
|
||||
public function testUserFavorites()
|
||||
{
|
||||
$username = "nekomata1037";
|
||||
Profile::factory()->createOne([
|
||||
"username" => "nekomata1037"
|
||||
"username" => $username,
|
||||
"internal_username" => $username
|
||||
]);
|
||||
$this->get('/v4/users/nekomata1037/favorites')
|
||||
->seeStatusCode(200)
|
||||
|
Loading…
x
Reference in New Issue
Block a user