35 lines
1.5 KiB
PHP
35 lines
1.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use App\Services\ClientTg\TelegramTariffService;
|
||
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||
|
|
|
||
|
|
uses(RefreshDatabase::class);
|
||
|
|
|
||
|
|
it('ступень выбирается по объёму показов (границы)', function () {
|
||
|
|
$p = app(TelegramTariffService::class);
|
||
|
|
expect($p->pricePerImpressionRub(0))->toBe('0.45') // volume floored to >=1
|
||
|
|
->and($p->pricePerImpressionRub(999))->toBe('0.45')
|
||
|
|
->and($p->pricePerImpressionRub(1000))->toBe('0.42')
|
||
|
|
->and($p->pricePerImpressionRub(4999))->toBe('0.42')
|
||
|
|
->and($p->pricePerImpressionRub(5000))->toBe('0.40')
|
||
|
|
->and($p->pricePerImpressionRub(9999))->toBe('0.40')
|
||
|
|
->and($p->pricePerImpressionRub(10000))->toBe('0.38')
|
||
|
|
->and($p->pricePerImpressionRub(49999))->toBe('0.38')
|
||
|
|
->and($p->pricePerImpressionRub(50000))->toBe('0.36')
|
||
|
|
->and($p->pricePerImpressionRub(500000))->toBe('0.36');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('смета = объём показов × цена ступени', function () {
|
||
|
|
$p = app(TelegramTariffService::class);
|
||
|
|
// 500 показов → ступень 0.45 → 225.00
|
||
|
|
expect($p->estimateRub(500))->toBe('225.00')
|
||
|
|
// 1000 показов → ступень 0.42 → 420.00
|
||
|
|
->and($p->estimateRub(1000))->toBe('420.00')
|
||
|
|
// 5000 показов → ступень 0.40 → 2000.00
|
||
|
|
->and($p->estimateRub(5000))->toBe('2000.00')
|
||
|
|
// 0 показов → 0.00
|
||
|
|
->and($p->estimateRub(0))->toBe('0.00');
|
||
|
|
});
|