assertInstanceOf(HTTPException_404::class, $e); $this->assertSame(404, $e->getCode()); } public function testFactory403ReturnsCorrectClass(): void { $e = HTTPException::factory(403); $this->assertInstanceOf(HTTPException_403::class, $e); $this->assertSame(403, $e->getCode()); } public function testFactoryWithMessage(): void { $e = HTTPException::factory(404, 'Страница не найдена'); $this->assertSame('Страница не найдена', $e->getMessage()); } public function testFactoryWithVariables(): void { $e = HTTPException::factory(404, 'Файл :name не найден', [':name' => 'test.html']); $this->assertSame('Файл test.html не найден', $e->getMessage()); } public function testFactoryUnknownCodeReturnsBaseClass(): void { $e = HTTPException::factory(418); $this->assertInstanceOf(HTTPException::class, $e); $this->assertSame(418, $e->getCode()); } public function testGetResponseReturns404Response(): void { $e = HTTPException::factory(404); $response = $e->getResponse(); $this->assertInstanceOf(Response::class, $response); $this->assertSame(404, $response->status()); } public function testGetResponseReturns403Response(): void { $e = HTTPException::factory(403); $response = $e->getResponse(); $this->assertInstanceOf(Response::class, $response); $this->assertSame(403, $response->status()); } public function testGetResponseBodyContainsHtml(): void { $e = HTTPException::factory(404); $body = $e->getResponse()->body(); $this->assertStringContainsString('404', $body); } public function testExtendsMyException(): void { $e = HTTPException::factory(404); $this->assertInstanceOf(\System\Classes\MyException::class, $e); } }