- Turnstile (App\Support\Turnstile, middleware turnstile) cho login admin và login/register/forgot/reset của khách; cấu hình ở setting key=turnstile, secret mã hoá SignRSA. - Menu sidebar khách (setting client_menu) và nút tắt topbar (setting client_quick_links) do admin sửa qua administrator/client-menu[/quick-links], khách đọc v1/setting/menu, v1/setting/quick-links. - v1/setting và settings/public chỉ trả whitelist PublicSetting::FIELDS (trước đây lộ bot_token, inet_api_key). - Cài đặt tài khoản khách (preferences), rate limit theo IP cho register/resend-verify. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
65 lines
1.9 KiB
PHP
65 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Http\Resources\Api\Admin\ProductResource;
|
|
use App\Models\Product;
|
|
use App\Models\ProductPricings;
|
|
use Illuminate\Support\Collection;
|
|
use Tests\TestCase;
|
|
|
|
class AdminProductResourceTest extends TestCase
|
|
{
|
|
public function test_it_reads_legacy_pricing_cycle_names_without_returning_null(): void
|
|
{
|
|
$product = new Product([
|
|
'name' => 'Legacy product',
|
|
'is_active' => true,
|
|
'setup_fee' => 0,
|
|
]);
|
|
$product->id = 4;
|
|
$product->setRelation('pricings', new Collection([
|
|
new ProductPricings([
|
|
'billing_cycle' => 'semiannually',
|
|
'price' => 7200000,
|
|
'currency' => 'VND',
|
|
]),
|
|
new ProductPricings([
|
|
'billing_cycle' => 'one_time',
|
|
'price' => 15000000,
|
|
'currency' => 'VND',
|
|
]),
|
|
]));
|
|
|
|
$data = (new ProductResource($product))->resolve(request());
|
|
|
|
$this->assertSame('7200000.00', $data['price_semiannually']);
|
|
$this->assertSame('15000000.00', $data['price_onetime']);
|
|
$this->assertSame('recurring', $data['billing_type']);
|
|
}
|
|
|
|
public function test_legacy_one_time_only_product_uses_frontend_billing_value(): void
|
|
{
|
|
$product = new Product([
|
|
'name' => 'One-time product',
|
|
'is_active' => true,
|
|
'setup_fee' => 0,
|
|
]);
|
|
$product->id = 5;
|
|
$product->setRelation('pricings', new Collection([
|
|
new ProductPricings([
|
|
'billing_cycle' => 'one_time',
|
|
'price' => 15000000,
|
|
'currency' => 'VND',
|
|
]),
|
|
]));
|
|
|
|
$data = (new ProductResource($product))->resolve(request());
|
|
|
|
$this->assertSame('onetime', $data['billing_type']);
|
|
$this->assertSame('15000000.00', $data['price_onetime']);
|
|
}
|
|
}
|