From d9531ef96254fe09345789648c2420abae8aff69 Mon Sep 17 00:00:00 2001 From: Darius Matulionis Date: Fri, 30 Aug 2024 16:19:53 +0300 Subject: [PATCH] update tests --- phpunit.xml | 3 +++ tests/RoutesTest.php | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/phpunit.xml b/phpunit.xml index 378379b..07bcfb7 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -24,5 +24,8 @@ src/ + + src/routes.php + diff --git a/tests/RoutesTest.php b/tests/RoutesTest.php index 70ce789..61f383f 100644 --- a/tests/RoutesTest.php +++ b/tests/RoutesTest.php @@ -2,6 +2,7 @@ namespace Tests; +use Illuminate\Http\Request; use L5Swagger\Exceptions\L5SwaggerException; use L5Swagger\Generator; use L5Swagger\GeneratorFactory; @@ -175,6 +176,39 @@ public function testUserCanAccessDocumentationInterface(): void ->isOk(); } + /** + * @throws L5SwaggerException + */ + public function testUserCanAccessDocumentationInterfaceAndConfigureProxy(): void + { + config(['l5-swagger' => [ + 'default' => 'default', + 'documentations' => config('l5-swagger.documentations'), + 'defaults' => array_merge(config('l5-swagger.defaults'), ['proxy' => ['foo', 'bar']]), + ]]); + + $config = $this->configFactory->documentationConfig(); + $jsonFile = $config['paths']['docs_json'] ?? 'api-docs.json'; + + $this->get($config['routes']['api']) + ->assertSee(route('l5-swagger.default.docs', $jsonFile)) + ->assertSee(route('l5-swagger.default.oauth2_callback')) + ->isOk(); + + $this->assertSame(['foo', 'bar'], Request::getTrustedProxies()); + + config(['l5-swagger' => [ + 'default' => 'default', + 'documentations' => config('l5-swagger.documentations'), + 'defaults' => array_merge(config('l5-swagger.defaults'), ['proxy' => 'baz']), + ]]); + + $this->get($config['routes']['api']) + ->isOk(); + + $this->assertSame(['baz'], Request::getTrustedProxies()); + } + /** * @throws L5SwaggerException */