Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkaOnLine committed Sep 3, 2024
1 parent b95fb31 commit 7314605
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions tests/HelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tests;

use Illuminate\Support\Facades\Storage;
use L5Swagger\Exceptions\L5SwaggerException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\CoversFunction;
Expand All @@ -16,10 +17,40 @@
#[CoversFunction('swagger_ui_dist_path')]
class HelpersTest extends TestCase
{
public function testAssetFunctionThrowsExceptionIfFileDoesNotExists(): void
public function testAssetFunctionReturnsRoute(): void
{
$path = l5_swagger_asset('default', 'swagger-ui.js');

$this->assertStringContainsString('http://localhost/docs/asset/swagger-ui.js?v=', $path);
}

/**
* @throws L5SwaggerException
*/
public function testGeneratesBasePathForAssetsThrowsExceptionIfFileIsNotAllowed(): void
{
$this->expectException(L5SwaggerException::class);

l5_swagger_asset('default', 'asdasd');
swagger_ui_dist_path('default', 'foo.bar');
}

/**
* @throws L5SwaggerException
*/
public function testGeneratesBasePathForAssets(): void
{
$path = swagger_ui_dist_path('default');

$this->assertStringContainsString('swagger-api/swagger-ui/dist', $path);
}

/**
* @throws L5SwaggerException
*/
public function testGeneratesAssetPathForAssets(): void
{
$path = swagger_ui_dist_path('default', 'swagger-ui.js');

$this->assertStringContainsString('swagger-api/swagger-ui/dist/swagger-ui.js', $path);
}
}

0 comments on commit 7314605

Please sign in to comment.