Phase 2: Implement Domain & Mailbox persistence, Analytics, and fix pagination issues

This commit is contained in:
idevakk
2026-03-05 20:19:30 +05:30
parent b981b6998f
commit 60b87a3609
23 changed files with 1037 additions and 256 deletions

46
tests/Unit/DomainTest.php Normal file
View File

@@ -0,0 +1,46 @@
<?php
use App\Models\Domain;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(Tests\TestCase::class, RefreshDatabase::class);
test('domain hash is automatically generated on creation', function () {
$domain = Domain::factory()->create([
'name' => 'auto-hash-test.com',
]);
expect($domain->domain_hash)->not->toBeNull()
->and(strlen($domain->domain_hash))->toBeGreaterThan(20);
});
test('allowed_types is cast to array', function () {
$domain = Domain::factory()->create([
'allowed_types' => ['test', 'demo'],
]);
$freshDomain = Domain::find($domain->id);
expect($freshDomain->allowed_types)->toBeArray()
->and($freshDomain->allowed_types)->toBe(['test', 'demo']);
});
test('domain supports soft deletes', function () {
$domain = Domain::factory()->create();
$id = $domain->id;
$domain->delete();
$this->assertSoftDeleted('domains', ['id' => $id]);
expect(Domain::find($id))->toBeNull();
expect(Domain::withTrashed()->find($id))->not->toBeNull();
});
test('domain is_active and is_archived are cast to boolean', function () {
$domain = Domain::factory()->create([
'is_active' => 1,
'is_archived' => 0,
]);
expect($domain->is_active)->toBeTrue()
->and($domain->is_archived)->toBeFalse();
});