request('GET', '/api/academic-years/current/grading-mode', [ 'headers' => [ 'Host' => 'localhost', 'Accept' => 'application/json', ], ]); self::assertResponseStatusCodeSame(404); } #[Test] public function configureGradingModeReturns404WithoutTenant(): void { $client = static::createClient(); $client->request('PUT', '/api/academic-years/current/grading-mode', [ 'headers' => [ 'Host' => 'localhost', 'Accept' => 'application/json', 'Content-Type' => 'application/json', ], 'json' => ['mode' => 'numeric_20'], ]); self::assertResponseStatusCodeSame(404); } // ========================================================================= // Security - Without authentication (with tenant) // ========================================================================= #[Test] public function getGradingModeReturns401WithoutAuthentication(): void { $client = static::createClient(); $client->request('GET', 'http://ecole-alpha.classeo.local/api/academic-years/current/grading-mode', [ 'headers' => [ 'Accept' => 'application/json', ], ]); self::assertResponseStatusCodeSame(401); } #[Test] public function configureGradingModeReturns401WithoutAuthentication(): void { $client = static::createClient(); $client->request('PUT', 'http://ecole-alpha.classeo.local/api/academic-years/current/grading-mode', [ 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', ], 'json' => ['mode' => 'numeric_20'], ]); self::assertResponseStatusCodeSame(401); } // ========================================================================= // Validation - Invalid mode // ========================================================================= #[Test] public function configureGradingModeRejectsInvalidModeWithoutTenant(): void { $client = static::createClient(); $client->request('PUT', '/api/academic-years/current/grading-mode', [ 'headers' => [ 'Host' => 'localhost', 'Accept' => 'application/json', 'Content-Type' => 'application/json', ], 'json' => ['mode' => 'invalid_mode'], ]); // Without tenant, returns 404 before validation kicks in self::assertResponseStatusCodeSame(404); } // ========================================================================= // Special identifiers - 'current', 'next', 'previous' // ========================================================================= #[Test] public function getGradingModeAcceptsCurrentIdentifier(): void { $client = static::createClient(); $client->request('GET', 'http://ecole-alpha.classeo.local/api/academic-years/current/grading-mode', [ 'headers' => ['Accept' => 'application/json'], ]); // 401 (no auth) not 404 (invalid id) — proves 'current' is accepted self::assertResponseStatusCodeSame(401); } #[Test] public function getGradingModeAcceptsNextIdentifier(): void { $client = static::createClient(); $client->request('GET', 'http://ecole-alpha.classeo.local/api/academic-years/next/grading-mode', [ 'headers' => ['Accept' => 'application/json'], ]); self::assertResponseStatusCodeSame(401); } #[Test] public function getGradingModeAcceptsPreviousIdentifier(): void { $client = static::createClient(); $client->request('GET', 'http://ecole-alpha.classeo.local/api/academic-years/previous/grading-mode', [ 'headers' => ['Accept' => 'application/json'], ]); self::assertResponseStatusCodeSame(401); } }