-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[6.x] Add fallback when facade root accessor has previously been reso…
…lved. (#30616) * [6.x] Add fallback when facade root accessor has previously been resolved. Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * Use === true and reuse declared variable. Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * Fixes StyleCI Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
- Loading branch information
1 parent
899b8c3
commit 9afd29d
Showing
2 changed files
with
49 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,42 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Support; | ||
|
||
use Illuminate\Support\Facades\Auth; | ||
use Orchestra\Testbench\TestCase; | ||
|
||
class FacadesTest extends TestCase | ||
{ | ||
protected function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
|
||
unset($_SERVER['__laravel.authResolved']); | ||
} | ||
|
||
public function testFacadeResolvedCanResolveCallback() | ||
{ | ||
Auth::resolved(function () { | ||
$_SERVER['__laravel.authResolved'] = true; | ||
}); | ||
|
||
$this->assertFalse(isset($_SERVER['__laravel.authResolved'])); | ||
|
||
$this->app->make('auth'); | ||
|
||
$this->assertTrue(isset($_SERVER['__laravel.authResolved'])); | ||
} | ||
|
||
public function testFacadeResolvedCanResolveCallbackAfterAccessRootHasBeenResolved() | ||
{ | ||
$this->app->make('auth'); | ||
|
||
$this->assertFalse(isset($_SERVER['__laravel.authResolved'])); | ||
|
||
Auth::resolved(function () { | ||
$_SERVER['__laravel.authResolved'] = true; | ||
}); | ||
|
||
$this->assertTrue(isset($_SERVER['__laravel.authResolved'])); | ||
} | ||
} |