add all controllers logic

This commit is contained in:
root
2026-03-11 17:53:15 -04:00
parent 3e6c577085
commit 2ef71cc92b
421 changed files with 12009 additions and 5211 deletions
@@ -0,0 +1,73 @@
<?php
namespace Tests\Unit\Services\ClassSections;
use App\Models\User;
use App\Services\ClassSections\ClassAttendanceService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class ClassAttendanceServiceTest extends TestCase
{
use RefreshDatabase;
public function test_get_attendance_payload_includes_students(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
]);
DB::table('classSection')->insert([
'class_id' => 1,
'class_section_id' => 101,
'class_section_name' => '1-A',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
DB::table('students')->insert([
'school_id' => 'S-1',
'firstname' => 'Student',
'lastname' => 'One',
'age' => 8,
'gender' => 'Male',
'photo_consent' => 1,
'parent_id' => 1,
'year_of_registration' => '2025',
'school_year' => '2025-2026',
'semester' => 'Fall',
'is_active' => 1,
]);
DB::table('student_class')->insert([
'student_id' => 1,
'class_section_id' => 101,
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
$teacher = User::query()->create([
'firstname' => 'Teach',
'lastname' => 'Er',
'email' => 'teacher@example.com',
'cellphone' => '5555555555',
'address_street' => '123 Main',
'city' => 'City',
'state' => 'ST',
'zip' => '12345',
'accept_school_policy' => 1,
'status' => 'Active',
'password' => bcrypt('secret'),
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
$service = app(ClassAttendanceService::class);
$payload = $service->getAttendancePayload(101, $teacher->id);
$this->assertSame('1-A', $payload['class_name']);
$this->assertCount(1, $payload['students']);
}
}
@@ -0,0 +1,36 @@
<?php
namespace Tests\Unit\Services\ClassSections;
use App\Models\ClassSection;
use App\Services\ClassSections\ClassSectionCommandService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ClassSectionCommandServiceTest extends TestCase
{
use RefreshDatabase;
public function test_create_update_delete(): void
{
$service = app(ClassSectionCommandService::class);
$section = $service->create([
'class_id' => 1,
'class_section_id' => 101,
'class_section_name' => '1-A',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
$this->assertInstanceOf(ClassSection::class, $section);
$this->assertDatabaseHas('classSection', ['id' => $section->id]);
$updated = $service->update($section, ['class_section_name' => '1-B']);
$this->assertSame('1-B', $updated->class_section_name);
$deleted = $service->delete($section);
$this->assertTrue($deleted);
$this->assertDatabaseMissing('classSection', ['id' => $section->id]);
}
}
@@ -0,0 +1,47 @@
<?php
namespace Tests\Unit\Services\ClassSections;
use App\Services\ClassSections\ClassSectionQueryService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class ClassSectionQueryServiceTest extends TestCase
{
use RefreshDatabase;
public function test_list_filters_by_search(): void
{
DB::table('classes')->insert([
'class_name' => 'Class 1',
'schedule' => 'Monday',
'capacity' => 30,
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
DB::table('classSection')->insert([
[
'class_id' => 1,
'class_section_id' => 101,
'class_section_name' => '1-A',
'semester' => 'Fall',
'school_year' => '2025-2026',
],
[
'class_id' => 1,
'class_section_id' => 102,
'class_section_name' => '2-B',
'semester' => 'Fall',
'school_year' => '2025-2026',
],
]);
$service = app(ClassSectionQueryService::class);
$pager = $service->list(['search' => '1-A'], 1, 10);
$this->assertSame(1, $pager->total());
$this->assertSame('1-A', $pager->items()[0]->class_section_name);
}
}
@@ -0,0 +1,31 @@
<?php
namespace Tests\Unit\Services\ClassSections;
use App\Services\ClassSections\ClassSectionSeedService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class ClassSectionSeedServiceTest extends TestCase
{
use RefreshDatabase;
public function test_seed_defaults_creates_rows(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'semester', 'config_value' => 'Fall'],
]);
$service = app(ClassSectionSeedService::class);
$count = $service->seedDefaults();
$this->assertGreaterThan(0, $count);
$this->assertDatabaseHas('classes', [
'class_name' => 'Class 1',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
}
}