initialization
This commit is contained in:
commit
9ff09693ed
92 files changed
+46209
No files matched your search
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Api\OpenApiGenerator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class OpenApiGeneratorTest extends TestCase
|
||||
{
|
||||
public function testGenerateIncludesPublicApiRoutes(): void
|
||||
{
|
||||
$spec = OpenApiGenerator::generate('http://localhost:8080');
|
||||
|
||||
$this->assertSame('3.0.3', $spec['openapi']);
|
||||
$this->assertArrayHasKey('/api/v1/passwords', $spec['paths']);
|
||||
$this->assertArrayHasKey('/api/v1/passwords/generate', $spec['paths']);
|
||||
$this->assertArrayHasKey('/api/v1/health', $spec['paths']);
|
||||
$this->assertArrayHasKey('/api/v1/locales/{lang}', $spec['paths']);
|
||||
$this->assertSame('http://localhost:8080', $spec['servers'][0]['url']);
|
||||
|
||||
$this->assertSame('boolean', $spec['paths']['/api/v1/passwords']['get']['responses']['200']['content']['application/json']['schema']['properties']['success']['type']);
|
||||
$this->assertArrayHasKey('types', $spec['paths']['/api/v1/passwords']['get']['responses']['200']['content']['application/json']['schema']['properties']['data']['properties']);
|
||||
$this->assertSame('#/components/schemas/PasswordGenerationSuccess', $spec['paths']['/api/v1/passwords/generate']['post']['responses']['200']['content']['application/json']['schema']['$ref']);
|
||||
|
||||
$passwordResponseData = $spec['components']['schemas']['PasswordGenerationSuccess']['properties']['data']['properties'];
|
||||
$this->assertArrayHasKey('security_assessment', $passwordResponseData);
|
||||
$this->assertArrayHasKey('raw_technical_details', $passwordResponseData);
|
||||
$this->assertArrayHasKey('entropy_breakdown', $passwordResponseData['raw_technical_details']['properties']);
|
||||
|
||||
$localeEnum = $spec['paths']['/api/v1/locales/{lang}']['get']['parameters'][0]['schema']['enum'];
|
||||
$this->assertContains('ja', $localeEnum);
|
||||
$this->assertContains('de_CH', $localeEnum);
|
||||
$this->assertNotContains('js', $localeEnum);
|
||||
$this->assertNotContains('ch', $localeEnum);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user