2022-12-11 00:08:59 +00:00
|
|
|
<?php /** @noinspection PhpIllegalPsrClassPathInspection */
|
2023-02-12 15:14:11 +00:00
|
|
|
namespace Tests\Integration;
|
2023-02-02 23:37:37 +00:00
|
|
|
use App\Club;
|
|
|
|
use App\Testing\ScoutFlush;
|
|
|
|
use App\Testing\SyntheticMongoDbTransaction;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Tests\TestCase;
|
2019-05-13 08:52:55 +05:00
|
|
|
|
|
|
|
class ClubControllerTest extends TestCase
|
|
|
|
{
|
2023-02-02 23:37:37 +00:00
|
|
|
use SyntheticMongoDbTransaction;
|
|
|
|
use ScoutFlush;
|
|
|
|
|
2019-05-13 08:52:55 +05:00
|
|
|
public function testMain()
|
|
|
|
{
|
2023-02-02 23:37:37 +00:00
|
|
|
Club::factory()->createOne([
|
|
|
|
"mal_id" => 1
|
|
|
|
]);
|
2023-02-05 00:55:11 +00:00
|
|
|
$this->get('/v4/clubs/1')
|
|
|
|
->seeStatusCode(200)
|
2021-01-14 07:29:28 +05:00
|
|
|
->seeJsonStructure(['data'=>[
|
2019-05-13 08:52:55 +05:00
|
|
|
'mal_id',
|
2022-06-07 15:52:18 +02:00
|
|
|
'name',
|
2019-05-13 08:52:55 +05:00
|
|
|
'url',
|
2022-06-07 15:52:18 +02:00
|
|
|
'images' => [
|
|
|
|
'jpg' => [
|
|
|
|
'image_url',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'members',
|
2019-05-13 08:52:55 +05:00
|
|
|
'category',
|
|
|
|
'created',
|
2022-06-07 15:52:18 +02:00
|
|
|
'access',
|
2021-01-14 07:29:28 +05:00
|
|
|
]]);
|
2019-05-13 08:52:55 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testMembers()
|
|
|
|
{
|
2023-02-02 23:37:37 +00:00
|
|
|
$dummyUsername = $this->faker->userName();
|
2023-02-05 00:55:11 +00:00
|
|
|
$document = $this->dummyResultsDocument('/v4/clubs/1/members', 'clubs', [
|
|
|
|
[
|
|
|
|
"username" => $this->faker->userName(),
|
|
|
|
"url" => "https://myanimelist.net/profile/".$dummyUsername,
|
|
|
|
"images" => [
|
|
|
|
"jpg" => [
|
|
|
|
"image_url" => "http://httpbin.org/get"
|
|
|
|
],
|
|
|
|
"webp" => [
|
|
|
|
"image_url" => "http://httpbin.org/get"
|
2023-02-02 23:37:37 +00:00
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]);
|
2023-02-05 00:55:11 +00:00
|
|
|
DB::table("clubs_members")->insert($document);
|
2022-06-07 15:52:18 +02:00
|
|
|
$this->get('/v4/clubs/1/members')
|
2019-05-13 08:52:55 +05:00
|
|
|
->seeStatusCode(200)
|
|
|
|
->seeJsonStructure([
|
2021-01-16 10:50:42 +05:00
|
|
|
'pagination' => [
|
2021-01-14 07:29:28 +05:00
|
|
|
'last_visible_page',
|
2022-06-07 15:52:18 +02:00
|
|
|
'has_next_page',
|
2021-01-14 07:29:28 +05:00
|
|
|
],
|
|
|
|
'data' => [
|
2019-05-13 08:52:55 +05:00
|
|
|
[
|
|
|
|
'username',
|
|
|
|
'url',
|
2021-01-14 07:29:28 +05:00
|
|
|
'images' => [
|
|
|
|
'jpg' => [
|
|
|
|
'image_url'
|
|
|
|
],
|
|
|
|
'webp' => [
|
|
|
|
'image_url'
|
|
|
|
]
|
|
|
|
],
|
2019-05-13 08:52:55 +05:00
|
|
|
]
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function test404()
|
|
|
|
{
|
2023-02-02 23:37:37 +00:00
|
|
|
$this->mockJikanParserWith404RespondingUpstream();
|
2021-01-14 07:29:28 +05:00
|
|
|
$this->get('/v4/clubs/1000000')
|
2019-05-13 08:52:55 +05:00
|
|
|
->seeStatusCode(404);
|
|
|
|
}
|
|
|
|
}
|