assertSame('ContextTest', $context->class); $this->assertSame('\OpenApi\Tests\ContextTest', $context->fullyQualifiedName($context->class)); $this->assertSame('testDetect', $context->method); $this->assertSame(__FILE__, $context->filename); $this->assertSame($line, $context->line); $this->assertSame('OpenApi\Tests', $context->namespace); } public function testFullyQualifiedName() { $this->assertOpenApiLogEntryContains('Required @OA\PathItem() not found'); $openapi = Generator::scan([__DIR__ . '/Fixtures/Customer.php']); $context = $openapi->components->schemas[0]->_context; // resolve with namespace $this->assertSame('\FullyQualified', $context->fullyQualifiedName('\FullyQualified')); $this->assertSame('\OpenApi\Tests\Fixtures\Unqualified', $context->fullyQualifiedName('Unqualified')); $this->assertSame('\OpenApi\Tests\Fixtures\Namespace\Qualified', $context->fullyQualifiedName('Namespace\Qualified')); // respect use statements $this->assertSame('\Exception', $context->fullyQualifiedName('Exception')); $this->assertSame('\OpenApi\Tests\Fixtures\Customer', $context->fullyQualifiedName('Customer')); $this->assertSame('\OpenApi\Logger', $context->fullyQualifiedName('Logger')); $this->assertSame('\OpenApi\Logger', $context->fullyQualifiedName('lOgGeR')); // php has case-insensitive class names :-( $this->assertSame('\OpenApi\Logger', $context->fullyQualifiedName('OpenApiLogger')); $this->assertSame('\OpenApi\Annotations\QualifiedAlias', $context->fullyQualifiedName('OA\QualifiedAlias')); } public function testPhpdocContent() { $singleLine = new Context(['comment' => <<assertEquals('A single line.', $singleLine->phpdocContent()); $multiline = new Context(['comment' => <<assertEquals("A description spread across\nmultiple lines.\n\neven blank lines", $multiline->phpdocContent()); $escapedLinebreak = new Context(['comment' => <<assertEquals('A single line spread across multiple lines.', $escapedLinebreak->phpdocContent()); } /** * https://phpdoc.org/docs/latest/guides/docblocks.html. */ public function testPhpdocSummaryAndDescription() { $single = new Context(['comment' => '/** This is a single line DocComment. */']); $this->assertEquals('This is a single line DocComment.', $single->phpdocContent()); $multi = new Context(['comment' => "/**\n * This is a multi-line DocComment.\n */"]); $this->assertEquals('This is a multi-line DocComment.', $multi->phpdocContent()); $emptyWhiteline = new Context(['comment' => <<assertEquals('This is a summary', $emptyWhiteline->phpdocSummary()); $periodNewline = new Context(['comment' => <<assertEquals('This is a summary.', $periodNewline->phpdocSummary()); $multilineSummary = new Context(['comment' => <<