Skip to content

Commit

Permalink
Fix route
Browse files Browse the repository at this point in the history
  • Loading branch information
guanguans committed Jun 2, 2023
1 parent 443633e commit 6d286b4
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 12 deletions.
2 changes: 1 addition & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
static function (Router $router): void {
$router->get('assets/stylesheets', 'AssetController@css')->name('assets.css');
$router->get('assets/javascript', 'AssetController@js')->name('assets.js');
$router->get('fonts/FontAwesome.otf', 'AssetController@js')->name('assets.font');
$router->get('fonts/fontawesome-webfont.{suffix}', 'AssetController@font')->name('assets.webfont');
$router->get('fonts/FontAwesome.otf', 'AssetController@fontAwesome')->name('assets.font');
}
);
6 changes: 4 additions & 2 deletions src/Http/Controllers/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public function css(): Response
*/
public function font(string $suffix): Response
{
$file = base_path("vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/font-awesome/fonts/fontawesome-webfont.$suffix");
// $file = base_path("vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/font-awesome/fonts/fontawesome-webfont.$suffix");
$file = __DIR__."/../../../vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/font-awesome/fonts/fontawesome-webfont.$suffix";
$response = new Response(file_get_contents($file), 200, ['Content-Type' => 'text/font']);

return $this->cacheResponse($response);
Expand All @@ -68,7 +69,8 @@ public function font(string $suffix): Response
*/
public function fontAwesome(): Response
{
$file = base_path('vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/font-awesome/fonts/FontAwesome.otf');
// $file = base_path('vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/font-awesome/fonts/FontAwesome.otf');
$file = __DIR__.'/../../../vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/font-awesome/fonts/FontAwesome.otf';
$response = new Response(file_get_contents($file), 200, ['Content-Type' => 'text/font']);

return $this->cacheResponse($response);
Expand Down
10 changes: 5 additions & 5 deletions tests/BootstrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@

it('can return `bool` for `isBooted`', function (): void {
expect($this->bootstrapper)->isBooted()->toBeBool();
});
})->group(__DIR__, __FILE__);

it('can boot `soar score` for `boot`', function (): void {
expect($this->bootstrapper)->boot()->toBeNull();
});
})->group(__DIR__, __FILE__);

it('can get `scores` for `getScores`', function (): void {
expect($this->bootstrapper->getScores())->toBeCollection();
});
})->group(__DIR__, __FILE__);

it('can sanitize `explain` for `sanitizeExplain`', function (): void {
$explain = [
Expand All @@ -44,7 +44,7 @@
$sanitizeExplain = fn (array $explain): array => $this->sanitizeExplain($explain);

expect($sanitizeExplain->call($this->bootstrapper, $explain))->toBeArray();
});
})->group(__DIR__, __FILE__);

it('can to `human time` for `toHumanTime`', function (): void {
$toHumanTime = fn (float $milliseconds): string => $this->toHumanTime($milliseconds);
Expand All @@ -54,4 +54,4 @@
$toHumanTime->call($this->bootstrapper, 100),
$toHumanTime->call($this->bootstrapper, 10000),
])->each->toBeString()->toEndWith('s');
});
})->group(__DIR__, __FILE__);
8 changes: 4 additions & 4 deletions tests/FeatureTest.php → tests/Feature/FeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* This source file is subject to the MIT license that is bundled.
*/

namespace Tests;
namespace Tests\Feature;

it('console output', function (): void {
$response = $this->get('/html');
Expand All @@ -21,7 +21,7 @@
$response->assertSee('IndexRules');
$response->assertSee('Explain');
$response->assertSee('Backtraces');
});
})->group(__DIR__, __FILE__);

it('json output', function (): void {
$response = $this->get('/json');
Expand All @@ -33,7 +33,7 @@
$response->assertSee('IndexRules');
$response->assertSee('Explain');
$response->assertSee('Backtraces');
});
})->group(__DIR__, __FILE__);

it('soar bar output', function (): void {
$response = $this->get('/html');
Expand All @@ -44,4 +44,4 @@
$response->assertSee('IndexRules');
$response->assertSee('Explain');
$response->assertSee('Backtraces');
});
})->group(__DIR__, __FILE__);
29 changes: 29 additions & 0 deletions tests/Feature/HttpTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

/**
* This file is part of the guanguans/laravel-soar.
*
* (c) guanguans <ityaozm@gmail.com>
*
* This source file is subject to the MIT license that is bundled.
*/

namespace Tests\Feature;

it('can request `assets/javascript`', function (): void {
$this->get('soar-bar/assets/javascript')->assertSuccessful();
})->group(__DIR__, __FILE__);

it('can request `assets/stylesheets`', function (): void {
$this->get('soar-bar/assets/stylesheets')->assertSuccessful();
})->group(__DIR__, __FILE__);

it('can request `fonts/fontawesome-webfont.{suffix}`', function (): void {
$this->get('soar-bar/fonts/fontawesome-webfont.svg')->assertSuccessful();
})->group(__DIR__, __FILE__);

it('can request `fonts/FontAwesome.otf`', function (): void {
$this->get('soar-bar/fonts/FontAwesome.otf')->assertSuccessful();
})->group(__DIR__, __FILE__);

0 comments on commit 6d286b4

Please sign in to comment.