Files
portal/app/tests/Feature/ClientSms/PricingTest.php
T
Дмитрий 3ec722416c feat(смс-клиент): сервисы — цена по ступеням, аудитория, отбор получателей
ClientSmsPricing (ступень по объёму получатели×сегменты, наценка не
применяется), ClientSmsAudienceBuilder (сделки/база/список, tenant-scope
SET LOCAL + явный where, нормализация телефона), ClientSmsRecipientSelector
(стоп-лист→дубль→маршрут), ClientSmsPlan DTO.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-25 20:59:35 +03:00

36 lines
1.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
use App\Services\ClientSms\ClientSmsPricing;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('ступень выбирается по объёму (границы)', function () {
$p = app(ClientSmsPricing::class);
expect($p->pricePerSmsRub(99))->toBe('9.00')
->and($p->pricePerSmsRub(100))->toBe('8.50')
->and($p->pricePerSmsRub(249))->toBe('8.50')
->and($p->pricePerSmsRub(250))->toBe('8.30')
->and($p->pricePerSmsRub(500))->toBe('8.10')
->and($p->pricePerSmsRub(999))->toBe('8.10')
->and($p->pricePerSmsRub(1000))->toBe('8.00')
->and($p->pricePerSmsRub(50000))->toBe('8.00')
->and($p->pricePerSmsRub(0))->toBe('9.00'); // volume floored to >=1
});
it('смета = объём × цена ступени', function () {
$p = app(ClientSmsPricing::class);
// 300 recipients × 1 segment = volume 300 → tier 8.30 → 2490.00
expect($p->estimateRub(300, 1))->toBe('2490.00')
// 60 recipients × 2 segments = volume 120 → tier 8.50 → 1020.00
->and($p->estimateRub(60, 2))->toBe('1020.00')
->and($p->estimateRub(0, 1))->toBe('0.00'); // no recipients → 0
});
it('segments() делегирует калькулятору', function () {
$p = app(ClientSmsPricing::class);
expect($p->segments('короткий'))->toBe(1);
});