-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows to disable redirect to
favicon.ico
logic (#121)
* Allows to disable `redirect_favicon_ico` * Update RedirectStaticAssets.php * Update RedirectStaticAssetsTest.php Co-authored-by: Taylor Otwell <[email protected]>
- Loading branch information
1 parent
c558f64
commit 517704a
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Laravel\Vapor\Tests\Feature; | ||
|
||
use Illuminate\Support\Facades\Route; | ||
use Laravel\Vapor\Runtime\Http\Middleware\RedirectStaticAssets; | ||
use Laravel\Vapor\VaporServiceProvider; | ||
use Orchestra\Testbench\TestCase; | ||
|
||
class RedirectStaticAssetsTest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$_ENV['ASSET_URL'] = 'https://asset-url.com'; | ||
|
||
Route::get('/favicon.ico', function () { | ||
return 'My own favicon.'; | ||
})->middleware(RedirectStaticAssets::class); | ||
} | ||
|
||
protected function getPackageProviders($app): array | ||
{ | ||
return [ | ||
VaporServiceProvider::class, | ||
]; | ||
} | ||
|
||
public function test_redirects_to_favicon_ico() | ||
{ | ||
$response = $this->get('/favicon.ico'); | ||
$response->assertStatus(302)->assertRedirect('https://asset-url.com/favicon.ico'); | ||
|
||
config()->set('vapor.redirect_favicon', false); | ||
|
||
$response = $this->get('/favicon.ico'); | ||
$response->assertStatus(200)->assertSee('My own favicon.'); | ||
} | ||
} |