feat: add unit tests for OpenApiController to validate YAML and JSON responses
All checks were successful
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 2m34s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 2m37s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 2m30s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 2m39s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 2m43s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 2m19s

This commit is contained in:
2025-12-01 11:30:46 -05:00
parent 88098837a3
commit c91f35c0b1

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace Siteworxpro\Tests\Controllers;
use Siteworxpro\App\Controllers\OpenApiController;
class OpenApiControllerTest extends ControllerTest
{
public function testBuildsYaml(): void
{
$request = $this->getMockRequest('/.well-known/openapi.yaml');
$controller = new OpenApiController();
$response = $controller->get($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertStringContainsString('openapi: 3.0.0', (string)$response->getBody());
}
public function testBuildsJson(): void
{
$request = $this->getMockRequest(uri: '/.well-known/openapi.json');
$controller = new OpenApiController();
$response = $controller->get($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('application/json', $response->getHeaderLine('Content-Type'));
$this->assertNotFalse(json_decode($response->getBody()->getContents()));
}
}