1818use Codeception \TestInterface ;
1919use ReflectionClass ;
2020use RuntimeException ;
21+ use Symfony \Component \BrowserKit \AbstractBrowser ;
2122use Yii ;
2223use yii \base \Security ;
2324use yii \db \ActiveQueryInterface ;
@@ -174,7 +175,6 @@ class Yii2 extends Framework implements ActiveRecord, MultiSession, PartedModule
174175{
175176 /**
176177 * Application config file must be set.
177- * @var array
178178 */
179179 protected array $ config = [
180180 'fixturesMethod ' => '_fixtures ' ,
@@ -217,9 +217,9 @@ class Yii2 extends Framework implements ActiveRecord, MultiSession, PartedModule
217217
218218 private Logger $ yiiLogger ;
219219
220- private function getClient (): ?\ Codeception \ Lib \ Connector \ Yii2
220+ private function getClient (): ?Yii2Connector
221221 {
222- if (isset ( $ this ->client ) && !($ this ->client instanceof \ Codeception \ Lib \ Connector \Yii2 )) {
222+ if ($ this ->client instanceof AbstractBrowser && !($ this ->client instanceof Yii2Connector )) {
223223 throw new RuntimeException ('The Yii2 module must be used with the Yii2 browser client ' );
224224 }
225225 return $ this ->client ?? null ;
@@ -275,20 +275,20 @@ protected function validateConfig(): void
275275 $ pathToConfig = codecept_absolute_path ($ this ->config ['configFile ' ]);
276276 if (!is_file ($ pathToConfig )) {
277277 throw new ModuleConfigException (
278- __CLASS__ ,
278+ self ::class ,
279279 "The application config file does not exist: " . $ pathToConfig
280280 );
281281 }
282282 $ validMethods = implode (", " , Yii2Connector::CLEAN_METHODS );
283283 if (!in_array ($ this ->config ['responseCleanMethod ' ], Yii2Connector::CLEAN_METHODS , true )) {
284284 throw new ModuleConfigException (
285- __CLASS__ ,
285+ self ::class ,
286286 "The response clean method must be one of: " . $ validMethods
287287 );
288288 }
289289 if (!in_array ($ this ->config ['requestCleanMethod ' ], Yii2Connector::CLEAN_METHODS , true )) {
290290 throw new ModuleConfigException (
291- __CLASS__ ,
291+ self ::class ,
292292 "The request clean method must be one of: " . $ validMethods
293293 );
294294 }
@@ -351,7 +351,7 @@ public function _before(TestInterface $test): void
351351 private function loadFixtures (object $ test ): void
352352 {
353353 $ this ->debugSection ('Fixtures ' , 'Loading fixtures ' );
354- if (empty ( $ this ->loadedFixtures )
354+ if ($ this ->loadedFixtures === []
355355 && method_exists ($ test , $ this ->_getConfig ('fixturesMethod ' ))
356356 ) {
357357 $ connectionWatcher = new ConnectionWatcher ();
@@ -502,11 +502,10 @@ public function haveFixtures($fixtures): void
502502 * Array of fixture instances
503503 *
504504 * @part fixtures
505- * @return array
506505 */
507506 public function grabFixtures ()
508507 {
509- if (! $ this ->loadedFixtures ) {
508+ if ($ this ->loadedFixtures === [] ) {
510509 return [];
511510 }
512511
@@ -562,7 +561,6 @@ public function grabFixture($name, $index = null)
562561 * @template T of \yii\db\ActiveRecord
563562 * @param class-string<T> $model
564563 * @param array<string, mixed> $attributes
565- * @return mixed
566564 * @part orm
567565 */
568566 public function haveRecord (string $ model , $ attributes = []): mixed
@@ -713,7 +711,6 @@ public function grabComponent(string $component): null|object
713711 * $I->seeEmailIsSent(3);
714712 * ```
715713 *
716- * @param int|null $num
717714 * @throws \Codeception\Exception\ModuleException
718715 * @part email
719716 */
@@ -749,7 +746,6 @@ public function dontSeeEmailIsSent(): void
749746 * ```
750747 *
751748 * @part email
752- * @return array
753749 * @throws \Codeception\Exception\ModuleException
754750 */
755751 public function grabSentEmails (): array
@@ -781,8 +777,6 @@ public function grabLastSentEmail(): object
781777
782778 /**
783779 * Returns a list of regex patterns for recognized domain names
784- *
785- * @return array
786780 */
787781 public function getInternalDomains (): array
788782 {
@@ -791,9 +785,9 @@ public function getInternalDomains(): array
791785
792786 private function defineConstants (): void
793787 {
794- defined ('YII_DEBUG ' ) or define ('YII_DEBUG ' , true );
795- defined ('YII_ENV ' ) or define ('YII_ENV ' , 'test ' );
796- defined ('YII_ENABLE_ERROR_HANDLER ' ) or define ('YII_ENABLE_ERROR_HANDLER ' , false );
788+ defined ('YII_DEBUG ' ) || define ('YII_DEBUG ' , true );
789+ defined ('YII_ENV ' ) || define ('YII_ENV ' , 'test ' );
790+ defined ('YII_ENABLE_ERROR_HANDLER ' ) || define ('YII_ENABLE_ERROR_HANDLER ' , false );
797791 }
798792
799793 /**
0 commit comments