add controllers, servoices
This commit is contained in:
@@ -2,45 +2,32 @@
|
||||
|
||||
namespace Tests\Unit\Services\AttendanceTracking;
|
||||
|
||||
use App\Models\ParentNotification;
|
||||
use App\Services\AttendanceNotificationLogService;
|
||||
use Mockery;
|
||||
use App\Services\AttendanceTracking\AttendanceNotificationLogService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AttendanceNotificationLogServiceTest extends TestCase
|
||||
{
|
||||
protected function tearDown(): void
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_log_notification_creates_and_updates(): void
|
||||
{
|
||||
Mockery::close();
|
||||
parent::tearDown();
|
||||
$service = new AttendanceNotificationLogService(new \App\Models\ParentNotification());
|
||||
|
||||
$service->logNotification(1, 'ABS_1', '2025-01-01', 'email', 'parent@example.com', 'Subject', 'sent');
|
||||
$this->assertDatabaseHas('parent_notifications', [
|
||||
'student_id' => 1,
|
||||
'code' => 'ABS_1',
|
||||
'incident_date' => '2025-01-01',
|
||||
'channel' => 'email',
|
||||
'to_address' => 'parent@example.com',
|
||||
'status' => 'sent',
|
||||
]);
|
||||
|
||||
$service->logNotification(1, 'ABS_1', '2025-01-01', 'email', 'parent@example.com', 'Updated', 'failed');
|
||||
$row = DB::table('parent_notifications')->where('student_id', 1)->first();
|
||||
$this->assertSame('Updated', $row->subject);
|
||||
$this->assertSame('failed', $row->status);
|
||||
}
|
||||
|
||||
public function test_notification_already_sent_returns_true_when_model_has_sent_returns_true(): void
|
||||
{
|
||||
$model = Mockery::mock(ParentNotification::class);
|
||||
$model->shouldReceive('hasSent')
|
||||
->once()
|
||||
->with(10, 'ABS_1', '2026-03-01', 'email', 'parent@example.com')
|
||||
->andReturn(true);
|
||||
|
||||
$service = new AttendanceNotificationLogService($model);
|
||||
|
||||
$this->assertTrue(
|
||||
$service->notificationAlreadySent(10, 'ABS_1', '2026-03-01', 'email', 'parent@example.com')
|
||||
);
|
||||
}
|
||||
|
||||
public function test_notification_already_sent_returns_false_when_model_has_sent_returns_false(): void
|
||||
{
|
||||
$model = Mockery::mock(ParentNotification::class);
|
||||
$model->shouldReceive('hasSent')
|
||||
->once()
|
||||
->andReturn(false);
|
||||
|
||||
$service = new AttendanceNotificationLogService($model);
|
||||
|
||||
$this->assertFalse(
|
||||
$service->notificationAlreadySent(10, 'ABS_1', '2026-03-01', 'email', 'parent@example.com')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user