add notifications logic and add support of both JWT and Sanctum

This commit is contained in:
root
2026-03-11 01:20:31 -04:00
parent f6be51576c
commit 182036cc41
141 changed files with 8685 additions and 648 deletions
@@ -0,0 +1,66 @@
<?php
namespace Tests\Unit\Services\Notifications;
use App\Services\Notifications\NotificationManagementService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class NotificationManagementServiceTest extends TestCase
{
use RefreshDatabase;
public function test_update_modifies_notification(): void
{
DB::table('notifications')->insert([
'id' => 1,
'title' => 'Old',
'message' => 'Message',
'target_group' => 'parent',
'delivery_channels' => json_encode(['in_app']),
'created_at' => now(),
'updated_at' => now(),
]);
$service = new NotificationManagementService();
$result = $service->update(1, ['title' => 'New']);
$this->assertTrue($result['ok']);
$this->assertDatabaseHas('notifications', [
'id' => 1,
'title' => 'New',
]);
}
public function test_update_returns_false_when_missing(): void
{
$service = new NotificationManagementService();
$result = $service->update(999, ['title' => 'New']);
$this->assertFalse($result['ok']);
}
public function test_delete_and_restore_notification(): void
{
DB::table('notifications')->insert([
'id' => 1,
'title' => 'Old',
'message' => 'Message',
'target_group' => 'parent',
'delivery_channels' => json_encode(['in_app']),
'created_at' => now(),
'updated_at' => now(),
]);
$service = new NotificationManagementService();
$this->assertTrue($service->delete(1));
$this->assertSoftDeleted('notifications', ['id' => 1]);
$this->assertTrue($service->restore(1));
$this->assertDatabaseHas('notifications', [
'id' => 1,
'deleted_at' => null,
]);
}
}