OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
API
/
vendor
/
zircote
/
swagger-php
/
tests
/
Processors
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/07/2024 04:34:33 AM
rwxr-xr-x
📄
AugmentParametersTest.php
1.76 KB
08/07/2024 04:34:32 AM
rw-r--r--
📄
AugmentPropertiesTest.php
11.86 KB
08/07/2024 04:34:32 AM
rw-r--r--
📄
AugmentRefsTest.php
1.17 KB
08/07/2024 04:34:32 AM
rw-r--r--
📄
AugmentRequestBodyTest.php
1.09 KB
08/07/2024 04:34:32 AM
rw-r--r--
📄
AugmentSchemasTest.php
2.18 KB
08/07/2024 04:34:32 AM
rw-r--r--
📄
BuildPathsTest.php
1.86 KB
08/07/2024 04:34:32 AM
rw-r--r--
📄
CleanUnmergedTest.php
2.89 KB
08/07/2024 04:34:33 AM
rw-r--r--
📄
CleanUnusedComponentsTest.php
1.22 KB
08/07/2024 04:34:33 AM
rw-r--r--
📄
DocBlockDescriptionsTest.php
3.74 KB
08/07/2024 04:34:33 AM
rw-r--r--
📄
ExpandClassesTest.php
8.86 KB
08/07/2024 04:34:33 AM
rw-r--r--
📄
ExpandEnumsTest.php
6.13 KB
08/07/2024 04:34:33 AM
rw-r--r--
📄
MergeIntoComponentsTest.php
1 KB
08/07/2024 04:34:33 AM
rw-r--r--
📄
MergeIntoOpenApiTest.php
1007 bytes
08/07/2024 04:34:33 AM
rw-r--r--
📄
MergeJsonContentTest.php
4.2 KB
08/07/2024 04:34:33 AM
rw-r--r--
📄
MergeXmlContentTest.php
4.13 KB
08/07/2024 04:34:33 AM
rw-r--r--
📄
OperationIdTest.php
1.57 KB
08/07/2024 04:34:33 AM
rw-r--r--
Editing: CleanUnmergedTest.php
Close
<?php declare(strict_types=1); /** * @license Apache 2.0 */ namespace OpenApi\Tests\Processors; use OpenApi\Analysis; use OpenApi\Annotations as OA; use OpenApi\Processors\CleanUnmerged; use OpenApi\Processors\MergeIntoOpenApi; use OpenApi\Tests\OpenApiTestCase; class CleanUnmergedTest extends OpenApiTestCase { public function testCleanUnmergedProcessor(): void { $comment = <<<END @OA\Info( title="Info only has one contact field.", version="test", ) @OA\PathItem(path="/test"), @OA\License( name="MIT", @OA\Contact( name="Batman" ) ) END; $analysis = new Analysis($this->annotationsFromDocBlockParser($comment), $this->getContext()); $this->assertCount(4, $analysis->annotations); $analysis->process([new MergeIntoOpenApi()]); $this->assertCount(5, $analysis->annotations); $before = $analysis->split(); $this->assertCount(3, $before->merged->annotations, 'Generated @OA\OpenApi, @OA\PathItem and @OA\Info'); $this->assertCount(2, $before->unmerged->annotations, '@OA\License + @OA\Contact'); $this->assertCount(0, $analysis->openapi->_unmerged); $analysis->validate(); // Validation fails to detect the unmerged annotations. // CleanUnmerged should place the unmerged annotions into the swagger->_unmerged array. $analysis->process([new CleanUnmerged()]); $between = $analysis->split(); $this->assertCount(3, $between->merged->annotations, 'Generated @OA\OpenApi, @OA\PathItem and @OA\Info'); $this->assertCount(2, $between->unmerged->annotations, '@OA\License + @OA\Contact'); $this->assertCount(2, $analysis->openapi->_unmerged); // 1 would also be oke, Could a'Only the @OA\License' $this->assertOpenApiLogEntryContains('Unexpected @OA\License(), expected to be inside @OA\Info in '); $this->assertOpenApiLogEntryContains('Unexpected @OA\Contact(), expected to be inside @OA\Info in '); $analysis->validate(); // When a processor places a previously unmerged annotation into the swagger obect. $license = $analysis->getAnnotationsOfType(OA\License::class)[0]; /** @var OA\Contact $contact */ $contact = $analysis->getAnnotationsOfType(OA\Contact::class)[0]; $analysis->openapi->info->contact = $contact; $this->assertCount(1, $license->_unmerged); $analysis->process([new CleanUnmerged()]); $this->assertCount(0, $license->_unmerged); $after = $analysis->split(); $this->assertCount(4, $after->merged->annotations, 'Generated @OA\OpenApi, @OA\PathItem, @OA\Info and @OA\Contact'); $this->assertCount(1, $after->unmerged->annotations, '@OA\License'); $this->assertCount(1, $analysis->openapi->_unmerged); $this->assertOpenApiLogEntryContains('Unexpected @OA\License(), expected to be inside @OA\Info in '); $analysis->validate(); } }