|
13 | 13 | use Codeception\Lib\Connector\Yii2\TransactionForcer;
|
14 | 14 | use Codeception\Lib\Framework;
|
15 | 15 | use Codeception\Lib\Interfaces\ActiveRecord;
|
16 |
| -use Codeception\Lib\Interfaces\MultiSession; |
17 | 16 | use Codeception\Lib\Interfaces\PartedModule;
|
18 | 17 | use Codeception\TestInterface;
|
19 | 18 | use PHPUnit\Framework\Assert;
|
20 | 19 | use ReflectionClass;
|
21 | 20 | use RuntimeException;
|
22 |
| -use Symfony\Component\BrowserKit\CookieJar; |
23 |
| -use Symfony\Component\BrowserKit\History; |
24 | 21 | use Yii;
|
25 | 22 | use yii\base\Security;
|
26 | 23 | use yii\db\ActiveQueryInterface;
|
|
29 | 26 | use yii\mail\BaseMessage;
|
30 | 27 | use yii\mail\MessageInterface;
|
31 | 28 | use yii\test\Fixture;
|
32 |
| -use yii\web\Application as WebApplication; |
33 | 29 | use yii\web\IdentityInterface;
|
34 | 30 |
|
35 | 31 | /**
|
|
207 | 203 | * closeSessionOnRecreateApplication: bool,
|
208 | 204 | * applicationClass: class-string<\yii\base\Application>|null
|
209 | 205 | * }
|
210 |
| - * @phpstan-type SessionBackup array{cookie: array<mixed>, session: array<mixed>, headers: array<string, string>, clientContext: array{ cookieJar: CookieJar, history: History }} |
211 | 206 | * @phpstan-type ClientConfig array{
|
212 | 207 | * configFile: string,
|
213 | 208 | * responseCleanMethod: Yii2Connector::CLEAN_CLEAR|Yii2Connector::CLEAN_MANUAL|Yii2Connector::CLEAN_RECREATE,
|
|
218 | 213 | * applicationClass: class-string<\yii\base\Application>|null
|
219 | 214 | * }
|
220 | 215 | */
|
221 |
| -final class Yii2 extends Framework implements ActiveRecord, MultiSession, PartedModule |
| 216 | +final class Yii2 extends Framework implements ActiveRecord, PartedModule |
222 | 217 | {
|
223 | 218 | /**
|
224 | 219 | * @var list<Yii2Connector\FixturesStore>
|
@@ -886,64 +881,4 @@ public function _afterSuite(): void
|
886 | 881 |
|
887 | 882 | $_SERVER = $this->server;
|
888 | 883 | }
|
889 |
| - |
890 |
| - /** |
891 |
| - * Initialize an empty session. Implements MultiSession. |
892 |
| - */ |
893 |
| - public function _initializeSession(): void |
894 |
| - { |
895 |
| - $this->getClient()->restart(); |
896 |
| - $this->headers = []; |
897 |
| - $_SESSION = []; |
898 |
| - $_COOKIE = []; |
899 |
| - } |
900 |
| - |
901 |
| - /** |
902 |
| - * Return the session content for future restoring. Implements MultiSession. |
903 |
| - * |
904 |
| - * @return SessionBackup |
905 |
| - */ |
906 |
| - public function _backupSession(): array |
907 |
| - { |
908 |
| - if (Yii::$app instanceof WebApplication && Yii::$app->has('session', true) && Yii::$app->session->useCustomStorage) { |
909 |
| - throw new ModuleException($this, "Yii2 MultiSession only supports the default session backend."); |
910 |
| - } |
911 |
| - return [ |
912 |
| - 'clientContext' => $this->getClient()->getContext(), |
913 |
| - 'headers' => $this->headers, |
914 |
| - // @phpstan-ignore nullCoalesce.variable |
915 |
| - 'cookie' => $_COOKIE ?? [], |
916 |
| - 'session' => $_SESSION ?? [], |
917 |
| - ]; |
918 |
| - } |
919 |
| - |
920 |
| - /** |
921 |
| - * Restore a session. Implements MultiSession. |
922 |
| - * |
923 |
| - * @param SessionBackup $session output of _backupSession() |
924 |
| - */ |
925 |
| - public function _loadSession($session): void |
926 |
| - { |
927 |
| - $this->getClient()->setContext($session['clientContext']); |
928 |
| - $this->headers = $session['headers']; |
929 |
| - $_SESSION = $session['session']; |
930 |
| - $_COOKIE = $session['cookie']; |
931 |
| - $app = Yii::$app; |
932 |
| - if ($app?->has('user', true)) { |
933 |
| - $definitions = $app->getComponents(); |
934 |
| - $app->set('user', $definitions['user']); |
935 |
| - } |
936 |
| - } |
937 |
| - |
938 |
| - /** |
939 |
| - * Close and dump a session. Implements MultiSession. |
940 |
| - * |
941 |
| - * @param mixed $session |
942 |
| - */ |
943 |
| - public function _closeSession($session = null): void |
944 |
| - { |
945 |
| - if (! $session) { |
946 |
| - $this->_initializeSession(); |
947 |
| - } |
948 |
| - } |
949 | 884 | }
|
0 commit comments