Files
ladill-hosting/tests/Feature/AccountPagesTest.php
T
isaaccladandCursor 5703a00862
Deploy Ladill Hosting / deploy (push) Successful in 24s
Show linked domains on cards and fix Email leftovers.
Display hosted_sites on account cards, scope Afia and Settings to hosting,
add hosting_settings for notifications, and remove mailbox UI from the
hosting layout and account pages.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-06 17:30:40 +00:00

77 lines
2.6 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\EmailTeamMember;
use App\Models\User;
use App\Services\Billing\BillingClient;
use App\Services\Payment\WalletPaymentService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Str;
use Mockery;
use Tests\TestCase;
class AccountPagesTest extends TestCase
{
use RefreshDatabase;
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
private function user(): User
{
return User::create(['public_id' => (string) Str::uuid(), 'name' => 'A', 'email' => 'a+'.uniqid().'@x.com']);
}
public function test_settings_page_renders(): void
{
$this->actingAs($this->user())->get(route('account.settings'))->assertOk()->assertSee('Hosting notifications');
}
public function test_team_page_renders_with_owner(): void
{
$u = $this->user();
$this->actingAs($u)->get(route('account.team'))->assertOk()->assertSee('Owner')->assertSee($u->email);
}
public function test_team_invite_creates_member(): void
{
$u = $this->user();
$this->actingAs($u)->post(route('account.team.store'), ['email' => 'mate@x.com', 'role' => 'member'])
->assertRedirect();
$this->assertDatabaseHas('email_team_members', ['account_id' => $u->id, 'email' => 'mate@x.com', 'status' => 'invited']);
}
public function test_developers_page_and_token_lifecycle(): void
{
$u = $this->user();
$this->actingAs($u)->get(route('account.developers'))->assertOk()->assertSee('Create a token');
$this->actingAs($u)->post(route('account.developers.store'), ['name' => 'CI'])
->assertRedirect()->assertSessionHas('new_token');
$this->assertSame(1, $u->tokens()->count());
}
public function test_billing_page_renders(): void
{
$w = Mockery::mock(WalletPaymentService::class);
$w->shouldReceive('balanceMinor')->andReturn(5000);
$this->app->instance(WalletPaymentService::class, $w);
$b = Mockery::mock(BillingClient::class);
$b->shouldReceive('serviceLedger')->andReturn(['spent_minor' => 1000, 'credited_minor' => 0]);
$b->shouldReceive('balanceMinor')->andReturn(5000);
$this->app->instance(BillingClient::class, $b);
$this->actingAs($this->user())->get(route('account.billing'))
->assertOk()->assertSee('Spent on hosting');
}
public function test_switch_account_rejects_inaccessible(): void
{
$this->actingAs($this->user())->post(route('account.switch'), ['account' => 999999])->assertForbidden();
}
}