Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkaOnLine committed Aug 28, 2024
1 parent 064e674 commit 396d9d2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 0 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
requireCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
stopOnFailure="false"
cacheDirectory=".phpunit.cache"
>
Expand Down
4 changes: 2 additions & 2 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
function swagger_ui_dist_path(string $documentation, $asset = null)
{
$allowed_files = [
$allowedFiles = [
'favicon-16x16.png',
'favicon-32x32.png',
'oauth2-redirect.html',
Expand All @@ -37,7 +37,7 @@ function swagger_ui_dist_path(string $documentation, $asset = null)
return realpath($path);
}

if (! in_array($asset, $allowed_files)) {
if (! in_array($asset, $allowedFiles, true)) {
throw new L5SwaggerException(sprintf('(%s) - this L5 Swagger asset is not allowed', $asset));
}

Expand Down
4 changes: 4 additions & 0 deletions tests/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Illuminate\Http\Request;
use L5Swagger\Exceptions\L5SwaggerException;
use L5Swagger\Generator;
use L5Swagger\GeneratorFactory;
use L5Swagger\L5SwaggerServiceProvider;
use OpenApi\Analysers\TokenAnalyser;
use OpenApi\Processors\CleanUnmerged;
use PHPUnit\Framework\Attributes\CoversClass;
Expand All @@ -16,7 +18,9 @@
* @covers \L5Swagger\Generator
*/
#[TestDox('Generator')]
#[CoversClass(GeneratorFactory::class)]
#[CoversClass(Generator::class)]
#[CoversClass(L5SwaggerServiceProvider::class)]
class GeneratorTest extends TestCase
{
/**
Expand Down
3 changes: 3 additions & 0 deletions tests/HelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
namespace Tests;

use L5Swagger\Exceptions\L5SwaggerException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\CoversFunction;
use PHPUnit\Framework\Attributes\TestDox;

/**
* @covers L5SwaggerException
*/
#[TestDox('Helpers')]
#[CoversClass(L5SwaggerException::class)]
#[CoversFunction('l5_swagger_asset')]
#[CoversFunction('swagger_ui_dist_path')]
class HelpersTest extends TestCase
{
public function testAssetFunctionThrowsExceptionIfFileDoesNotExists(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/RoutesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use L5Swagger\GeneratorFactory;
use L5Swagger\Http\Controllers\SwaggerAssetController;
use L5Swagger\Http\Controllers\SwaggerController;
use L5Swagger\Http\Middleware\Config;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\MockObject\Exception;
Expand All @@ -18,6 +19,8 @@
#[TestDox('Routes')]
#[CoversClass(SwaggerController::class)]
#[CoversClass(SwaggerAssetController::class)]
#[CoversClass(Config::class)]
#[CoversClass(L5SwaggerException::class)]
class RoutesTest extends TestCase
{
public function testUserCantAccessJsonFileIfItIsNotGenerated(): void
Expand Down

0 comments on commit 396d9d2

Please sign in to comment.