add services logic

This commit is contained in:
root
2026-03-11 01:38:20 -04:00
parent 182036cc41
commit 3e6c577085
47 changed files with 918 additions and 1772 deletions
@@ -0,0 +1,51 @@
<?php
namespace Tests\Unit\Services\Attendance;
use App\Services\Attendance\AttendanceCommentService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class AttendanceCommentServiceTest extends TestCase
{
use RefreshDatabase;
public function test_comment_from_score_uses_template_and_name(): void
{
DB::table('attendance_comment_template')->insert([
[
'min_score' => 90,
'max_score' => 100,
'template_text' => '{name} attendance is excellent.',
'is_active' => 1,
],
[
'min_score' => 0,
'max_score' => 89,
'template_text' => 'needs improvement in attendance.',
'is_active' => 1,
],
]);
$service = new AttendanceCommentService();
$comment = $service->commentFromScore(95, 'James');
$this->assertSame("James' attendance is excellent.", $comment);
}
public function test_comment_from_score_falls_back_to_this_student(): void
{
DB::table('attendance_comment_template')->insert([
'min_score' => 0,
'max_score' => 100,
'template_text' => 'needs improvement in attendance.',
'is_active' => 1,
]);
$service = new AttendanceCommentService();
$comment = $service->commentFromScore(70);
$this->assertSame("This student's needs improvement in attendance.", $comment);
}
}