Skip to content

Commit 8c6b44b

Browse files
committed
feat!: remove multisession support
1 parent 9afc444 commit 8c6b44b

File tree

1 file changed

+1
-60
lines changed

1 file changed

+1
-60
lines changed

src/Codeception/Module/Yii2.php

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@
207207
* closeSessionOnRecreateApplication: bool,
208208
* applicationClass: class-string<\yii\base\Application>|null
209209
* }
210-
* @phpstan-type SessionBackup array{cookie: array<mixed>, session: array<mixed>, headers: array<string, string>, clientContext: array{ cookieJar: CookieJar, history: History }}
211210
* @phpstan-type ClientConfig array{
212211
* configFile: string,
213212
* responseCleanMethod: Yii2Connector::CLEAN_CLEAR|Yii2Connector::CLEAN_MANUAL|Yii2Connector::CLEAN_RECREATE,
@@ -218,7 +217,7 @@
218217
* applicationClass: class-string<\yii\base\Application>|null
219218
* }
220219
*/
221-
final class Yii2 extends Framework implements ActiveRecord, MultiSession, PartedModule
220+
final class Yii2 extends Framework implements ActiveRecord, PartedModule
222221
{
223222
/**
224223
* @var list<Yii2Connector\FixturesStore>
@@ -887,63 +886,5 @@ public function _afterSuite(): void
887886
$_SERVER = $this->server;
888887
}
889888

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-
}
919889

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-
}
949890
}

0 commit comments

Comments
 (0)