39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
use App\Enums\IsActive;
|
|
use App\Models\SubLocation;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
describe('SubLocation Model', function () {
|
|
it('can create a sub location', function () {
|
|
$subLocation = SubLocation::factory()->create([
|
|
'name' => 'Test Sub Location',
|
|
]);
|
|
|
|
expect($subLocation->name)->toBe('Test Sub Location')
|
|
->and($subLocation->exists)->toBeTrue();
|
|
});
|
|
|
|
it('has guarded attributes', function () {
|
|
$guarded = ['id'];
|
|
|
|
expect(SubLocation::make()->getGuarded())->toEqual($guarded);
|
|
});
|
|
|
|
it('belongs to location', function () {
|
|
$subLocation = SubLocation::factory()->create();
|
|
|
|
expect($subLocation->location())->toBeInstanceOf(BelongsTo::class);
|
|
});
|
|
|
|
it('casts is_active to enum', function () {
|
|
$subLocation = SubLocation::factory()->create(['is_active' => IsActive::ACTIVE]);
|
|
|
|
expect($subLocation->is_active)->toBeInstanceOf(IsActive::class)
|
|
->and($subLocation->is_active)->toBe(IsActive::ACTIVE);
|
|
});
|
|
});
|