41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\GameAccount;
|
|
use App\Services\BalanceService;
|
|
use Laravel\Passport\Passport;
|
|
use Mockery\MockInterface;
|
|
use Tests\TestCase;
|
|
|
|
class LauncherAccountFeatureTest extends TestCase
|
|
{
|
|
public function test_authenticated_launcher_can_get_username_and_balance(): void
|
|
{
|
|
$account = new GameAccount;
|
|
$account->id = 7;
|
|
$account->username = 'PLAYERONE';
|
|
Passport::actingAs($account);
|
|
|
|
$this->mock(BalanceService::class, function (MockInterface $mock): void {
|
|
$mock->shouldReceive('balance')
|
|
->once()
|
|
->with(7)
|
|
->andReturn('1250.00');
|
|
});
|
|
|
|
$this->getJson('/api/launcher/account')
|
|
->assertOk()
|
|
->assertExactJson([
|
|
'username' => 'PLAYERONE',
|
|
'balance' => '1250.00',
|
|
]);
|
|
}
|
|
|
|
public function test_launcher_account_endpoint_requires_authentication(): void
|
|
{
|
|
$this->getJson('/api/launcher/account')
|
|
->assertUnauthorized();
|
|
}
|
|
}
|