37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use App\Services\External\Yandex360BalanceStore;
|
||
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||
|
|
use Tests\TestCase;
|
||
|
|
|
||
|
|
uses(TestCase::class, RefreshDatabase::class);
|
||
|
|
|
||
|
|
it('set сохраняет число, get возвращает float', function () {
|
||
|
|
$store = new Yandex360BalanceStore;
|
||
|
|
$store->set(1464.31);
|
||
|
|
expect($store->get())->toBe(1464.31);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('get возвращает null, когда не задан', function () {
|
||
|
|
expect((new Yandex360BalanceStore)->get())->toBeNull();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('status отдаёт balance + updated_at', function () {
|
||
|
|
$store = new Yandex360BalanceStore;
|
||
|
|
expect($store->status())->toMatchArray(['balance' => null, 'updated_at' => null]);
|
||
|
|
$store->set(500.0);
|
||
|
|
$st = $store->status();
|
||
|
|
expect($st['balance'])->toBe(500.0);
|
||
|
|
expect($st['updated_at'])->not->toBeNull();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('null очищает баланс', function () {
|
||
|
|
$store = new Yandex360BalanceStore;
|
||
|
|
$store->set(500.0);
|
||
|
|
$store->set(null);
|
||
|
|
expect($store->get())->toBeNull();
|
||
|
|
expect($store->status()['balance'])->toBeNull();
|
||
|
|
});
|