add controllers, servoices
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services\Grading;
|
||||
|
||||
use App\Services\Grading\GradingBelowSixtyService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class GradingBelowSixtyServiceTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_list_rows_returns_students_below_sixty(): void
|
||||
{
|
||||
DB::table('students')->insert([
|
||||
'id' => 100,
|
||||
'parent_id' => 10,
|
||||
'firstname' => 'Kid',
|
||||
'lastname' => 'User',
|
||||
'school_id' => 1,
|
||||
'age' => 10,
|
||||
'gender' => 'M',
|
||||
'photo_consent' => 1,
|
||||
'year_of_registration' => '2025',
|
||||
'is_active' => 1,
|
||||
]);
|
||||
|
||||
DB::table('classSection')->insert([
|
||||
'id' => 1,
|
||||
'class_section_id' => 1,
|
||||
'class_section_name' => '1A',
|
||||
'class_id' => 1,
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
|
||||
DB::table('semester_scores')->insert([
|
||||
'id' => 1,
|
||||
'student_id' => 100,
|
||||
'school_id' => 1,
|
||||
'class_section_id' => 1,
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
'semester_score' => 55,
|
||||
]);
|
||||
|
||||
$service = new GradingBelowSixtyService();
|
||||
$rows = $service->listRows('2025-2026', 'Fall');
|
||||
|
||||
$this->assertCount(1, $rows);
|
||||
$this->assertSame(100, (int) $rows[0]['student_id']);
|
||||
$this->assertSame('Open', $rows[0]['status']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services\Grading;
|
||||
|
||||
use App\Services\Grading\GradingLockService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class GradingLockServiceTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_toggle_creates_lock(): void
|
||||
{
|
||||
DB::table('classSection')->insert([
|
||||
'id' => 1,
|
||||
'class_section_id' => 1,
|
||||
'class_section_name' => '1A',
|
||||
'class_id' => 1,
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
|
||||
$service = new GradingLockService();
|
||||
$locked = $service->toggle(1, 'Fall', '2025-2026', 99);
|
||||
|
||||
$this->assertTrue($locked);
|
||||
$this->assertDatabaseHas('grading_locks', [
|
||||
'class_section_id' => 1,
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
'is_locked' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_lock_all_locks_sections(): void
|
||||
{
|
||||
DB::table('classSection')->insert([
|
||||
[
|
||||
'id' => 1,
|
||||
'class_section_id' => 1,
|
||||
'class_section_name' => '1A',
|
||||
'class_id' => 1,
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'class_section_id' => 2,
|
||||
'class_section_name' => '1B',
|
||||
'class_id' => 1,
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
],
|
||||
]);
|
||||
|
||||
$service = new GradingLockService();
|
||||
$count = $service->lockAll('Fall', '2025-2026', 99);
|
||||
|
||||
$this->assertSame(2, $count);
|
||||
$this->assertDatabaseHas('grading_locks', [
|
||||
'class_section_id' => 2,
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
'is_locked' => 1,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services\Grading;
|
||||
|
||||
use App\Services\Grading\HomeworkTrackingCalendarService;
|
||||
use App\Services\Grading\HomeworkTrackingService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class HomeworkTrackingServiceTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_report_returns_teacher_rows(): void
|
||||
{
|
||||
DB::table('configuration')->insert([
|
||||
['id' => 1, 'config_key' => 'school_year', 'config_value' => '2025-2026'],
|
||||
['id' => 2, 'config_key' => 'semester', 'config_value' => 'Fall'],
|
||||
]);
|
||||
|
||||
DB::table('classSection')->insert([
|
||||
'id' => 1,
|
||||
'class_section_id' => 1,
|
||||
'class_section_name' => '1A',
|
||||
'class_id' => 1,
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
|
||||
DB::table('users')->insert([
|
||||
'id' => 1,
|
||||
'school_id' => 1,
|
||||
'firstname' => 'Teacher',
|
||||
'lastname' => 'User',
|
||||
'cellphone' => '5555555555',
|
||||
'email' => 'teacher@example.com',
|
||||
'address_street' => '123 Main',
|
||||
'city' => 'City',
|
||||
'state' => 'ST',
|
||||
'zip' => '12345',
|
||||
'accept_school_policy' => 1,
|
||||
'is_verified' => 1,
|
||||
'status' => 'Active',
|
||||
'is_suspended' => 0,
|
||||
'failed_attempts' => 0,
|
||||
'password' => bcrypt('secret'),
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
|
||||
DB::table('teacher_class')->insert([
|
||||
'id' => 1,
|
||||
'class_section_id' => 1,
|
||||
'teacher_id' => 1,
|
||||
'position' => 'main',
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
|
||||
DB::table('homework')->insert([
|
||||
'id' => 1,
|
||||
'student_id' => 100,
|
||||
'school_id' => 1,
|
||||
'class_section_id' => 1,
|
||||
'updated_by' => 1,
|
||||
'homework_index' => 1,
|
||||
'score' => 90,
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$service = new HomeworkTrackingService(new HomeworkTrackingCalendarService());
|
||||
$result = $service->report('Fall', '2025-2026', 1);
|
||||
|
||||
$this->assertNotEmpty($result['teachers']);
|
||||
$this->assertSame(1, $result['teachers'][0]['class_section_id']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user