Initial Ladill Hosting app with Gitea deploy pipeline.
Deploy Ladill Hosting / deploy (push) Failing after 17s
Deploy Ladill Hosting / deploy (push) Failing after 17s
Shared web hosting extracted from the platform monolith, with CI deploy to /var/www/ladill-hosting matching Bird/Domains/Email. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Exceptions\ContaboApiException;
|
||||
use App\Jobs\ProvisionHostingOrderJob;
|
||||
use App\Models\CustomerHostingOrder;
|
||||
use App\Models\HostingProduct;
|
||||
use App\Models\User;
|
||||
use App\Services\Hosting\HostingOrderFulfillmentService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use Tests\TestCase;
|
||||
|
||||
class HostingOrderFulfillmentServiceTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_paid_order_is_always_queued_for_provisioning(): void
|
||||
{
|
||||
Bus::fake();
|
||||
|
||||
$user = User::factory()->create();
|
||||
$product = HostingProduct::create([
|
||||
'name' => 'Cloud VPS',
|
||||
'slug' => 'vps-fulfillment',
|
||||
'category' => HostingProduct::CATEGORY_VPS,
|
||||
'type' => HostingProduct::TYPE_VPS,
|
||||
'contabo_product_id' => 'V91',
|
||||
'price_monthly' => 50,
|
||||
'currency' => 'GHS',
|
||||
'disk_gb' => 75,
|
||||
'is_active' => true,
|
||||
'is_visible' => true,
|
||||
]);
|
||||
|
||||
$order = CustomerHostingOrder::create([
|
||||
'user_id' => $user->id,
|
||||
'hosting_product_id' => $product->id,
|
||||
'domain_name' => 'vps-server',
|
||||
'billing_cycle' => CustomerHostingOrder::CYCLE_MONTHLY,
|
||||
'amount_paid' => 50,
|
||||
'currency' => 'GHS',
|
||||
'status' => CustomerHostingOrder::STATUS_PENDING_APPROVAL,
|
||||
]);
|
||||
|
||||
$result = app(HostingOrderFulfillmentService::class)->attemptAutoFulfillment($order);
|
||||
|
||||
$this->assertTrue($result['fulfilled']);
|
||||
$order->refresh();
|
||||
$this->assertSame(CustomerHostingOrder::STATUS_APPROVED, $order->status);
|
||||
Bus::assertDispatched(ProvisionHostingOrderJob::class);
|
||||
}
|
||||
|
||||
public function test_customer_facing_status_hides_approval_wording(): void
|
||||
{
|
||||
$this->assertSame('Pending', CustomerHostingOrder::customerFacingStatusLabelFor(
|
||||
CustomerHostingOrder::STATUS_PENDING_APPROVAL
|
||||
));
|
||||
$this->assertSame('Pending', CustomerHostingOrder::customerFacingStatusLabelFor(
|
||||
CustomerHostingOrder::STATUS_APPROVED
|
||||
));
|
||||
}
|
||||
|
||||
public function test_contabo_402_is_treated_as_payment_required(): void
|
||||
{
|
||||
$exception = ContaboApiException::fromResponse(402, json_encode([
|
||||
'message' => 'Request refused as it requires additional payed service.',
|
||||
], JSON_THROW_ON_ERROR));
|
||||
|
||||
$this->assertTrue($exception->isPaymentRequired());
|
||||
}
|
||||
|
||||
public function test_order_returns_to_pending_approval_on_contabo_payment_failure(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$product = HostingProduct::create([
|
||||
'name' => 'Cloud VPS',
|
||||
'slug' => 'vps-hold',
|
||||
'category' => HostingProduct::CATEGORY_VPS,
|
||||
'type' => HostingProduct::TYPE_VPS,
|
||||
'contabo_product_id' => 'V91',
|
||||
'price_monthly' => 50,
|
||||
'currency' => 'GHS',
|
||||
'disk_gb' => 75,
|
||||
'is_active' => true,
|
||||
'is_visible' => true,
|
||||
]);
|
||||
|
||||
$order = CustomerHostingOrder::create([
|
||||
'user_id' => $user->id,
|
||||
'hosting_product_id' => $product->id,
|
||||
'domain_name' => 'vps-hold',
|
||||
'billing_cycle' => CustomerHostingOrder::CYCLE_MONTHLY,
|
||||
'amount_paid' => 50,
|
||||
'currency' => 'GHS',
|
||||
'status' => CustomerHostingOrder::STATUS_PROVISIONING,
|
||||
]);
|
||||
|
||||
$order->holdForAdminProvisioning('Request refused as it requires additional payed service.', 402);
|
||||
|
||||
$order->refresh();
|
||||
$this->assertSame(CustomerHostingOrder::STATUS_PENDING_APPROVAL, $order->status);
|
||||
$this->assertSame(402, $order->meta['provisioning_hold']['http_status'] ?? null);
|
||||
$this->assertSame('Pending', $order->customerFacingStatusLabel());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user