Files
2026-02-10 22:11:06 -05:00

51 lines
1.3 KiB
PHP

<?php
use App\Models\NotificationModel;
use CodeIgniter\Test\CIUnitTestCase;
class NotificationModelTest extends CIUnitTestCase
{
protected $model;
protected function setUp(): void
{
parent::setUp();
$this->model = new NotificationModel();
}
public function testGetActiveNotifications()
{
$result = $this->model->getActiveNotifications();
$this->assertIsArray($result);
}
public function testGetDeletedNotifications()
{
$result = $this->model->getDeletedNotifications();
$this->assertIsArray($result);
}
public function testRestoreNotification()
{
// Create + soft delete a test record
$id = $this->model->insert([
'title' => 'Test restore',
'message' => 'Test message',
'target_group' => 'parent',
'delivery_channels' => 'in_app',
'priority' => 'normal',
'status' => 'sent',
'scheduled_at' => date('Y-m-d H:i:s'),
]);
$this->model->delete($id);
$this->assertNotNull($this->model->onlyDeleted()->find($id));
// Restore
$this->model->restoreNotification($id);
$this->assertNull($this->model->onlyDeleted()->find($id));
}
}