35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Helpers\OrderHelper;
|
|
use App\Support\BillingCycleCatalog;
|
|
use App\Support\ProductBillingCycles;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class CustomBillingCycleTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_custom_cycle_is_resolved_end_to_end(): void
|
|
{
|
|
$this->assertSame([], BillingCycleCatalog::customMonths());
|
|
|
|
BillingCycleCatalog::saveCustomMonths([60, 12, 60, 0, 9999]);
|
|
|
|
$this->assertSame([60], BillingCycleCatalog::customMonths());
|
|
$this->assertContains('months_60', BillingCycleCatalog::codes());
|
|
$this->assertSame(60, OrderHelper::cycleToMonths('months_60'));
|
|
$this->assertSame('5 năm', BillingCycleCatalog::labelForCode('months_60'));
|
|
$this->assertContains('months_60', ProductBillingCycles::forType('vps'));
|
|
$this->assertSame(['annually'], ProductBillingCycles::forType('domain'));
|
|
}
|
|
|
|
public function test_unknown_code_is_rejected(): void
|
|
{
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
OrderHelper::cycleToMonths('months_x');
|
|
}
|
|
}
|