29 lines
1.1 KiB
PHP
29 lines
1.1 KiB
PHP
|
|
<?php
|
|||
|
|
|
|||
|
|
declare(strict_types=1);
|
|||
|
|
use App\Services\External\XfetchBalanceProvider;
|
|||
|
|
use Illuminate\Support\Facades\Http;
|
|||
|
|
use Tests\TestCase;
|
|||
|
|
|
|||
|
|
uses(TestCase::class);
|
|||
|
|
|
|||
|
|
beforeEach(fn () => config()->set('services.xfetch.key', 'test-key'));
|
|||
|
|
|
|||
|
|
it('не настроено, когда ключа нет', function () {
|
|||
|
|
config()->set('services.xfetch.key', '');
|
|||
|
|
expect((new XfetchBalanceProvider)->fetch()->ok)->toBeFalse();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
it('деньги при balance_url с числом', function () {
|
|||
|
|
config()->set('services.xfetch.balance_url', 'https://xf4.ru/balance');
|
|||
|
|
Http::fake(['xf4.ru/balance' => Http::response(['balance' => 555], 200)]);
|
|||
|
|
expect((new XfetchBalanceProvider)->fetch()->balance)->toBe(555.0);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
it('жив без суммы при пустом balance_url и пинге 200', function () {
|
|||
|
|
config()->set('services.xfetch.balance_url', '');
|
|||
|
|
config()->set('services.xfetch.endpoint', 'https://xf4.ru/fetch');
|
|||
|
|
Http::fake(['xf4.ru/*' => Http::response('ok', 200)]);
|
|||
|
|
expect((new XfetchBalanceProvider)->fetch()->ok)->toBeTrue();
|
|||
|
|
});
|