2023-02-07 02:45:15 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Initialize;
|
|
|
|
|
|
|
|
use App\Initialize\InitializeMembers;
|
2023-02-23 01:11:05 +01:00
|
|
|
use App\Nami\Api\FullMemberAction;
|
2023-02-07 02:45:15 +01:00
|
|
|
use App\Setting\NamiSettings;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
2023-02-07 23:55:46 +01:00
|
|
|
use Illuminate\Support\Facades\Artisan;
|
2023-02-07 02:45:15 +01:00
|
|
|
use Tests\TestCase;
|
|
|
|
use Zoomyboy\LaravelNami\Data\MemberEntry;
|
|
|
|
use Zoomyboy\LaravelNami\Fakes\SearchFake;
|
|
|
|
|
|
|
|
class InitializeMembersTest extends TestCase
|
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
public function testItInitializesMembers(): void
|
|
|
|
{
|
|
|
|
$this->loginNami();
|
|
|
|
$api = app(NamiSettings::class)->login();
|
|
|
|
app(SearchFake::class)->fetches(1, 0, [
|
|
|
|
MemberEntry::factory()->toMember(['groupId' => 100, 'id' => 20]),
|
|
|
|
]);
|
2023-02-23 01:11:05 +01:00
|
|
|
FullMemberAction::shouldRun()->once();
|
2023-02-07 23:23:15 +01:00
|
|
|
|
|
|
|
app(InitializeMembers::class)->handle($api);
|
|
|
|
}
|
2023-02-07 23:55:46 +01:00
|
|
|
|
|
|
|
public function testFetchesMembersViaCommandLine(): void
|
|
|
|
{
|
|
|
|
$this->loginNami();
|
|
|
|
app(SearchFake::class)->fetches(1, 0, [
|
|
|
|
MemberEntry::factory()->toMember(['groupId' => 100, 'id' => 20]),
|
|
|
|
]);
|
2023-02-23 01:11:05 +01:00
|
|
|
FullMemberAction::shouldRun()->once();
|
2023-02-07 23:55:46 +01:00
|
|
|
|
|
|
|
Artisan::call('member:pull');
|
|
|
|
}
|
2023-02-07 02:45:15 +01:00
|
|
|
}
|