assertEquals($expected, $context->resolveRelativeUri($referencedUri)); } public function normalizeUriProvider() { $data = [ [ 'https://example.com/openapi.yaml', 'https://example.com/openapi.yaml', ], [ 'https://example.com/openapi.yaml#/components/Pet', 'https://example.com/openapi.yaml#/components/Pet', ], [ 'https://example.com/./openapi.yaml', 'https://example.com/openapi.yaml', ], [ 'https://example.com/./openapi.yaml#/components/Pet', 'https://example.com/openapi.yaml#/components/Pet', ], [ 'https://example.com/api/../openapi.yaml', 'https://example.com/openapi.yaml', ], [ 'https://example.com/api/../openapi.yaml#/components/Pet', 'https://example.com/openapi.yaml#/components/Pet', ], [ 'https://example.com/../openapi.yaml', 'https://example.com/../openapi.yaml', ], [ 'https://example.com/../openapi.yaml#/components/Pet', 'https://example.com/../openapi.yaml#/components/Pet', ], [ '/definitions.yaml', 'file:///definitions.yaml', ], [ '/definitions.yaml#/components/Pet', 'file:///definitions.yaml#/components/Pet', ], [ '/var/www/definitions.yaml', 'file:///var/www/definitions.yaml', ], [ '/var/www/definitions.yaml#/components/Pet', 'file:///var/www/definitions.yaml#/components/Pet', ], [ '/var/www/api/../definitions.yaml', 'file:///var/www/definitions.yaml', ], [ '/var/www/api/../definitions.yaml#/components/Pet', 'file:///var/www/definitions.yaml#/components/Pet', ], [ '/var/www/api/foo/../../definitions.yaml#/components/Pet', 'file:///var/www/definitions.yaml#/components/Pet', ], ]; return $data; } /** * @dataProvider normalizeUriProvider */ public function testNormalizeUri($uri, $expected) { $context = new ReferenceContext(null, $uri); $this->assertEquals($expected, $context->getUri()); } }