Files
portal-api/tests/Feature/Api/Admin/Customer/UpdateServiceBillingCycleTest.php
baodev0andClaude Opus 5.5 30898ea46f feat: email gửi tay/nhắc gia hạn, gói hosting, sửa dữ liệu sản phẩm
- Gửi email theo template cho 1 khách, tab lịch sử email, nhắc gia hạn dịch vụ hàng loạt
- Mail lưu from/bcc/sent_by; mẫu MARKETING và mẫu cũ trong TemplateSeeder
- Gói hosting: giới hạn, trạng thái, lấy plan Plesk qua CLI gateway
- Backfill payment_method và ngày đơn hàng còn thiếu
- Bổ sung field CPU/RAM/Disk/Băng thông cho loại sản phẩm vps và cloud

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 11:32:05 +07:00

41 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\Api\Admin\Customer;
use App\Models\Customer;
use App\Models\OrderItem;
use App\Models\Service;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Schema;
use Spatie\Permission\Models\Role;
use Tests\TestCase;
class UpdateServiceBillingCycleTest extends TestCase
{
use RefreshDatabase;
public function test_updates_order_item_billing_cycle_and_months(): void
{
Role::firstOrCreate(['name' => 'Full Administrator', 'guard_name' => 'admin']);
$admin = User::factory()->create();
$admin->assignRole('Full Administrator');
Schema::disableForeignKeyConstraints();
$customer = Customer::factory()->create();
$item = OrderItem::create(['order_id' => 1, 'product_id' => 1, 'billing_cycle' => 'monthly', 'months' => 1, 'quantity' => 1, 'price' => 100000]);
$service = Service::create(['customer_id' => $customer->id, 'order_item_id' => $item->id, 'status' => 'active']);
$url = "/api/v1/administrator/customers/{$customer->uuid}/services/{$service->id}";
$this->actingAs($admin, 'admin')->putJson($url, ['billing_cycle' => 'annually'])->assertOk();
$item->refresh();
$this->assertSame('annually', $item->billing_cycle);
$this->assertSame(12, (int) $item->months);
$this->actingAs($admin, 'admin')->putJson($url, ['billing_cycle' => 'onetime'])->assertStatus(422);
}
}