47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
use App\Models\Company;
|
|
use App\Models\User;
|
|
use App\Models\VerificationRequest;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
test('company has correct guarded properties', function () {
|
|
$company = new Company;
|
|
expect($company->getGuarded())->toBe(['id']);
|
|
});
|
|
|
|
test('company can be created using factory', function () {
|
|
$company = Company::factory()->create([
|
|
'name' => 'PT Media Maju',
|
|
]);
|
|
|
|
expect($company->name)->toBe('PT Media Maju');
|
|
$this->assertDatabaseHas('companies', ['name' => 'PT Media Maju']);
|
|
});
|
|
|
|
test('company belongs to a user', function () {
|
|
$user = User::factory()->create();
|
|
$company = Company::factory()->create(['user_id' => $user->id]);
|
|
|
|
expect($company->user)->toBeInstanceOf(User::class);
|
|
expect($company->user->id)->toBe($user->id);
|
|
});
|
|
|
|
test('company has one verification request', function () {
|
|
$company = Company::factory()->create();
|
|
$request = VerificationRequest::factory()->create(['company_id' => $company->id]);
|
|
|
|
expect($company->verificationRequest)->toBeInstanceOf(VerificationRequest::class);
|
|
expect($company->verificationRequest->id)->toBe($request->id);
|
|
});
|
|
|
|
test('company has static method for data change labels', function () {
|
|
$labels = Company::dataChangeEntryLabels();
|
|
|
|
expect($labels)->toBeArray();
|
|
expect($labels)->toHaveKey('name', 'Nama');
|
|
expect($labels)->toHaveKey('director_nik', 'NIK Direktur');
|
|
});
|