-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor: unpack Foundry 2 proxies (#160)
- un-deprecated unpacking Foundry 1 proxies
- Loading branch information
Showing
1 changed file
with
12 additions
and
5 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,8 @@ | |
use Zenstruck\Browser\Session\Driver\BrowserKitDriver; | ||
use Zenstruck\Callback\Parameter; | ||
use Zenstruck\Foundry\Factory; | ||
use Zenstruck\Foundry\Proxy; | ||
use Zenstruck\Foundry\Persistence\Proxy; | ||
use Zenstruck\Foundry\Proxy As LegacyProxy; | ||
|
||
/** | ||
* @author Kevin Bond <[email protected]> | ||
|
@@ -138,11 +139,14 @@ public function actingAs(object $user, ?string $firewall = null): self | |
$user = $user->create(); // @phpstan-ignore-line | ||
} | ||
|
||
if ($user instanceof Proxy) { // @phpstan-ignore-line | ||
trigger_deprecation('zenstruck/browser', '1.9', 'Passing a Proxy to actingAs() is deprecated, pass the real object instead.'); | ||
if ($user instanceof LegacyProxy) { // @phpstan-ignore-line | ||
$user = $user->object(); // @phpstan-ignore-line | ||
} | ||
|
||
if ($user instanceof Proxy) { // @phpstan-ignore-line | ||
$user = $user->_real(); // @phpstan-ignore-line | ||
} | ||
|
||
if (!$user instanceof UserInterface) { | ||
throw new \LogicException(\sprintf('%s() requires the user be an instance of %s.', __METHOD__, UserInterface::class)); | ||
} | ||
|
@@ -178,11 +182,14 @@ public function assertAuthenticated($as = null): self | |
$as = $as->create(); // @phpstan-ignore-line | ||
} | ||
|
||
if ($as instanceof Proxy) { // @phpstan-ignore-line | ||
trigger_deprecation('zenstruck/browser', '1.9', 'Passing a Proxy to assertAuthenticated() is deprecated, pass the real object instead.'); | ||
if ($as instanceof LegacyProxy) { // @phpstan-ignore-line | ||
$as = $as->object(); // @phpstan-ignore-line | ||
} | ||
|
||
if ($as instanceof Proxy) { // @phpstan-ignore-line | ||
$as = $as->_real(); // @phpstan-ignore-line | ||
} | ||
|
||
if ($as instanceof UserInterface) { | ||
$as = $as->getUserIdentifier(); | ||
} | ||
|