26 lines
887 B
PHP
26 lines
887 B
PHP
<?php
|
|
|
|
use App\Models\AuditLogEntry;
|
|
use App\Models\School;
|
|
use App\Models\SchoolEmailDomain;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('logs when a school email domain is created', function () {
|
|
$school = School::factory()->create();
|
|
SchoolEmailDomain::create([
|
|
'domain' => 'test.com',
|
|
'school_id' => $school->id,
|
|
]);
|
|
$lastLog = AuditLogEntry::orderBy('id', 'desc')->first();
|
|
expect($lastLog->message)->toEqual('Added the email domain test.com to school '.$school->name);
|
|
});
|
|
|
|
it('logs when a school email domain is deleted', function () {
|
|
$domain = SchoolEmailDomain::factory()->create();
|
|
$domain->delete();
|
|
$lastLog = AuditLogEntry::orderBy('id', 'desc')->first();
|
|
expect($lastLog->message)->toEqual('Removed the email domain '.$domain->domain.' from school '.$domain->school->name);
|
|
});
|