mockRequest('GET', '/api/employees'); $controller = $this->createMock(EmployeeController::class); $controller->expects($this->once())->method('index'); $controller->expects($this->never())->method('show'); $this->captureDispatch($controller); } public function testGetEmployeesTrailingSlash(): void { $this->mockRequest('GET', '/api/employees/'); $controller = $this->createMock(EmployeeController::class); $controller->expects($this->once())->method('index'); $this->captureDispatch($controller); } public function testGetEmployeeBySlugRoutesToShow(): void { $this->mockRequest('GET', '/api/employees/talos'); $controller = $this->createMock(EmployeeController::class); $controller->expects($this->once())->method('show')->with('talos'); $this->captureDispatch($controller); } public function testPostMethodReturns405(): void { $this->mockRequest('POST', '/api/employees'); $output = $this->captureDispatch(); $json = json_decode($output, true); $this->assertFalse($json['success']); $this->assertStringContainsString('Method not allowed', $json['error']); } public function testOptionsReturnsCorsHeaders(): void { $this->mockRequest('OPTIONS', '/api/employees'); $output = $this->captureDispatch(); // OPTIONS should return empty body $this->assertEmpty($output); } public function testUnknownRouteReturns404(): void { $this->mockRequest('GET', '/api/unknown'); $output = $this->captureDispatch(); $json = json_decode($output, true); $this->assertFalse($json['success']); $this->assertStringContainsString('not found', $json['error']); } public function testSlugWithQueryString(): void { $this->mockRequest('GET', '/api/employees/daedalus?format=full'); $controller = $this->createMock(EmployeeController::class); $controller->expects($this->once())->method('show')->with('daedalus'); $this->captureDispatch($controller); } }