47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?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();
|
|
});
|