Skip to content

Commit dc4ce15

Browse files
committed
Fix PR comments
1 parent 66cc4fc commit dc4ce15

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/Codeception/Lib/Connector/Yii2.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Codeception\Lib\Connector\Yii2\Logger;
99
use Codeception\Lib\Connector\Yii2\TestMailer;
1010
use Codeception\Util\Debug;
11+
use InvalidArgumentException;
1112
use Symfony\Component\BrowserKit\AbstractBrowser as Client;
1213
use Symfony\Component\BrowserKit\Cookie;
1314
use Symfony\Component\BrowserKit\CookieJar;
@@ -521,7 +522,7 @@ protected function resetResponse(Application $app): void
521522
self::CLEAN_FORCE_RECREATE, self::CLEAN_RECREATE => $app->set('response', $app->getComponents()['response']),
522523
self::CLEAN_CLEAR => $app->response->clear(),
523524
self::CLEAN_MANUAL => null,
524-
default => throw new \InvalidArgumentException("Unknown method: $method"),
525+
default => throw new InvalidArgumentException("Unknown method: $method"),
525526
};
526527
}
527528

@@ -558,7 +559,7 @@ protected function resetRequest(Application $app): void
558559
$request->setAcceptableLanguages(null);
559560
})(),
560561
self::CLEAN_MANUAL => null,
561-
default => throw new \InvalidArgumentException("Unknown method: $method"),
562+
default => throw new InvalidArgumentException("Unknown method: $method"),
562563
};
563564
}
564565

src/Codeception/Lib/Connector/Yii2/Logger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function init(): void
2727
/**
2828
* @param string|array|YiiException $message
2929
* @param self::LEVEL_INFO|self::LEVEL_WARNING|self::LEVEL_ERROR $level
30-
* @param mixed $category
30+
* @param string $category
3131
*/
3232
public function log($message, $level, $category = 'application'): void
3333
{

src/Codeception/Module/Yii2.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,15 @@ class Yii2 extends Framework implements ActiveRecord, MultiSession, PartedModule
217217

218218
private Logger $yiiLogger;
219219

220-
private function getClient(): ?Yii2Connector
220+
private function getClient(): Yii2Connector
221221
{
222-
if ($this->client instanceof AbstractBrowser && !($this->client instanceof Yii2Connector)) {
222+
if (!isset($this->client)) {
223+
throw new RuntimeException('Browser not initialized');
224+
}
225+
if (!$this->client instanceof Yii2Connector) {
223226
throw new RuntimeException('The Yii2 module must be used with the Yii2 browser client');
224227
}
225-
return $this->client ?? null;
228+
return $this->client;
226229
}
227230

228231
public function _initialize(): void
@@ -846,7 +849,7 @@ public function _backupSession(): array
846849
'clientContext' => $this->getClient()->getContext(),
847850
'headers' => $this->headers,
848851
'cookie' => $_COOKIE,
849-
'session' => $_SESSION,
852+
'session' => $_SESSION ?? [],
850853
];
851854
}
852855

0 commit comments

Comments
 (0)