Fix Laravel Pint formatting

This commit is contained in:
root
2026-06-08 23:30:22 -04:00
parent 567dc24649
commit c792b8be05
1288 changed files with 10766 additions and 9669 deletions
@@ -13,7 +13,6 @@ class ApiAuthenticationAndAuthorizationTest extends TestCase
use CreatesApiTestUsers;
use RefreshDatabase;
public function test_api_login_returns_token_and_user_object(): void
{
$user = $this->createApiUserWithRole('teacher', [
@@ -103,7 +102,7 @@ class ApiAuthenticationAndAuthorizationTest extends TestCase
foreach ($this->sampleProtectedRoutes() as $route) {
$method = $this->primaryMethod($route);
$uri = '/' . $this->uriWithPlaceholders($route->uri());
$uri = '/'.$this->uriWithPlaceholders($route->uri());
$response = $this->json($method, $uri);
$status = $response->getStatusCode();
@@ -113,7 +112,7 @@ class ApiAuthenticationAndAuthorizationTest extends TestCase
}
}
$this->assertSame([], $failures, "Anonymous requests reached unexpected responses:\n" . implode("\n", $failures));
$this->assertSame([], $failures, "Anonymous requests reached unexpected responses:\n".implode("\n", $failures));
}
/**
@@ -47,7 +47,6 @@ class ApiPreferencesFeatureTest extends TestCase
->assertJsonPath('status', true);
}
public function test_non_admin_cannot_list_or_manage_another_users_preferences(): void
{
$owner = $this->createApiUserWithRole('teacher');
+1 -1
View File
@@ -36,7 +36,7 @@ class ApiPublicEndpointsTest extends TestCase
public function test_public_frontend_content_endpoints_do_not_server_error(): void
{
foreach (['/', 'facility', 'team', 'call-to-action', 'testimonial', 'not-found'] as $path) {
$uri = '/api/v1/frontend' . ($path === '/' ? '' : '/' . $path);
$uri = '/api/v1/frontend'.($path === '/' ? '' : '/'.$path);
$response = $this->getJson($uri);
$this->assertLessThan(500, $response->getStatusCode(), "$uri returned a server error");
@@ -2,8 +2,6 @@
namespace Tests\Feature\Api;
use App\Models\Permission;
use App\Models\Role;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\Concerns\CreatesApiTestUsers;
+5 -5
View File
@@ -24,11 +24,11 @@ class ApiRouteContractTest extends TestCase
[$class, $method] = explode('@', $action, 2);
if (! class_exists($class) || ! method_exists($class, $method)) {
$missing[] = implode('|', $route->methods()) . ' ' . $route->uri() . ' -> ' . $action;
$missing[] = implode('|', $route->methods()).' '.$route->uri().' -> '.$action;
}
}
$this->assertSame([], $missing, "These API routes reference missing controllers or methods:\n" . implode("\n", $missing));
$this->assertSame([], $missing, "These API routes reference missing controllers or methods:\n".implode("\n", $missing));
}
public function test_api_routes_do_not_duplicate_method_and_uri_pairs(): void
@@ -42,7 +42,7 @@ class ApiRouteContractTest extends TestCase
continue;
}
$key = $method . ' ' . $route->uri();
$key = $method.' '.$route->uri();
if (isset($seen[$key])) {
$duplicates[] = $key;
}
@@ -90,11 +90,11 @@ class ApiRouteContractTest extends TestCase
});
if (! $hasProtection) {
$unprotected[] = implode('|', $methods) . ' ' . $route->uri();
$unprotected[] = implode('|', $methods).' '.$route->uri();
}
}
$this->assertSame([], $unprotected, "Mutating API routes without an obvious auth/throttle middleware:\n" . implode("\n", $unprotected));
$this->assertSame([], $unprotected, "Mutating API routes without an obvious auth/throttle middleware:\n".implode("\n", $unprotected));
}
/**
@@ -2,7 +2,6 @@
namespace Tests\Feature\Api;
use App\Models\Role;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Hash;
@@ -121,4 +121,4 @@ class AdministratorAbsenceControllerTest extends TestCase
'dates' => ['2026-03-08'],
]);
}
}
}
@@ -128,4 +128,4 @@ class AdministratorEnrollmentControllerTest extends TestCase
'message' => 'Enrollment statuses updated and notifications sent.',
]);
}
}
}
@@ -263,6 +263,7 @@ class AdministratorEnrollmentUpdateStatusesApiTest extends TestCase
private function postUpdateStatuses(array $enrollmentStatus)
{
$query = http_build_query(['enrollment_status' => $enrollmentStatus]);
return $this->post('/api/v1/administrator/enrollment-withdrawal/update-statuses?' . $query, []);
return $this->post('/api/v1/administrator/enrollment-withdrawal/update-statuses?'.$query, []);
}
}
@@ -157,4 +157,4 @@ class AdministratorNotificationControllerTest extends TestCase
'message' => 'Print notification recipients updated.',
]);
}
}
}
@@ -2,10 +2,10 @@
namespace Tests\Feature\Api\Administrator;
use App\Http\Middleware\EnsurePrintRequestsAdminAccess;
use App\Models\User;
use App\Services\Administrator\TeacherSubmissionNotificationService;
use App\Services\Administrator\TeacherSubmissionReportService;
use App\Http\Middleware\EnsurePrintRequestsAdminAccess;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\Sanctum\Sanctum;
use Mockery;
@@ -281,7 +281,7 @@ class AdministratorTeacherSubmissionReportApiTest extends TestCase
'class_section_id' => 12,
'admin_id' => 901,
'notification_category' => 'teacher_submissions',
'message' => 'Reminder ' . $i,
'message' => 'Reminder '.$i,
'status' => 'sent',
'school_year' => '2025-2026',
'semester' => 'Fall',
@@ -80,7 +80,7 @@ class EmergencyContactControllerTest extends TestCase
]);
Sanctum::actingAs($admin, [], 'api');
$response = $this->patch('/api/v1/administrator/emergency-contacts/' . $contact->id, [
$response = $this->patch('/api/v1/administrator/emergency-contacts/'.$contact->id, [
'parent_id' => $parent->id,
'name' => 'New Name',
'cellphone' => '5555555555',
@@ -116,7 +116,7 @@ class EmergencyContactControllerTest extends TestCase
]);
Sanctum::actingAs($admin, [], 'api');
$response = $this->delete('/api/v1/administrator/emergency-contacts/' . $contact->id, [
$response = $this->delete('/api/v1/administrator/emergency-contacts/'.$contact->id, [
'parent_id' => $parent->id,
], [
'Accept' => 'application/json',
@@ -145,7 +145,7 @@ class EmergencyContactControllerTest extends TestCase
]);
Sanctum::actingAs($admin, [], 'api');
$response = $this->get('/api/v1/administrator/emergency-contacts/' . $contact->id . '?parent_id=' . $parent->id, [
$response = $this->get('/api/v1/administrator/emergency-contacts/'.$contact->id.'?parent_id='.$parent->id, [
'Accept' => 'application/json',
]);
@@ -171,7 +171,7 @@ class EmergencyContactControllerTest extends TestCase
]);
Sanctum::actingAs($admin, [], 'api');
$response = $this->patch('/api/v1/administrator/emergency-contacts/' . $contact->id, [
$response = $this->patch('/api/v1/administrator/emergency-contacts/'.$contact->id, [
'parent_id' => $otherParent->id,
'name' => 'New Name',
'cellphone' => '9999999999',
@@ -205,7 +205,7 @@ class EmergencyContactControllerTest extends TestCase
]);
Sanctum::actingAs($admin, [], 'api');
$response = $this->delete('/api/v1/administrator/emergency-contacts/' . $contact->id, [
$response = $this->delete('/api/v1/administrator/emergency-contacts/'.$contact->id, [
'parent_id' => $otherParent->id,
], [
'Accept' => 'application/json',
@@ -16,11 +16,17 @@ class AssignmentApiControllerTest extends TestCase
use RefreshDatabase;
protected User $user;
protected User $teacherMain;
protected User $teacherAssistant;
protected ClassSection $sectionA;
protected ClassSection $sectionB;
protected Student $studentOne;
protected Student $studentTwo;
protected function setUp(): void
@@ -418,4 +424,4 @@ class AssignmentApiControllerTest extends TestCase
$this->assertSame(['Main Teacher'], $mainTeachers);
}
}
}
+49 -49
View File
@@ -2,12 +2,12 @@
namespace Tests\Feature\Api;
use App\Models\User;
use App\Models\ClassSection;
use App\Models\Configuration;
use App\Models\Student;
use App\Models\StudentClass;
use App\Models\TeacherClass;
use App\Models\ClassSection;
use App\Models\Configuration;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\Sanctum\Sanctum;
use PHPUnit\Framework\Attributes\Test;
@@ -48,36 +48,36 @@ class AssignmentApiTest extends TestCase
$teacher = User::factory()->create([
'firstname' => 'Ahmad',
'lastname' => 'Ali',
'lastname' => 'Ali',
]);
TeacherClass::query()->create([
'teacher_id' => $teacher->id,
'class_section_id' => $section->class_section_id,
'position' => 'main',
'semester' => 'Fall',
'school_year' => '2025-2026',
'description' => 'Main teacher assignment',
'teacher_id' => $teacher->id,
'class_section_id' => $section->class_section_id,
'position' => 'main',
'semester' => 'Fall',
'school_year' => '2025-2026',
'description' => 'Main teacher assignment',
]);
$student = Student::factory()->create([
'firstname' => 'Sara',
'lastname' => 'Yousef',
'is_active' => 1,
'gender' => 'F',
'firstname' => 'Sara',
'lastname' => 'Yousef',
'is_active' => 1,
'gender' => 'F',
'registration_grade' => '5',
'photo_consent' => 1,
'tuition_paid' => 1,
'school_id' => 'SCH-1001',
'photo_consent' => 1,
'tuition_paid' => 1,
'school_id' => 'SCH-1001',
]);
StudentClass::query()->create([
'student_id' => $student->id,
'class_section_id' => $section->class_section_id,
'semester' => 'Fall',
'school_year' => '2025-2026',
'description' => 'Student assigned',
'is_active' => 1, // remove if your table doesnt have this column
'student_id' => $student->id,
'class_section_id' => $section->class_section_id,
'semester' => 'Fall',
'school_year' => '2025-2026',
'description' => 'Student assigned',
'is_active' => 1, // remove if your table doesnt have this column
]);
$response = $this->getJson('/api/assignments');
@@ -96,7 +96,7 @@ class AssignmentApiTest extends TestCase
'semester',
'school_year',
'description',
]
],
],
'schoolYears',
'selectedYear',
@@ -122,19 +122,19 @@ class AssignmentApiTest extends TestCase
$teacher = User::factory()->create(['firstname' => 'Test', 'lastname' => 'Teacher']);
TeacherClass::query()->create([
'teacher_id' => $teacher->id,
'teacher_id' => $teacher->id,
'class_section_id' => $section1->class_section_id,
'position' => 'main',
'semester' => 'Fall',
'school_year' => '2024-2025',
'position' => 'main',
'semester' => 'Fall',
'school_year' => '2024-2025',
]);
TeacherClass::query()->create([
'teacher_id' => $teacher->id,
'teacher_id' => $teacher->id,
'class_section_id' => $section2->class_section_id,
'position' => 'main',
'semester' => 'Fall',
'school_year' => '2025-2026',
'position' => 'main',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
$response = $this->getJson('/api/assignments?school_year=2025-2026');
@@ -158,11 +158,11 @@ class AssignmentApiTest extends TestCase
$section = ClassSection::factory()->create();
$payload = [
'student_id' => $student->id,
'student_id' => $student->id,
'class_section_id' => $section->class_section_id,
'semester' => 'Spring',
'school_year' => '2025-2026',
'description' => 'Moved after placement review',
'semester' => 'Spring',
'school_year' => '2025-2026',
'description' => 'Moved after placement review',
];
$response = $this->postJson('/api/assignments', $payload);
@@ -171,10 +171,10 @@ class AssignmentApiTest extends TestCase
->assertJsonPath('message', 'Assignment saved successfully.');
$this->assertDatabaseHas('student_class', [
'student_id' => $student->id,
'student_id' => $student->id,
'class_section_id' => $section->class_section_id,
'semester' => 'Spring',
'school_year' => '2025-2026',
'semester' => 'Spring',
'school_year' => '2025-2026',
]);
}
@@ -203,19 +203,19 @@ class AssignmentApiTest extends TestCase
// First create
$this->postJson('/api/assignments', [
'student_id' => $student->id,
'student_id' => $student->id,
'class_section_id' => $sectionA->class_section_id,
'semester' => 'Fall',
'school_year' => '2025-2026',
'semester' => 'Fall',
'school_year' => '2025-2026',
])->assertCreated();
// Second call same unique key should update (per service updateOrCreate)
$this->postJson('/api/assignments', [
'student_id' => $student->id,
'student_id' => $student->id,
'class_section_id' => $sectionA->class_section_id,
'semester' => 'Fall',
'school_year' => '2025-2026',
'description' => 'Reassigned',
'semester' => 'Fall',
'school_year' => '2025-2026',
'description' => 'Reassigned',
])->assertCreated();
$this->assertEquals(
@@ -228,10 +228,10 @@ class AssignmentApiTest extends TestCase
);
$this->assertDatabaseHas('student_class', [
'student_id' => $student->id,
'student_id' => $student->id,
'class_section_id' => $sectionA->class_section_id,
'semester' => 'Fall',
'school_year' => '2025-2026',
'semester' => 'Fall',
'school_year' => '2025-2026',
]);
}
@@ -113,7 +113,7 @@ class LateSlipLogsControllerTest extends TestCase
$user = User::query()->create([
'firstname' => 'Test',
'lastname' => 'User',
'email' => $roleName . '@example.com',
'email' => $roleName.'@example.com',
'cellphone' => '5555555555',
'address_street' => '123 Main',
'city' => 'City',
@@ -85,10 +85,10 @@ class AttendanceCommentTemplateApiTest extends TestCase
$mock->shouldReceive('create')
->once()
->with(Mockery::on(function ($data) use ($payload) {
return (int)$data['min_score'] === 80
&& (int)$data['max_score'] === 100
return (int) $data['min_score'] === 80
&& (int) $data['max_score'] === 100
&& $data['template_text'] === $payload['template_text']
&& (bool)$data['is_active'] === true;
&& (bool) $data['is_active'] === true;
}))
->andReturn([
'id' => 10,
@@ -159,7 +159,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
->once()
->with(7, Mockery::on(function ($data) {
return $data['template_text'] === 'Updated comment text'
&& (bool)$data['is_active'] === false;
&& (bool) $data['is_active'] === false;
}))
->andReturn([
'id' => 7,
@@ -221,7 +221,7 @@ class AttendanceCommentTemplateApiTest extends TestCase
'max_score' => 49,
'template_text' => 'Low attendance',
'is_active' => true,
]
],
]);
$this->app->instance(AttendanceCommentTemplateService::class, $mock);
@@ -232,4 +232,4 @@ class AttendanceCommentTemplateApiTest extends TestCase
->assertJsonCount(1, 'templates')
->assertJsonPath('templates.0.id', 1);
}
}
}
@@ -4,6 +4,7 @@ namespace Tests\Feature\Api\V1\AttendanceTracking;
use App\Services\AttendanceTracking\AttendanceTrackingService;
use Mockery;
use Mockery\MockInterface;
use Tests\TestCase;
class AttendanceTrackingControllerTest extends TestCase
@@ -14,7 +15,7 @@ class AttendanceTrackingControllerTest extends TestCase
parent::tearDown();
}
protected function mockService(): \Mockery\MockInterface
protected function mockService(): MockInterface
{
$service = Mockery::mock(AttendanceTrackingService::class);
$this->app->instance(AttendanceTrackingService::class, $service);
@@ -159,7 +159,7 @@ class IpBanControllerTest extends TestCase
$user = User::query()->create([
'firstname' => 'Test',
'lastname' => 'User',
'email' => $roleName . '@example.com',
'email' => $roleName.'@example.com',
'cellphone' => '5555555555',
'address_street' => '123 Main',
'city' => 'City',
+1 -1
View File
@@ -234,4 +234,4 @@ class BadgeControllerTest extends TestCase
$this->postJson('/api/badges/log-print', ['user_ids' => [1]])->assertStatus(401);
$this->postJson('/api/badges/pdf', ['user_ids' => [1]])->assertStatus(401);
}
}
}
@@ -31,7 +31,8 @@ class BroadcastEmailControllerTest extends TestCase
{
$this->seedParentData();
$fake = new class extends EmailService {
$fake = new class extends EmailService
{
public array $sent = [];
public function send(
@@ -41,9 +42,9 @@ class BroadcastEmailControllerTest extends TestCase
string $fromKey = 'general',
array $cc = [],
array $bcc = []
): bool
{
): bool {
$this->sent[] = compact('to', 'subject', 'html', 'fromKey', 'cc', 'bcc');
return true;
}
};
@@ -92,7 +92,7 @@ class ClassProgressControllerTest extends TestCase
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/class-progress/' . $report->id);
$response = $this->getJson('/api/v1/class-progress/'.$report->id);
$response->assertOk();
$response->assertJsonPath('status', true);
@@ -110,7 +110,7 @@ class ClassProgressControllerTest extends TestCase
Sanctum::actingAs($user);
$response = $this->patchJson('/api/v1/class-progress/' . $report->id, [
$response = $this->patchJson('/api/v1/class-progress/'.$report->id, [
'status' => 'behind',
]);
@@ -132,7 +132,7 @@ class ClassProgressControllerTest extends TestCase
Sanctum::actingAs($user);
$response = $this->deleteJson('/api/v1/class-progress/' . $report->id);
$response = $this->deleteJson('/api/v1/class-progress/'.$report->id);
$response->assertOk();
$this->assertDatabaseMissing('class_progress_reports', [
@@ -152,7 +152,7 @@ class ClassProgressControllerTest extends TestCase
Sanctum::actingAs($other);
$response = $this->getJson('/api/v1/class-progress/' . $report->id);
$response = $this->getJson('/api/v1/class-progress/'.$report->id);
$response->assertStatus(403);
}
@@ -187,7 +187,7 @@ class ClassProgressControllerTest extends TestCase
Sanctum::actingAs($user);
$response = $this->get('/api/v1/class-progress/attachments/' . $attachment->id);
$response = $this->get('/api/v1/class-progress/attachments/'.$attachment->id);
$response->assertOk();
}
@@ -257,7 +257,7 @@ class ClassSectionControllerTest extends TestCase
'firstname' => 'Test',
'lastname' => 'User',
'cellphone' => '5555555555',
'email' => $roleName . '@example.com',
'email' => $roleName.'@example.com',
'address_street' => '123 Main',
'city' => 'City',
'state' => 'ST',
@@ -50,7 +50,8 @@ class CommunicationControllerTest extends TestCase
{
$this->seedCommunicationData();
$fake = new class extends EmailService {
$fake = new class extends EmailService
{
public array $sent = [];
public function send(
@@ -62,6 +63,7 @@ class CommunicationControllerTest extends TestCase
array $bcc = []
): bool {
$this->sent[] = compact('to', 'subject', 'html', 'fromKey', 'cc', 'bcc');
return true;
}
};
@@ -23,7 +23,7 @@ class FamilyAdminControllerTest extends TestCase
$this->seedFamilyGuardian($familyId, $user->id);
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/family-admin?student_id=' . $studentId);
$response = $this->getJson('/api/v1/family-admin?student_id='.$studentId);
$response->assertOk();
$response->assertJsonPath('status', true);
@@ -58,7 +58,7 @@ class FamilyAdminControllerTest extends TestCase
$this->seedPayment($user->id);
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/family-admin/card?family_id=' . $familyId);
$response = $this->getJson('/api/v1/family-admin/card?family_id='.$familyId);
$response->assertOk();
$response->assertJsonPath('status', true);
@@ -123,7 +123,7 @@ class FamilyAdminControllerTest extends TestCase
'firstname' => 'Parent',
'lastname' => 'User',
'cellphone' => '9999999999',
'email' => 'parent' . $id . '@example.com',
'email' => 'parent'.$id.'@example.com',
'address_street' => '123 Street',
'city' => 'City',
'state' => 'ST',
@@ -163,7 +163,7 @@ class FamilyAdminControllerTest extends TestCase
{
return DB::table('families')->insertGetId([
'family_code' => $code,
'household_name' => 'Family ' . $code,
'household_name' => 'Family '.$code,
'is_active' => 1,
'created_at' => now(),
'updated_at' => now(),
@@ -20,7 +20,7 @@ class FamilyControllerTest extends TestCase
$this->seedFamilyStudent($familyId, $studentId);
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/families/by-student/' . $studentId);
$response = $this->getJson('/api/v1/families/by-student/'.$studentId);
$response->assertOk();
$response->assertJsonPath('status', true);
@@ -34,7 +34,7 @@ class FamilyControllerTest extends TestCase
$this->seedFamilyGuardian($familyId, $user->id);
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/families/' . $familyId . '/guardians');
$response = $this->getJson('/api/v1/families/'.$familyId.'/guardians');
$response->assertOk();
$response->assertJsonPath('status', true);
@@ -292,7 +292,7 @@ class FamilyControllerTest extends TestCase
{
return DB::table('families')->insertGetId([
'family_code' => $code,
'household_name' => 'Family ' . $code,
'household_name' => 'Family '.$code,
'is_active' => 1,
'created_at' => now(),
'updated_at' => now(),
@@ -28,7 +28,7 @@ class EventChargeControllerTest extends TestCase
{
$charge = $this->makeCharge();
$this->getJson('/api/v1/finance/event-charges/' . $charge->id)
$this->getJson('/api/v1/finance/event-charges/'.$charge->id)
->assertStatus(401);
}
@@ -37,7 +37,7 @@ class EventChargeControllerTest extends TestCase
$this->actingAsApiAdministrator();
$charge = $this->makeCharge();
$this->getJson('/api/v1/finance/event-charges/' . $charge->id)
$this->getJson('/api/v1/finance/event-charges/'.$charge->id)
->assertOk()
->assertJsonPath('ok', true)
->assertJsonPath('event_charge.id', $charge->id)
@@ -57,7 +57,7 @@ class EventChargeControllerTest extends TestCase
$this->actingAsApiAdministrator();
$charge = $this->makeCharge();
$this->putJson('/api/v1/finance/event-charges/' . $charge->id, [
$this->putJson('/api/v1/finance/event-charges/'.$charge->id, [
'event_name' => 'Museum Visit',
'amount' => 40.50,
])
@@ -76,7 +76,7 @@ class EventChargeControllerTest extends TestCase
$this->actingAsApiAdministrator();
$charge = $this->makeCharge(['charged' => 0]);
$this->postJson('/api/v1/finance/event-charges/' . $charge->id . '/approve')
$this->postJson('/api/v1/finance/event-charges/'.$charge->id.'/approve')
->assertOk()
->assertJsonPath('ok', true);
@@ -91,7 +91,7 @@ class EventChargeControllerTest extends TestCase
$this->actingAsApiAdministrator();
$charge = $this->makeCharge(['charged' => 1]);
$this->postJson('/api/v1/finance/event-charges/' . $charge->id . '/void')
$this->postJson('/api/v1/finance/event-charges/'.$charge->id.'/void')
->assertOk()
->assertJsonPath('ok', true);
@@ -106,7 +106,7 @@ class EventChargeControllerTest extends TestCase
$this->actingAsApiAdministrator();
$charge = $this->makeCharge(['charged' => 1]);
$this->deleteJson('/api/v1/finance/event-charges/' . $charge->id)
$this->deleteJson('/api/v1/finance/event-charges/'.$charge->id)
->assertOk()
->assertJsonPath('ok', true);
@@ -49,7 +49,7 @@ class FrontendControllerTest extends TestCase
$user = User::query()->create([
'firstname' => 'Test',
'lastname' => 'User',
'email' => $roleName . '@example.com',
'email' => $roleName.'@example.com',
'cellphone' => '5555555555',
'address_street' => '123 Main',
'city' => 'City',
@@ -4,7 +4,6 @@ namespace Tests\Feature\Api\V1\Frontend;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
@@ -57,7 +57,7 @@ class LandingPageControllerTest extends TestCase
$user = User::query()->create([
'firstname' => 'Test',
'lastname' => 'User',
'email' => $roleName . '@example.com',
'email' => $roleName.'@example.com',
'cellphone' => '5555555555',
'address_street' => '123 Main',
'city' => 'City',
@@ -15,7 +15,7 @@ class PageControllerTest extends TestCase
{
$dir = public_path('html');
File::ensureDirectoryExists($dir);
File::put($dir . '/privacy_policy.html', '<h1>Privacy</h1>');
File::put($dir.'/privacy_policy.html', '<h1>Privacy</h1>');
$response = $this->getJson('/api/v1/pages/privacy');
@@ -28,7 +28,7 @@ class PageControllerTest extends TestCase
{
$dir = public_path('html');
File::ensureDirectoryExists($dir);
File::delete($dir . '/help_center.html');
File::delete($dir.'/help_center.html');
$response = $this->getJson('/api/v1/pages/help');
@@ -112,7 +112,7 @@ class IncidentControllerTest extends TestCase
$storeResponse->assertJson(['ok' => true, 'created' => true]);
$currentId = $storeResponse->json('incident_id');
$closeResponse = $this->postJson('/api/v1/incidents/' . $currentId . '/close', [
$closeResponse = $this->postJson('/api/v1/incidents/'.$currentId.'/close', [
'state_description' => 'Resolved',
'action_taken' => 'Spoke with student',
]);
@@ -45,7 +45,7 @@ class InventoryCategoriesControllerTest extends TestCase
$categoryId = $this->seedCategory('office');
Sanctum::actingAs($user);
$response = $this->patchJson('/api/v1/inventory/categories/' . $categoryId, [
$response = $this->patchJson('/api/v1/inventory/categories/'.$categoryId, [
'name' => 'Updated',
]);
@@ -59,7 +59,7 @@ class InventoryCategoriesControllerTest extends TestCase
$categoryId = $this->seedCategory('office');
Sanctum::actingAs($user);
$response = $this->deleteJson('/api/v1/inventory/categories/' . $categoryId);
$response = $this->deleteJson('/api/v1/inventory/categories/'.$categoryId);
$response->assertOk();
$this->assertDatabaseMissing('inventory_categories', ['id' => $categoryId]);
@@ -101,7 +101,7 @@ class InventoryCategoriesControllerTest extends TestCase
{
return DB::table('inventory_categories')->insertGetId([
'type' => $type,
'name' => ucfirst($type) . ' Category',
'name' => ucfirst($type).' Category',
'created_at' => now(),
'updated_at' => now(),
]);
@@ -35,7 +35,7 @@ class InventoryItemsControllerTest extends TestCase
$itemId = $this->seedInventoryItem($categoryId);
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/inventory/items/' . $itemId);
$response = $this->getJson('/api/v1/inventory/items/'.$itemId);
$response->assertOk();
$response->assertJsonPath('status', true);
@@ -70,7 +70,7 @@ class InventoryItemsControllerTest extends TestCase
$itemId = $this->seedInventoryItem($categoryId);
Sanctum::actingAs($user);
$response = $this->patchJson('/api/v1/inventory/items/' . $itemId, [
$response = $this->patchJson('/api/v1/inventory/items/'.$itemId, [
'name' => 'Updated Item',
]);
@@ -86,7 +86,7 @@ class InventoryItemsControllerTest extends TestCase
$itemId = $this->seedInventoryItem($categoryId);
Sanctum::actingAs($user);
$response = $this->deleteJson('/api/v1/inventory/items/' . $itemId);
$response = $this->deleteJson('/api/v1/inventory/items/'.$itemId);
$response->assertOk();
$this->assertDatabaseMissing('inventory_items', ['id' => $itemId]);
@@ -100,7 +100,7 @@ class InventoryItemsControllerTest extends TestCase
$itemId = $this->seedInventoryItem($categoryId);
Sanctum::actingAs($user);
$response = $this->postJson('/api/v1/inventory/items/' . $itemId . '/audit', [
$response = $this->postJson('/api/v1/inventory/items/'.$itemId.'/audit', [
'needs_repair_qty' => 1,
'need_replace_qty' => 1,
'cannot_find_qty' => 0,
@@ -118,7 +118,7 @@ class InventoryItemsControllerTest extends TestCase
$itemId = $this->seedInventoryItem($categoryId, 0);
Sanctum::actingAs($user);
$response = $this->postJson('/api/v1/inventory/items/' . $itemId . '/adjust', [
$response = $this->postJson('/api/v1/inventory/items/'.$itemId.'/adjust', [
'mode' => 'in',
'quantity' => 2,
'reason' => 'Restock',
@@ -170,7 +170,7 @@ class InventoryItemsControllerTest extends TestCase
$bookId = $this->seedInventoryItem($categoryId, 5, 'book');
Sanctum::actingAs($user);
$formResponse = $this->getJson('/api/v1/inventory/teacher-distribution?class_section_id=' . $classSectionId . '&item_id=' . $bookId);
$formResponse = $this->getJson('/api/v1/inventory/teacher-distribution?class_section_id='.$classSectionId.'&item_id='.$bookId);
$formResponse->assertOk();
$storeResponse = $this->postJson('/api/v1/inventory/teacher-distribution', [
@@ -233,7 +233,7 @@ class InventoryItemsControllerTest extends TestCase
{
return DB::table('inventory_categories')->insertGetId([
'type' => $type,
'name' => ucfirst($type) . ' Category',
'name' => ucfirst($type).' Category',
'created_at' => now(),
'updated_at' => now(),
]);
@@ -244,7 +244,7 @@ class InventoryItemsControllerTest extends TestCase
return DB::table('inventory_items')->insertGetId([
'type' => $type,
'category_id' => $categoryId,
'name' => 'Item ' . $type,
'name' => 'Item '.$type,
'quantity' => $quantity,
'semester' => 'Fall',
'school_year' => '2025-2026',
@@ -49,7 +49,7 @@ class InventoryMovementsControllerTest extends TestCase
$movementId = $this->seedMovement($itemId);
Sanctum::actingAs($user);
$response = $this->patchJson('/api/v1/inventory/movements/' . $movementId, [
$response = $this->patchJson('/api/v1/inventory/movements/'.$movementId, [
'qty_change' => 3,
'movement_type' => 'in',
]);
@@ -65,7 +65,7 @@ class InventoryMovementsControllerTest extends TestCase
$movementId = $this->seedMovement($itemId);
Sanctum::actingAs($user);
$response = $this->deleteJson('/api/v1/inventory/movements/' . $movementId);
$response = $this->deleteJson('/api/v1/inventory/movements/'.$movementId);
$response->assertOk();
$this->assertDatabaseMissing('inventory_movements', ['id' => $movementId]);
@@ -45,7 +45,7 @@ class SuppliersControllerTest extends TestCase
$supplierId = $this->seedSupplier('Supplier C');
Sanctum::actingAs($user);
$response = $this->patchJson('/api/v1/inventory/suppliers/' . $supplierId, [
$response = $this->patchJson('/api/v1/inventory/suppliers/'.$supplierId, [
'name' => 'Supplier Updated',
]);
@@ -59,7 +59,7 @@ class SuppliersControllerTest extends TestCase
$supplierId = $this->seedSupplier('Supplier D');
Sanctum::actingAs($user);
$response = $this->deleteJson('/api/v1/inventory/suppliers/' . $supplierId);
$response = $this->deleteJson('/api/v1/inventory/suppliers/'.$supplierId);
$response->assertOk();
$this->assertDatabaseMissing('suppliers', ['id' => $supplierId]);
@@ -44,7 +44,7 @@ class SupplyCategoriesControllerTest extends TestCase
$categoryId = $this->seedCategory('Pens');
Sanctum::actingAs($user);
$response = $this->patchJson('/api/v1/inventory/supply-categories/' . $categoryId, [
$response = $this->patchJson('/api/v1/inventory/supply-categories/'.$categoryId, [
'name' => 'Pens Updated',
]);
@@ -58,7 +58,7 @@ class SupplyCategoriesControllerTest extends TestCase
$categoryId = $this->seedCategory('Markers');
Sanctum::actingAs($user);
$response = $this->deleteJson('/api/v1/inventory/supply-categories/' . $categoryId);
$response = $this->deleteJson('/api/v1/inventory/supply-categories/'.$categoryId);
$response->assertOk();
$this->assertDatabaseMissing('supply_categories', ['id' => $categoryId]);
@@ -68,7 +68,7 @@ class MessagesControllerTest extends TestCase
Sanctum::actingAs($recipient);
$response = $this->getJson('/api/v1/messages/' . $message->id);
$response = $this->getJson('/api/v1/messages/'.$message->id);
$response->assertOk();
$this->assertDatabaseHas('messages', [
@@ -98,7 +98,7 @@ class MessagesControllerTest extends TestCase
Sanctum::actingAs($sender);
$response = $this->patchJson('/api/v1/messages/' . $message->id, [
$response = $this->patchJson('/api/v1/messages/'.$message->id, [
'status' => 'trashed',
]);
@@ -130,7 +130,7 @@ class MessagesControllerTest extends TestCase
Sanctum::actingAs($sender);
$response = $this->deleteJson('/api/v1/messages/' . $message->id);
$response = $this->deleteJson('/api/v1/messages/'.$message->id);
$response->assertOk();
$this->assertDatabaseHas('messages', [
@@ -197,7 +197,7 @@ class MessagesControllerTest extends TestCase
Sanctum::actingAs($other);
$response = $this->getJson('/api/v1/messages/' . $message->id);
$response = $this->getJson('/api/v1/messages/'.$message->id);
$response->assertForbidden();
}
@@ -18,7 +18,7 @@ class AuthorizedUsersControllerTest extends TestCase
'user_id' => $parentId,
'firstname' => 'Aunt',
'lastname' => 'Carer',
'email' => 'carer-' . uniqid() . '@example.test',
'email' => 'carer-'.uniqid().'@example.test',
'phone_number' => '5551112222',
'relation_to_user' => 'Aunt',
'status' => 'pending',
@@ -74,7 +74,7 @@ class AuthorizedUsersControllerTest extends TestCase
$foreign = $this->makeAuthorizedUser($otherParent->id);
$this->actingAs($parent, 'api')
->getJson('/api/v1/parents/authorized-users/' . $foreign->id)
->getJson('/api/v1/parents/authorized-users/'.$foreign->id)
->assertNotFound();
}
@@ -84,7 +84,7 @@ class AuthorizedUsersControllerTest extends TestCase
$record = $this->makeAuthorizedUser($parent->id);
$this->actingAs($parent, 'api')
->deleteJson('/api/v1/parents/authorized-users/' . $record->id)
->deleteJson('/api/v1/parents/authorized-users/'.$record->id)
->assertOk()
->assertJsonPath('status', true);
@@ -98,7 +98,7 @@ class AuthorizedUsersControllerTest extends TestCase
$foreign = $this->makeAuthorizedUser($otherParent->id);
$this->actingAs($parent, 'api')
->deleteJson('/api/v1/parents/authorized-users/' . $foreign->id)
->deleteJson('/api/v1/parents/authorized-users/'.$foreign->id)
->assertNotFound();
$this->assertDatabaseHas('authorized_users', ['id' => $foreign->id]);
@@ -106,7 +106,7 @@ class ParentAttendanceReportControllerTest extends TestCase
]);
Sanctum::actingAs($parent);
$response = $this->patchJson('/api/v1/parents/attendance-reports/' . $reportId, [
$response = $this->patchJson('/api/v1/parents/attendance-reports/'.$reportId, [
'reason' => 'Family emergency',
]);
@@ -193,6 +193,7 @@ class ParentAttendanceReportControllerTest extends TestCase
if ((int) $dt->format('w') !== 0) {
$dt->modify('next sunday');
}
return $dt->format('Y-m-d');
}
}
@@ -208,7 +208,7 @@ class PrintRequestsWorkflowTest extends TestCase
'status' => 'Active',
'is_verified' => 1,
'is_suspended' => 0,
'email' => $roleName . '-print-request-' . str_replace('.', '', uniqid('', true)) . '@example.test',
'email' => $roleName.'-print-request-'.str_replace('.', '', uniqid('', true)).'@example.test',
]);
$user->roles()->syncWithoutDetaching([$role->id]);
@@ -230,7 +230,7 @@ class PrintRequestsWorkflowTest extends TestCase
}
/**
* @param array<string, mixed> $overrides
* @param array<string, mixed> $overrides
*/
private function seedPrintRequest(User $teacher, array $overrides = []): PrintRequest
{
@@ -37,12 +37,12 @@ class ParentPromotionControllerTest extends TestCase
Sanctum::actingAs($parent);
// Start enrollment
$start = $this->postJson('/api/v1/parents/promotions/' . $promotionId . '/start');
$start = $this->postJson('/api/v1/parents/promotions/'.$promotionId.'/start');
$start->assertOk();
$start->assertJsonPath('data.promotion_status', StudentPromotionRecord::STATUS_ENROLLMENT_STARTED);
// Complete the checklist incrementally
$update = $this->patchJson('/api/v1/parents/promotions/' . $promotionId . '/steps', [
$update = $this->patchJson('/api/v1/parents/promotions/'.$promotionId.'/steps', [
'info_confirmed' => true,
'documents_uploaded' => true,
'agreement_accepted' => true,
@@ -51,7 +51,7 @@ class ParentPromotionControllerTest extends TestCase
$update->assertJsonPath('data.promotion_status', StudentPromotionRecord::STATUS_ENROLLMENT_STARTED);
// Final step finalises promotion
$finish = $this->patchJson('/api/v1/parents/promotions/' . $promotionId . '/steps', [
$finish = $this->patchJson('/api/v1/parents/promotions/'.$promotionId.'/steps', [
'payment_completed' => true,
]);
$finish->assertOk();
@@ -72,7 +72,7 @@ class ParentPromotionControllerTest extends TestCase
$promotionId = $this->seedPromotionRecord($studentId, $parentB->id);
Sanctum::actingAs($parentA);
$response = $this->getJson('/api/v1/parents/promotions/' . $promotionId);
$response = $this->getJson('/api/v1/parents/promotions/'.$promotionId);
$response->assertStatus(403);
}
@@ -140,6 +140,7 @@ class ParentPromotionControllerTest extends TestCase
'promoted_level_name' => 'Grade 4',
'enrollment_deadline' => now()->addDays(30)->toDateString(),
]);
return (int) $record->getKey();
}
}
@@ -53,7 +53,7 @@ class PublicWinnersControllerTest extends TestCase
'published_at' => now(),
]);
$this->getJson('/api/winners/competitions/' . $competition->id)
$this->getJson('/api/winners/competitions/'.$competition->id)
->assertOk()
->assertJsonPath('status', true)
->assertJsonPath('data.competition.id', $competition->id)
@@ -75,7 +75,7 @@ class PublicWinnersControllerTest extends TestCase
'is_published' => 0,
]);
$this->getJson('/api/winners/competitions/' . $competition->id)
$this->getJson('/api/winners/competitions/'.$competition->id)
->assertNotFound()
->assertJsonPath('status', false);
}
@@ -18,10 +18,10 @@ class FilesControllerTest extends TestCase
Sanctum::actingAs($user);
$dir = storage_path('uploads/receipts');
if (!is_dir($dir)) {
if (! is_dir($dir)) {
mkdir($dir, 0777, true);
}
$path = $dir . DIRECTORY_SEPARATOR . 'sample.pdf';
$path = $dir.DIRECTORY_SEPARATOR.'sample.pdf';
file_put_contents($path, 'PDFDATA');
$response = $this->getJson('/api/v1/files/receipts/sample.pdf?meta=1');
@@ -60,10 +60,10 @@ class FilesControllerTest extends TestCase
]);
$dir = storage_path('uploads/exams/drafts');
if (!is_dir($dir)) {
if (! is_dir($dir)) {
mkdir($dir, 0777, true);
}
$path = $dir . DIRECTORY_SEPARATOR . 'draft1.pdf';
$path = $dir.DIRECTORY_SEPARATOR.'draft1.pdf';
file_put_contents($path, 'PDFDATA');
$response = $this->get('/api/v1/files/exams/teacher/draft1.pdf');
@@ -37,7 +37,7 @@ class ReportCardsControllerTest extends TestCase
$data = $this->seedReportCardData($user->id);
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/reports/report-cards/completeness?class_section_id=' . $data['class_section_id'] . '&school_year=2025-2026&semester=Fall');
$response = $this->getJson('/api/v1/reports/report-cards/completeness?class_section_id='.$data['class_section_id'].'&school_year=2025-2026&semester=Fall');
$response->assertOk();
$response->assertJsonPath('status', true);
@@ -53,7 +53,7 @@ class ReportCardsControllerTest extends TestCase
$this->seedAcknowledgement($data['student_id']);
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/reports/report-cards/acknowledgement?student_id=' . $data['student_id'] . '&school_year=2025-2026&semester=Fall');
$response = $this->getJson('/api/v1/reports/report-cards/acknowledgement?student_id='.$data['student_id'].'&school_year=2025-2026&semester=Fall');
$response->assertOk();
$response->assertJsonPath('status', true);
@@ -67,7 +67,7 @@ class ReportCardsControllerTest extends TestCase
$data = $this->seedReportCardData($user->id);
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/reports/report-cards/students/' . $data['student_id'] . '?school_year=2025-2026&semester=Fall');
$response = $this->getJson('/api/v1/reports/report-cards/students/'.$data['student_id'].'?school_year=2025-2026&semester=Fall');
$response->assertOk();
$this->assertSame('application/pdf', $response->headers->get('content-type'));
@@ -80,7 +80,7 @@ class ReportCardsControllerTest extends TestCase
$data = $this->seedReportCardData($user->id);
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/reports/report-cards/classes/' . $data['class_section_id'] . '?school_year=2025-2026&semester=Fall');
$response = $this->getJson('/api/v1/reports/report-cards/classes/'.$data['class_section_id'].'?school_year=2025-2026&semester=Fall');
$response->assertOk();
$this->assertSame('application/pdf', $response->headers->get('content-type'));
@@ -93,7 +93,7 @@ class ReportCardsControllerTest extends TestCase
$data = $this->seedStudentOnly();
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/reports/report-cards/students/' . $data['student_id'] . '?school_year=2025-2026&semester=Fall');
$response = $this->getJson('/api/v1/reports/report-cards/students/'.$data['student_id'].'?school_year=2025-2026&semester=Fall');
$response->assertStatus(422);
$response->assertJsonPath('status', false);
@@ -3,6 +3,7 @@
namespace Tests\Feature\Api\V1\Roles;
use App\Models\User;
use App\Services\Roles\RoleCrudService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Laravel\Sanctum\Sanctum;
@@ -49,7 +50,7 @@ class RolePermissionControllerTest extends TestCase
$roleId = $this->seedRole();
Sanctum::actingAs($user);
$response = $this->patchJson('/api/v1/role-permissions/roles/' . $roleId, [
$response = $this->patchJson('/api/v1/role-permissions/roles/'.$roleId, [
'description' => 'updated',
]);
@@ -63,7 +64,7 @@ class RolePermissionControllerTest extends TestCase
$roleId = $this->seedRole();
Sanctum::actingAs($user);
$response = $this->deleteJson('/api/v1/role-permissions/roles/' . $roleId);
$response = $this->deleteJson('/api/v1/role-permissions/roles/'.$roleId);
$response->assertOk();
$this->assertDatabaseMissing('roles', ['id' => $roleId]);
@@ -92,7 +93,7 @@ class RolePermissionControllerTest extends TestCase
$roleId = $this->seedRole();
Sanctum::actingAs($user);
$response = $this->postJson('/api/v1/role-permissions/users/' . $user->id . '/roles', [
$response = $this->postJson('/api/v1/role-permissions/users/'.$user->id.'/roles', [
'role_ids' => [$roleId],
]);
@@ -118,15 +119,15 @@ class RolePermissionControllerTest extends TestCase
$create->assertStatus(201);
$permissionId = (int) $create->json('data.permission.id');
$show = $this->getJson('/api/v1/role-permissions/permissions/' . $permissionId);
$show = $this->getJson('/api/v1/role-permissions/permissions/'.$permissionId);
$show->assertOk();
$update = $this->patchJson('/api/v1/role-permissions/permissions/' . $permissionId, [
$update = $this->patchJson('/api/v1/role-permissions/permissions/'.$permissionId, [
'description' => 'Updated',
]);
$update->assertOk();
$delete = $this->deleteJson('/api/v1/role-permissions/permissions/' . $permissionId);
$delete = $this->deleteJson('/api/v1/role-permissions/permissions/'.$permissionId);
$delete->assertOk();
$this->assertDatabaseMissing('permissions', ['id' => $permissionId]);
}
@@ -138,7 +139,7 @@ class RolePermissionControllerTest extends TestCase
$permissionId = $this->seedPermission();
Sanctum::actingAs($user);
$response = $this->putJson('/api/v1/role-permissions/roles/' . $roleId . '/permissions', [
$response = $this->putJson('/api/v1/role-permissions/roles/'.$roleId.'/permissions', [
'permissions' => [
$permissionId => ['create' => true, 'read' => true],
],
@@ -170,8 +171,9 @@ class RolePermissionControllerTest extends TestCase
$user = $this->seedUser();
Sanctum::actingAs($user);
$this->app->bind(\App\Services\Roles\RoleCrudService::class, function () {
return new class {
$this->app->bind(RoleCrudService::class, function () {
return new class
{
public function create(array $payload)
{
throw new \RuntimeException('fail');
@@ -58,7 +58,6 @@ class RoleSwitcherControllerTest extends TestCase
$response->assertStatus(401);
}
public function test_switch_rejects_role_that_user_does_not_have(): void
{
$user = $this->seedUser();
@@ -97,7 +97,7 @@ class PreferencesControllerTest extends TestCase
$user = $this->createUser('teacher');
Sanctum::actingAs($user);
$response = $this->deleteJson('/api/v1/preferences/' . $user->id);
$response = $this->deleteJson('/api/v1/preferences/'.$user->id);
$response->assertForbidden();
}
@@ -113,7 +113,7 @@ class PreferencesControllerTest extends TestCase
'notification_sms' => 1,
]);
$response = $this->deleteJson('/api/v1/preferences/' . $admin->id);
$response = $this->deleteJson('/api/v1/preferences/'.$admin->id);
$response->assertOk();
$this->assertDatabaseMissing('user_preferences', [
@@ -146,7 +146,7 @@ class PreferencesControllerTest extends TestCase
'id' => $id,
'firstname' => 'Test',
'lastname' => 'User',
'email' => $roleName . $id . '@example.com',
'email' => $roleName.$id.'@example.com',
'cellphone' => '5555555555',
'address_street' => '123 Main',
'city' => 'City',
@@ -3,6 +3,7 @@
namespace Tests\Feature\Api\V1\Settings;
use App\Models\User;
use App\Services\Settings\SchoolCalendar\SchoolCalendarMutationService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Laravel\Sanctum\Sanctum;
@@ -50,7 +51,7 @@ class SchoolCalendarControllerTest extends TestCase
$eventId = $this->seedEvent();
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/settings/school-calendar/events/' . $eventId);
$response = $this->getJson('/api/v1/settings/school-calendar/events/'.$eventId);
$response->assertOk();
$response->assertJsonPath('status', true);
@@ -88,7 +89,7 @@ class SchoolCalendarControllerTest extends TestCase
$eventId = $this->seedEvent();
Sanctum::actingAs($user);
$response = $this->patchJson('/api/v1/settings/school-calendar/events/' . $eventId, [
$response = $this->patchJson('/api/v1/settings/school-calendar/events/'.$eventId, [
'title' => 'Updated Event',
]);
@@ -107,7 +108,7 @@ class SchoolCalendarControllerTest extends TestCase
$eventId = $this->seedEvent();
Sanctum::actingAs($user);
$response = $this->deleteJson('/api/v1/settings/school-calendar/events/' . $eventId);
$response = $this->deleteJson('/api/v1/settings/school-calendar/events/'.$eventId);
$response->assertOk();
$response->assertJsonPath('status', true);
@@ -134,8 +135,9 @@ class SchoolCalendarControllerTest extends TestCase
$user = $this->seedUser();
Sanctum::actingAs($user);
$this->app->bind(\App\Services\Settings\SchoolCalendar\SchoolCalendarMutationService::class, function () {
return new class {
$this->app->bind(SchoolCalendarMutationService::class, function () {
return new class
{
public function create(array $payload, array $targets = []): array
{
throw new \RuntimeException('fail');
@@ -2,7 +2,6 @@
namespace Tests\Feature\Api\V1\Settings;
use App\Models\Setting;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
@@ -80,7 +79,7 @@ class SettingsControllerTest extends TestCase
$user = User::query()->create([
'firstname' => 'Test',
'lastname' => 'User',
'email' => $roleName . '@example.com',
'email' => $roleName.'@example.com',
'cellphone' => '5555555555',
'address_street' => '123 Main',
'city' => 'City',
@@ -99,7 +99,7 @@ class StaffControllerTest extends TestCase
'school_year' => '2025-2026',
]);
$response = $this->patchJson('/api/v1/staff/' . $staff->id, [
$response = $this->patchJson('/api/v1/staff/'.$staff->id, [
'firstname' => 'Updated',
]);
@@ -127,7 +127,7 @@ class StaffControllerTest extends TestCase
'school_year' => '2025-2026',
]);
$response = $this->deleteJson('/api/v1/staff/' . $staff->id);
$response = $this->deleteJson('/api/v1/staff/'.$staff->id);
$response->assertOk();
$this->assertDatabaseMissing('staff', [
@@ -146,7 +146,7 @@ class StaffControllerTest extends TestCase
$user = User::query()->create([
'firstname' => 'Test',
'lastname' => 'User',
'email' => $email ?? ($roleName . '@example.com'),
'email' => $email ?? ($roleName.'@example.com'),
'cellphone' => '5555555555',
'address_street' => '123 Main',
'city' => 'City',
@@ -59,7 +59,7 @@ class StudentControllerTest extends TestCase
]);
Sanctum::actingAs($user);
$response = $this->getJson('/api/v1/students/' . $studentId . '/score-card');
$response = $this->getJson('/api/v1/students/'.$studentId.'/score-card');
$response->assertOk();
$response->assertJson(['ok' => true]);
@@ -85,7 +85,7 @@ class SupportControllerTest extends TestCase
$user = User::query()->create([
'firstname' => 'Test',
'lastname' => 'User',
'email' => $roleName . '@example.com',
'email' => $roleName.'@example.com',
'cellphone' => '5555555555',
'address_street' => '123 Main',
'city' => 'City',
@@ -22,7 +22,7 @@ class TeacherControllerTest extends TestCase
$this->seedStudent($teacher->id, $classSectionId);
Sanctum::actingAs($teacher);
$response = $this->getJson('/api/v1/teachers/classes?class_section_id=' . $classSectionId);
$response = $this->getJson('/api/v1/teachers/classes?class_section_id='.$classSectionId);
$response->assertOk();
$response->assertJson(['ok' => true]);
+1 -1
View File
@@ -53,7 +53,7 @@ class UiControllerTest extends TestCase
$user = User::query()->create([
'firstname' => 'Test',
'lastname' => 'User',
'email' => $roleName . '@example.com',
'email' => $roleName.'@example.com',
'cellphone' => '5555555555',
'address_street' => '123 Main',
'city' => 'City',
@@ -58,8 +58,7 @@ class WhatsappInviteControllerTest extends TestCase
Sanctum::actingAs($user);
$this->seedInviteData();
Event::listen(WhatsappInvitesSend::class, static function () {
});
Event::listen(WhatsappInvitesSend::class, static function () {});
$response = $this->postJson('/api/v1/whatsapp/invites/send', [
'mode' => 'parents',
@@ -52,7 +52,7 @@ class WhatsappLinkControllerTest extends TestCase
'updated_at' => now(),
]);
$response = $this->getJson('/api/v1/whatsapp/links/' . $linkId);
$response = $this->getJson('/api/v1/whatsapp/links/'.$linkId);
$response->assertOk();
$response->assertJsonPath('status', true);
@@ -99,7 +99,7 @@ class WhatsappLinkControllerTest extends TestCase
'updated_at' => now(),
]);
$response = $this->patchJson('/api/v1/whatsapp/links/' . $linkId, [
$response = $this->patchJson('/api/v1/whatsapp/links/'.$linkId, [
'invite_link' => 'https://chat.whatsapp.com/updated',
'active' => false,
]);
@@ -129,7 +129,7 @@ class WhatsappLinkControllerTest extends TestCase
'updated_at' => now(),
]);
$response = $this->deleteJson('/api/v1/whatsapp/links/' . $linkId);
$response = $this->deleteJson('/api/v1/whatsapp/links/'.$linkId);
$response->assertOk();
$response->assertJsonPath('status', true);
@@ -54,11 +54,11 @@ class ScenarioAFamilyEnrollmentTest extends TestCase
// Teacher sees student in roster.
$this->actingAs($teacher, 'api');
$this->getJson('/api/v1/teachers/classes?class_section_id=' . $classSectionId)
$this->getJson('/api/v1/teachers/classes?class_section_id='.$classSectionId)
->assertOk()
->assertJsonPath('ok', true);
$studentIds = array_column($this->getJson('/api/v1/teachers/classes?class_section_id=' . $classSectionId)->json('students'), 'student_id');
$studentIds = array_column($this->getJson('/api/v1/teachers/classes?class_section_id='.$classSectionId)->json('students'), 'student_id');
$this->assertContains($studentId, $studentIds);
// Parent sees own profile.
@@ -89,7 +89,7 @@ class ScenarioAFamilyEnrollmentTest extends TestCase
]);
$this->actingAs($parentA, 'api');
$this->patchJson('/api/v1/parents/students/' . $studentB, [
$this->patchJson('/api/v1/parents/students/'.$studentB, [
'firstname' => 'Hacked',
'lastname' => 'Child',
'dob' => '2015-01-01',
@@ -27,7 +27,7 @@ class ScenarioBSundaySchoolDayTest extends TestCase
$this->actingAs($teacher, 'api');
$form = $this->getJson('/api/v1/attendance/teacher/form?class_section_id=' . $classSectionId)
$form = $this->getJson('/api/v1/attendance/teacher/form?class_section_id='.$classSectionId)
->assertOk();
$date = (string) ($form->json('data.current_sunday') ?? '2025-10-05');
@@ -52,7 +52,7 @@ class ScenarioBSundaySchoolDayTest extends TestCase
// Parent views attendance for their child.
$this->actingAs($parent, 'api');
$this->getJson('/api/v1/parents/attendance?school_year=' . self::E2E_SCHOOL_YEAR)
$this->getJson('/api/v1/parents/attendance?school_year='.self::E2E_SCHOOL_YEAR)
->assertOk()
->assertJsonPath('ok', true);
}
@@ -51,7 +51,7 @@ class ScenarioCAcademicTermTest extends TestCase
$this->actingAs($teacher, 'api');
$this->getJson('/api/v1/scores/overview?class_section_id=' . $classSectionId . '&semester=' . self::E2E_SEMESTER . '&school_year=' . self::E2E_SCHOOL_YEAR)
$this->getJson('/api/v1/scores/overview?class_section_id='.$classSectionId.'&semester='.self::E2E_SEMESTER.'&school_year='.self::E2E_SCHOOL_YEAR)
->assertOk()
->assertJsonPath('ok', true);
@@ -69,7 +69,7 @@ class ScenarioCAcademicTermTest extends TestCase
'is_locked' => 1,
]);
$this->getJson('/api/v1/reports/report-cards/students/' . $studentId . '?school_year=' . self::E2E_SCHOOL_YEAR . '&semester=' . self::E2E_SEMESTER)
$this->getJson('/api/v1/reports/report-cards/students/'.$studentId.'?school_year='.self::E2E_SCHOOL_YEAR.'&semester='.self::E2E_SEMESTER)
->assertOk();
}
@@ -61,7 +61,7 @@ class ScenarioDFamilyBillingTest extends TestCase
->value('id');
$this->assertGreaterThan(0, $chargeId);
$this->postJson('/api/v1/finance/event-charges/' . $chargeId . '/approve')
$this->postJson('/api/v1/finance/event-charges/'.$chargeId.'/approve')
->assertOk()
->assertJsonPath('ok', true);
@@ -81,7 +81,7 @@ class ScenarioDFamilyBillingTest extends TestCase
'invoice_id' => $invoiceId,
]);
$this->getJson('/api/v1/finance/payments/parent/' . $parentId . '?school_year=' . self::E2E_SCHOOL_YEAR)
$this->getJson('/api/v1/finance/payments/parent/'.$parentId.'?school_year='.self::E2E_SCHOOL_YEAR)
->assertOk()
->assertJsonPath('ok', true);
@@ -26,7 +26,7 @@ class ScenarioEFinanceEdgeTest extends TestCase
$parent = $this->createApiUserWithRole('parent');
$priorInvoiceId = $this->seedPriorYearUnpaidInvoice($parent->id);
$preview = $this->getJson('/api/v1/finance/carryforwards/preview?' . http_build_query([
$preview = $this->getJson('/api/v1/finance/carryforwards/preview?'.http_build_query([
'from_school_year' => self::E2E_PREV_SCHOOL_YEAR,
'to_school_year' => self::E2E_SCHOOL_YEAR,
'parent_id' => $parent->id,
@@ -44,24 +44,24 @@ class ScenarioEFinanceEdgeTest extends TestCase
$this->assertNotEmpty($draft->json('result.created'));
$carryforwardId = (int) $draft->json('result.created.0.id');
$this->postJson('/api/v1/finance/carryforwards/' . $carryforwardId . '/approve')
$this->postJson('/api/v1/finance/carryforwards/'.$carryforwardId.'/approve')
->assertOk()
->assertJsonPath('ok', true);
$posted = $this->postJson('/api/v1/finance/carryforwards/' . $carryforwardId . '/post')
$posted = $this->postJson('/api/v1/finance/carryforwards/'.$carryforwardId.'/post')
->assertOk()
->assertJsonPath('ok', true);
$newInvoiceId = (int) ($posted->json('carryforward.posted_invoice_id') ?? 0);
$this->assertGreaterThan(0, $newInvoiceId);
$plan = $this->postJson('/api/v1/finance/invoices/' . $newInvoiceId . '/installment-plans', [
$plan = $this->postJson('/api/v1/finance/invoices/'.$newInvoiceId.'/installment-plans', [
'number_of_installments' => 2,
'first_due_date' => '2025-09-15',
'interval_months' => 1,
])->assertCreated()->assertJsonPath('ok', true);
$planId = (int) $plan->json('plan.id');
$this->postJson('/api/v1/finance/installment-plans/' . $planId . '/activate')
$this->postJson('/api/v1/finance/installment-plans/'.$planId.'/activate')
->assertOk()
->assertJsonPath('ok', true);
@@ -81,7 +81,7 @@ class ScenarioEFinanceEdgeTest extends TestCase
'updated_at' => now(),
]);
$this->postJson('/api/v1/finance/payments/' . $paymentId . '/allocate-installments', [])
$this->postJson('/api/v1/finance/payments/'.$paymentId.'/allocate-installments', [])
->assertOk()
->assertJsonPath('ok', true);
@@ -89,20 +89,20 @@ class ScenarioEFinanceEdgeTest extends TestCase
->assertOk()
->assertJsonPath('ok', true);
$this->postJson('/api/v1/finance/parent-payment-followups/' . $parent->id . '/note', [
$this->postJson('/api/v1/finance/parent-payment-followups/'.$parent->id.'/note', [
'invoice_id' => $newInvoiceId,
'school_year' => self::E2E_SCHOOL_YEAR,
'note' => 'Called parent about prior-year balance.',
'contact_method' => 'phone',
])->assertCreated()->assertJsonPath('ok', true);
$this->postJson('/api/v1/finance/parent-payment-followups/' . $parent->id . '/promise-to-pay', [
$this->postJson('/api/v1/finance/parent-payment-followups/'.$parent->id.'/promise-to-pay', [
'invoice_id' => $newInvoiceId,
'promise_to_pay_date' => '2025-10-15',
'promise_to_pay_amount' => 50,
])->assertCreated()->assertJsonPath('ok', true);
$this->postJson('/api/v1/finance/parent-payment-followups/' . $parent->id . '/resolve', [
$this->postJson('/api/v1/finance/parent-payment-followups/'.$parent->id.'/resolve', [
'invoice_id' => $newInvoiceId,
'note' => 'Balance plan agreed.',
])->assertCreated()->assertJsonPath('ok', true);
@@ -3,7 +3,6 @@
namespace Tests\Feature\Api\V1\Workflows;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
use Tests\Concerns\SeedsE2ETestFixtures;
use Tests\TestCase;
@@ -36,7 +36,7 @@ class ScenarioGPrintBadgeTest extends TestCase
$this->actingAs($admin, 'api');
foreach (['assigned', 'done', 'delivered'] as $status) {
$this->patchJson('/api/v1/print-requests/' . $requestId . '/status', [
$this->patchJson('/api/v1/print-requests/'.$requestId.'/status', [
'status' => $status,
])->assertOk();
}
@@ -46,7 +46,7 @@ class ScenarioGPrintBadgeTest extends TestCase
'status' => 'delivered',
]);
$badgeTag = 'E2E-BADGE-' . random_int(10000, 99999);
$badgeTag = 'E2E-BADGE-'.random_int(10000, 99999);
DB::table('users')->where('id', $teacher->id)->update(['rfid_tag' => $badgeTag]);
$this->postJson('/api/v1/badges/log-print', [
@@ -29,7 +29,7 @@ class ScenarioHSecurityUnauthorizedAccessTest extends TestCase
// Parent cannot update another family's student.
$this->actingAs($parentA, 'api');
$this->patchJson('/api/v1/parents/students/' . $world['student_id'], [
$this->patchJson('/api/v1/parents/students/'.$world['student_id'], [
'firstname' => 'Blocked',
'lastname' => 'Update',
'dob' => '2014-01-01',
@@ -26,6 +26,7 @@ class StudentEnrollmentWorkflowTest extends TestCase
use RefreshDatabase;
private const SCHOOL_YEAR = '2025-2026';
private const SEMESTER = 'Fall';
public function test_admin_creates_account_adds_student_and_enrolls_them(): void
@@ -127,14 +128,14 @@ class StudentEnrollmentWorkflowTest extends TestCase
]);
// The class roster endpoint reflects the assignment.
$classes = $this->getJson('/api/v1/students/' . $studentId . '/classes');
$classes = $this->getJson('/api/v1/students/'.$studentId.'/classes');
$classes->assertOk()->assertJsonPath('ok', true);
$assignedIds = array_column($classes->json('classes'), 'class_section_id');
$this->assertContains($classSectionId, $assignedIds);
// 5. Move the student to "enrolled" via the enrollment workflow.
$statusResponse = $this->post(
'/api/v1/administrator/enrollment-withdrawal/update-statuses?' .
'/api/v1/administrator/enrollment-withdrawal/update-statuses?'.
http_build_query(['enrollment_status' => [$studentId => 'enrolled']]),
[]
);
@@ -194,14 +195,14 @@ class StudentEnrollmentWorkflowTest extends TestCase
// First enrol...
$this->post(
'/api/v1/administrator/enrollment-withdrawal/update-statuses?' .
'/api/v1/administrator/enrollment-withdrawal/update-statuses?'.
http_build_query(['enrollment_status' => [$studentId => 'enrolled']]),
[]
)->assertOk();
// ...then withdraw.
$this->post(
'/api/v1/administrator/enrollment-withdrawal/update-statuses?' .
'/api/v1/administrator/enrollment-withdrawal/update-statuses?'.
http_build_query(['enrollment_status' => [$studentId => 'withdrawn']]),
[]
)->assertOk();
+1 -1
View File
@@ -104,7 +104,7 @@ class BulkUserRoleCreationTest extends TestCase
'firstname' => "Bulk{$name}",
'lastname' => "User{$number}",
'gender' => $index % 2 === 0 ? 'Female' : 'Male',
'cellphone' => '555' . str_pad((string) $index, 7, '0', STR_PAD_LEFT),
'cellphone' => '555'.str_pad((string) $index, 7, '0', STR_PAD_LEFT),
'email' => "bulk_api_{$roleName}_{$number}@example.test",
'address_street' => "{$index} Test Street",
'city' => 'Brooklyn',
@@ -2,9 +2,9 @@
namespace Tests\Feature\Middleware;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use App\Models\User;
use Illuminate\Support\Facades\Route;
use Tests\TestCase;
@@ -16,12 +16,12 @@ class SchoolYearAdminPageTest extends TestCase
parent::setUp();
$compiledPath = storage_path('framework/views');
if (!is_dir($compiledPath)) {
if (! is_dir($compiledPath)) {
mkdir($compiledPath, 0777, true);
}
config([
'app.key' => 'base64:' . base64_encode(random_bytes(32)),
'app.key' => 'base64:'.base64_encode(random_bytes(32)),
'app.cipher' => 'AES-256-CBC',
'jwt.secret' => bin2hex(random_bytes(32)),
'view.compiled' => $compiledPath,