Files
portal/app/tests/Unit/External/Yandex360BalanceProviderTest.php
T
Дмитрий 1fef2571e8
Accessibility (Pa11y live) / a11y (push) Has been cancelled
SAST — Semgrep / Semgrep SAST scan (push) Has been cancelled
feat(y360): баланс почты Яндекс 360 — ручной ввод + кнопка Пополнить
email — денежный сервис; сумма вписывается в админке «Система» (Yandex360BalanceStore),
светофор по порогам, кнопка «Открыть оплату»/«Пополнить» → admin.yandex.ru/products.
Робот-скрейпер отклонён (SPA Яндекса враждебен ботам + автопополнение защищает баланс).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-02 13:34:13 +03:00

39 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
use App\Services\External\Yandex360BalanceProvider;
use App\Services\External\Yandex360BalanceStore;
use Tests\TestCase;
uses(TestCase::class);
/** Стаб хранилища ручного баланса. */
function balanceStoreReturning(?float $balance): Yandex360BalanceStore
{
return new class($balance) extends Yandex360BalanceStore
{
public function __construct(private ?float $b) {}
public function get(): ?float
{
return $this->b;
}
};
}
it('ok при заданном балансе', function () {
$p = new Yandex360BalanceProvider(balanceStoreReturning(1464.31));
$r = $p->fetch();
expect($r->serviceKey)->toBe('email');
expect($r->ok)->toBeTrue();
expect($r->balance)->toBe(1464.31);
});
it('fail, когда баланс не задан', function () {
$p = new Yandex360BalanceProvider(balanceStoreReturning(null));
$r = $p->fetch();
expect($r->ok)->toBeFalse();
expect($r->error)->toContain('не задан');
});