Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkaOnLine committed Aug 30, 2024
1 parent 80c3f2f commit d9531ef
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@
<include>
<directory suffix=".php">src/</directory>
</include>
<exclude>
<file>src/routes.php</file>
</exclude>
</source>
</phpunit>
34 changes: 34 additions & 0 deletions tests/RoutesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tests;

use Illuminate\Http\Request;
use L5Swagger\Exceptions\L5SwaggerException;
use L5Swagger\Generator;
use L5Swagger\GeneratorFactory;
Expand Down Expand Up @@ -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());

Check notice on line 198 in tests/RoutesTest.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

tests/RoutesTest.php#L198

Avoid using static access to class '\Illuminate\Http\Request' in method 'testUserCanAccessDocumentationInterfaceAndConfigureProxy'.

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());

Check notice on line 209 in tests/RoutesTest.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

tests/RoutesTest.php#L209

Avoid using static access to class '\Illuminate\Http\Request' in method 'testUserCanAccessDocumentationInterfaceAndConfigureProxy'.
}

/**
* @throws L5SwaggerException
*/
Expand Down

0 comments on commit d9531ef

Please sign in to comment.