From df4e36bd3c8201d5a37c091eb20ae72aed20efee Mon Sep 17 00:00:00 2001 From: Luke English Date: Wed, 23 Feb 2022 13:49:15 +0000 Subject: [PATCH 01/21] bootstrap updated --- .gitignore | 1 + tests/bootstrap.php | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 241050f..31a345f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /.idea/ +/nbproject/ /vendor/ /composer.lock tests/_support diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 71170fb..86d3fb6 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,9 +2,13 @@ defined('YII_DEBUG') || define('YII_DEBUG', true); defined('YII_ENV') || define('YII_ENV', 'test'); -Yii::$container = new \yii\di\Container(); +call_user_func(function() { + require dirname(__DIR__) . '/vendor/autoload.php'; + $container = new \yii\di\Container(); + Yii::$container = $container; +}); -$link = __DIR__ . '/../vendor/yiisoft/yii2-app-advanced/vendor'; -if (!file_exists($link) && !symlink(__DIR__ . '/../vendor', $link)) { +$link = dirname(__DIR__) . '/vendor/yiisoft/yii2-app-advanced/vendor'; +if (!file_exists($link) && !symlink(dirname(__DIR__) . '/vendor', $link)) { die('failed to create symlink'); -} +} \ No newline at end of file From 8fecd2a584133713557a81c16589d3ddb599b37b Mon Sep 17 00:00:00 2001 From: Luke English Date: Wed, 23 Feb 2022 14:11:55 +0000 Subject: [PATCH 02/21] updated composer.json --- composer.json | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index a539d2c..8d5af08 100644 --- a/composer.json +++ b/composer.json @@ -16,19 +16,19 @@ "name":"Michael Bodnarchuk" } ], - "minimum-stability": "RC", + "minimum-stability": "dev", "require": { - "php": ">=7.4.0 <=8.1 | ~8.1.0", - "codeception/lib-innerbrowser": "^1.0", - "codeception/codeception": "^4.0" + "php": ">=8.1.0", + "codeception/codeception": "dev-5.0-interfaces as 5.0.0", + "codeception/lib-innerbrowser": "^3.0" }, "require-dev": { "yiisoft/yii2": "dev-master", "yiisoft/yii2-app-advanced": "dev-master", "codeception/verify": "<2", "codemix/yii2-localeurls": "^1.7", - "codeception/module-asserts": "^2.0", - "codeception/module-filesystem": "^2.0" + "codeception/module-asserts": "^3.0", + "codeception/module-filesystem": "^3.0" }, "autoload":{ "classmap": ["src/"] @@ -40,6 +40,9 @@ ] }, "config": { + "allow-plugins": { + "yiisoft/yii2-composer": true + }, "classmap-authoritative": true }, "repositories": [ From e4fd41955286c2e81612844b98e81bca1ceeec5e Mon Sep 17 00:00:00 2001 From: Luke English Date: Wed, 23 Feb 2022 14:29:31 +0000 Subject: [PATCH 03/21] updated codeception.yml files --- tests/cases/closeConnections/codeception.yml | 2 +- tests/cases/closeConnectionsNoCleanup/codeception.yml | 2 +- tests/cases/events/codeception.yml | 2 +- tests/cases/locale-urls/codeception.yml | 2 +- tests/cases/mock-mailer/codeception.yml | 2 +- tests/cases/pageCacheHeaderAlreadySent/codeception.yml | 2 +- tests/cases/simple/codeception.yml | 2 +- tests/cases/sqlite/codeception.yml | 2 +- tests/cases/yii2-app-advanced/codeception.yml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/cases/closeConnections/codeception.yml b/tests/cases/closeConnections/codeception.yml index fe8df06..8045bf4 100644 --- a/tests/cases/closeConnections/codeception.yml +++ b/tests/cases/closeConnections/codeception.yml @@ -1,6 +1,6 @@ paths: tests: . - log: ../../_output + output: ../../_output data: _data support: ../../_support namespace: tests\ diff --git a/tests/cases/closeConnectionsNoCleanup/codeception.yml b/tests/cases/closeConnectionsNoCleanup/codeception.yml index 1bfb23c..fd2eb9a 100644 --- a/tests/cases/closeConnectionsNoCleanup/codeception.yml +++ b/tests/cases/closeConnectionsNoCleanup/codeception.yml @@ -1,6 +1,6 @@ paths: tests: . - log: ../../_output + output: ../../_output data: _data support: ../../_support namespace: tests\ diff --git a/tests/cases/events/codeception.yml b/tests/cases/events/codeception.yml index caf01d1..6c75eef 100644 --- a/tests/cases/events/codeception.yml +++ b/tests/cases/events/codeception.yml @@ -1,6 +1,6 @@ paths: tests: . - log: ../../_output + output: ../../_output data: _data support: ../../_support namespace: tests\ diff --git a/tests/cases/locale-urls/codeception.yml b/tests/cases/locale-urls/codeception.yml index caf01d1..6c75eef 100644 --- a/tests/cases/locale-urls/codeception.yml +++ b/tests/cases/locale-urls/codeception.yml @@ -1,6 +1,6 @@ paths: tests: . - log: ../../_output + output: ../../_output data: _data support: ../../_support namespace: tests\ diff --git a/tests/cases/mock-mailer/codeception.yml b/tests/cases/mock-mailer/codeception.yml index b0d1647..dcd92b1 100644 --- a/tests/cases/mock-mailer/codeception.yml +++ b/tests/cases/mock-mailer/codeception.yml @@ -1,6 +1,6 @@ paths: tests: . - log: ../../_output + output: ../../_output data: _data support: ../../_support namespace: tests\ diff --git a/tests/cases/pageCacheHeaderAlreadySent/codeception.yml b/tests/cases/pageCacheHeaderAlreadySent/codeception.yml index 01393b5..e17b226 100644 --- a/tests/cases/pageCacheHeaderAlreadySent/codeception.yml +++ b/tests/cases/pageCacheHeaderAlreadySent/codeception.yml @@ -1,6 +1,6 @@ paths: tests: . - log: ../../_output + output: ../../_output data: _data support: ../../_support namespace: tests\ diff --git a/tests/cases/simple/codeception.yml b/tests/cases/simple/codeception.yml index cb08201..bfca355 100644 --- a/tests/cases/simple/codeception.yml +++ b/tests/cases/simple/codeception.yml @@ -1,6 +1,6 @@ paths: tests: . - log: ../../_output + output: ../../_output data: _data support: ../../_support namespace: tests\ diff --git a/tests/cases/sqlite/codeception.yml b/tests/cases/sqlite/codeception.yml index caf01d1..6c75eef 100644 --- a/tests/cases/sqlite/codeception.yml +++ b/tests/cases/sqlite/codeception.yml @@ -1,6 +1,6 @@ paths: tests: . - log: ../../_output + output: ../../_output data: _data support: ../../_support namespace: tests\ diff --git a/tests/cases/yii2-app-advanced/codeception.yml b/tests/cases/yii2-app-advanced/codeception.yml index 744faf9..35d94f1 100644 --- a/tests/cases/yii2-app-advanced/codeception.yml +++ b/tests/cases/yii2-app-advanced/codeception.yml @@ -2,7 +2,7 @@ namespace: frontend\tests actor_suffix: Tester paths: tests: ../../../vendor/yiisoft/yii2-app-advanced/frontend/tests - log: ../../_output + output: ../../_output data: ../../../vendor/yiisoft/yii2-app-advanced/frontend/tests/_data support: ../../../vendor/yiisoft/yii2-app-advanced/frontend/tests/_support bootstrap: _bootstrap.php From 65681997d63f044aba179e4bdba055e0d1573b3f Mon Sep 17 00:00:00 2001 From: Luke English Date: Wed, 23 Feb 2022 14:29:48 +0000 Subject: [PATCH 04/21] added type definitions --- src/Codeception/Module/Yii2.php | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Codeception/Module/Yii2.php b/src/Codeception/Module/Yii2.php index 792e50b..0dcde16 100644 --- a/src/Codeception/Module/Yii2.php +++ b/src/Codeception/Module/Yii2.php @@ -171,7 +171,7 @@ class Yii2 extends Framework implements ActiveRecord, MultiSession, PartedModule * Application config file must be set. * @var array */ - protected $config = [ + protected array $config = [ 'fixturesMethod' => '_fixtures', 'cleanup' => true, 'ignoreCollidingDSN' => false, @@ -186,12 +186,12 @@ class Yii2 extends Framework implements ActiveRecord, MultiSession, PartedModule 'applicationClass' => null, ]; - protected $requiredFields = ['configFile']; + protected array $requiredFields = ['configFile']; /** * @var Yii2Connector\FixturesStore[] */ - public $loadedFixtures = []; + public array $loadedFixtures = []; /** * Helper to manage database connections @@ -256,7 +256,7 @@ private function initServerGlobal() ]); } - protected function validateConfig() + protected function validateConfig(): void { parent::validateConfig(); @@ -402,7 +402,7 @@ protected function rollbackTransactions() } } - public function _parts() + public function _parts(): array { return ['orm', 'init', 'fixtures', 'email']; } @@ -577,7 +577,7 @@ public function haveRecord($model, $attributes = []) * @param array $attributes * @part orm */ - public function seeRecord($model, $attributes = []) + public function seeRecord(string $model, array $attributes = []): void { $record = $this->findRecord($model, $attributes); if (!$record) { @@ -597,7 +597,7 @@ public function seeRecord($model, $attributes = []) * @param array $attributes * @part orm */ - public function dontSeeRecord($model, $attributes = []) + public function dontSeeRecord(string $model, array $attributes = []): void { $record = $this->findRecord($model, $attributes); $this->debugSection($model, json_encode($record)); @@ -618,7 +618,7 @@ public function dontSeeRecord($model, $attributes = []) * @return mixed * @part orm */ - public function grabRecord($model, $attributes = []) + public function grabRecord(string $model, array $attributes = []): mixed { return $this->findRecord($model, $attributes); } @@ -628,7 +628,7 @@ public function grabRecord($model, $attributes = []) * @param array $attributes * @return mixed */ - protected function findRecord($model, $attributes = []) + protected function findRecord(string $model, array $attributes = []): mixed { if (!class_exists($model)) { throw new \RuntimeException("Class $model does not exist"); @@ -660,7 +660,7 @@ protected function findRecord($model, $attributes = []) * @param string $route A route * @param array $params Additional route parameters */ - public function amOnRoute($route, array $params = []) + public function amOnRoute(string $route, array $params = []): void { array_unshift($params, $route); $this->amOnPage($params); @@ -679,7 +679,7 @@ public function amOnRoute($route, array $params = []) * * @param string|array $page the URI or route in array format */ - public function amOnPage($page) + public function amOnPage(string $page): void { parent::amOnPage($page); } @@ -715,7 +715,7 @@ protected function clientRequest(string $method, string $uri, array $parameters * @throws \Codeception\Exception\ModuleException * @deprecated in your tests you can use \Yii::$app directly. */ - public function grabComponent($component) + public function grabComponent(mixed $component) { try { return $this->client->getComponent($component); @@ -740,7 +740,7 @@ public function grabComponent($component) * @throws \Codeception\Exception\ModuleException * @part email */ - public function seeEmailIsSent($num = null) + public function seeEmailIsSent(int $num = null): void { if ($num === null) { $this->assertNotEmpty($this->grabSentEmails(), 'emails were sent'); @@ -754,7 +754,7 @@ public function seeEmailIsSent($num = null) * * @part email */ - public function dontSeeEmailIsSent() + public function dontSeeEmailIsSent(): void { $this->seeEmailIsSent(0); } @@ -775,7 +775,7 @@ public function dontSeeEmailIsSent() * @return array * @throws \Codeception\Exception\ModuleException */ - public function grabSentEmails() + public function grabSentEmails(): array { try { return $this->client->getEmails(); @@ -795,7 +795,7 @@ public function grabSentEmails() * ``` * @part email */ - public function grabLastSentEmail() + public function grabLastSentEmail(): object { $this->seeEmailIsSent(); $messages = $this->grabSentEmails(); @@ -814,7 +814,7 @@ public function getInternalDomains(): array return $this->client->getInternalDomains(); } - private function defineConstants() + private function defineConstants(): void { defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'test'); @@ -837,7 +837,7 @@ public function setCookie($name, $val, $params = []) * @param string $val The value of the CSRF token * @return string[] Returns an array containing the name of the CSRF param and the masked CSRF token. */ - public function createAndSetCsrfCookie($val) + public function createAndSetCsrfCookie(string $val): array { $masked = $this->client->maskToken($val); $name = $this->client->getCsrfParamName(); @@ -845,7 +845,7 @@ public function createAndSetCsrfCookie($val) return [$name, $masked]; } - public function _afterSuite() + public function _afterSuite(): void { parent::_afterSuite(); codecept_debug('Suite done, restoring $_SERVER to original'); @@ -856,7 +856,7 @@ public function _afterSuite() /** * Initialize an empty session. Implements MultiSession. */ - public function _initializeSession() + public function _initializeSession(): void { $this->client->removeContext(); $this->headers = []; @@ -868,7 +868,7 @@ public function _initializeSession() * Return the session content for future restoring. Implements MultiSession. * @return array backup data */ - public function _backupSession() + public function _backupSession(): array { if (isset(Yii::$app) && Yii::$app->session->useCustomStorage) { throw new ModuleException($this, "Yii2 MultiSession only supports the default session backend."); @@ -885,7 +885,7 @@ public function _backupSession() * Restore a session. Implements MultiSession. * @param array output of _backupSession() */ - public function _loadSession($session) + public function _loadSession($session): void { $this->client->setContext($session['clientContext']); $this->headers = $session['headers']; @@ -904,7 +904,7 @@ public function _loadSession($session) /** * Close and dump a session. Implements MultiSession. */ - public function _closeSession($session = null) + public function _closeSession($session = null): void { if (!$session) { $this->_initializeSession(); From 2a20418d35593ce0b8c139b6255b76cd391c535c Mon Sep 17 00:00:00 2001 From: Luke English Date: Wed, 23 Feb 2022 16:05:01 +0000 Subject: [PATCH 05/21] --- src/Codeception/Module/Yii2.php | 3 ++- tests/cases/simple/functional/SimpleCest.php | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Codeception/Module/Yii2.php b/src/Codeception/Module/Yii2.php index 0dcde16..12724f0 100644 --- a/src/Codeception/Module/Yii2.php +++ b/src/Codeception/Module/Yii2.php @@ -19,6 +19,7 @@ use yii\db\Connection; use yii\db\QueryInterface; use yii\db\Transaction; +use yii\helpers\Url; /** * This module provides integration with [Yii framework](http://www.yiiframework.com/) (2.0). @@ -663,7 +664,7 @@ protected function findRecord(string $model, array $attributes = []): mixed public function amOnRoute(string $route, array $params = []): void { array_unshift($params, $route); - $this->amOnPage($params); + $this->amOnPage(Url::to($params)); } /** diff --git a/tests/cases/simple/functional/SimpleCest.php b/tests/cases/simple/functional/SimpleCest.php index 00db22d..f509ed8 100644 --- a/tests/cases/simple/functional/SimpleCest.php +++ b/tests/cases/simple/functional/SimpleCest.php @@ -15,9 +15,8 @@ public function testInstantiation(FunctionalTester $I) public function testFormSubmit(FunctionalTester $I) { - $I->amOnPage('site/form'); + $I->amOnRoute('/site/form'); $I->seeResponseCodeIs(200); - $I->fillField('#test', 'test'); $I->click('#submit'); $I->canSeeResponseCodeIs(201); @@ -25,7 +24,7 @@ public function testFormSubmit(FunctionalTester $I) public function testFormSubmit2(FunctionalTester $I) { - $I->amOnPage('site/form'); + $I->amOnRoute('/site/form'); $I->seeResponseCodeIs(200); $I->submitForm('form', [ 'login-form[login]' => 'user', @@ -37,7 +36,7 @@ public function testFormSubmit2(FunctionalTester $I) public function testException(FunctionalTester $I) { $I->expectException(new \Exception('This is not an HttpException'), function() use ($I) { - $I->amOnPage('site/exception'); + $I->amOnRoute('/site/exception'); }); $I->assertInstanceOf(Application::class, \Yii::$app); } @@ -47,19 +46,19 @@ public function testExceptionInBeforeRequest(FunctionalTester $I) $e = new \Exception('This is not an HttpException'); \Yii::$app->params['throw'] = $e; $I->expectException($e, function() use ($I) { - $I->amOnPage('site/exception'); + $I->amOnRoute('/site/exception'); }); } public function testExitException(FunctionalTester $I) { - $I->amOnPage('site/end'); + $I->amOnRoute('/site/end'); $I->seeResponseCodeIs(500); } public function testEmptyResponse(FunctionalTester $I) { - $I->amOnPage('site/empty-response'); + $I->amOnRoute('/site/empty-response'); $I->seeResponseCodeIs(200); } @@ -68,7 +67,7 @@ public function testMissingUser(FunctionalTester $I) $I->expectException(ModuleException::class, function() use ($I) { $I->amLoggedInAs('nobody'); }); - $I->amOnPage('site/index'); + $I->amOnRoute('/site/index'); $I->assertTrue(\Yii::$app->user->isGuest); } } \ No newline at end of file From 2d8e16149c95e2d091cfef3afe0a62effdd84fa7 Mon Sep 17 00:00:00 2001 From: Luke English Date: Wed, 23 Feb 2022 16:33:26 +0000 Subject: [PATCH 06/21] --- src/Codeception/Module/Yii2.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Codeception/Module/Yii2.php b/src/Codeception/Module/Yii2.php index 12724f0..1d6ac7c 100644 --- a/src/Codeception/Module/Yii2.php +++ b/src/Codeception/Module/Yii2.php @@ -663,6 +663,10 @@ protected function findRecord(string $model, array $attributes = []): mixed */ public function amOnRoute(string $route, array $params = []): void { + if (Yii::$app->controller === null) { + $route = "/{$route}"; + } + array_unshift($params, $route); $this->amOnPage(Url::to($params)); } From e2192cfa5c6f6b4bfaec7a570aba088a87c1b06b Mon Sep 17 00:00:00 2001 From: Luke English Date: Wed, 23 Feb 2022 16:40:50 +0000 Subject: [PATCH 07/21] --- tests/cases/simple/functional.suite.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/cases/simple/functional.suite.yml b/tests/cases/simple/functional.suite.yml index 6da4e38..8634679 100644 --- a/tests/cases/simple/functional.suite.yml +++ b/tests/cases/simple/functional.suite.yml @@ -1,9 +1,3 @@ -# Codeception Test Suite Configuration -# -# Suite for functional tests -# Emulate web requests and make application process them -# Include one of framework modules (Symfony2, Yii2, Laravel5) to use it -# Remove this suite if you don't use frameworks actor: FunctionalTester modules: enabled: From 1bdbed79a4dadac7d65eefb61fb635793ef98a8c Mon Sep 17 00:00:00 2001 From: Luke English Date: Wed, 23 Feb 2022 16:57:25 +0000 Subject: [PATCH 08/21] --- .../cases/pageCacheHeaderAlreadySent/functional/PageCest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cases/pageCacheHeaderAlreadySent/functional/PageCest.php b/tests/cases/pageCacheHeaderAlreadySent/functional/PageCest.php index 3bec510..c2fa371 100644 --- a/tests/cases/pageCacheHeaderAlreadySent/functional/PageCest.php +++ b/tests/cases/pageCacheHeaderAlreadySent/functional/PageCest.php @@ -4,10 +4,10 @@ class PageCest { public function testCache(\tests\FunctionalTester $I) { - $I->amOnPage('user/index'); + $I->amOnRoute('user/index'); $I->canSeeResponseCodeIs(200); - $I->amOnPage('user/index'); + $I->amOnRoute('user/index'); $I->canSeeResponseCodeIs(200); } } \ No newline at end of file From ffbd527ca2dd1b5c4e6b66e7da1c87516e57be29 Mon Sep 17 00:00:00 2001 From: Luke English Date: Wed, 23 Feb 2022 16:57:34 +0000 Subject: [PATCH 09/21] --- tests/cases/simple/functional/SimpleCest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/cases/simple/functional/SimpleCest.php b/tests/cases/simple/functional/SimpleCest.php index f509ed8..f328c9e 100644 --- a/tests/cases/simple/functional/SimpleCest.php +++ b/tests/cases/simple/functional/SimpleCest.php @@ -35,7 +35,7 @@ public function testFormSubmit2(FunctionalTester $I) public function testException(FunctionalTester $I) { - $I->expectException(new \Exception('This is not an HttpException'), function() use ($I) { + $I->expectThrowable(new \Exception('This is not an HttpException'), function() use ($I) { $I->amOnRoute('/site/exception'); }); $I->assertInstanceOf(Application::class, \Yii::$app); @@ -45,7 +45,7 @@ public function testExceptionInBeforeRequest(FunctionalTester $I) { $e = new \Exception('This is not an HttpException'); \Yii::$app->params['throw'] = $e; - $I->expectException($e, function() use ($I) { + $I->expectThrowable($e, function() use ($I) { $I->amOnRoute('/site/exception'); }); } @@ -64,7 +64,7 @@ public function testEmptyResponse(FunctionalTester $I) public function testMissingUser(FunctionalTester $I) { - $I->expectException(ModuleException::class, function() use ($I) { + $I->expectThrowable(ModuleException::class, function() use ($I) { $I->amLoggedInAs('nobody'); }); $I->amOnRoute('/site/index'); From 7c5767d364249ab0b1fe327b0992394b9bc12a4e Mon Sep 17 00:00:00 2001 From: Luke English Date: Wed, 23 Feb 2022 17:00:06 +0000 Subject: [PATCH 10/21] --- tests/cases/events/functional/ResponseCest.php | 12 ++++++------ tests/cases/locale-urls/functional/LocaleUrlCest.php | 8 ++++---- .../cases/mock-mailer/functional/MockMailerCest.php | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/cases/events/functional/ResponseCest.php b/tests/cases/events/functional/ResponseCest.php index 4d7a2d3..30e7f37 100644 --- a/tests/cases/events/functional/ResponseCest.php +++ b/tests/cases/events/functional/ResponseCest.php @@ -17,11 +17,11 @@ public function testAfterSend(FunctionalTester $I) $sources[] = 'bootstrap'; }); $I->assertEmpty($sources); - $I->amOnPage('/'); + $I->amOnRoute('/'); $I->assertEquals(['config', 'bootstrap'], $sources); $sources = []; - $I->amOnPage('/'); + $I->amOnRoute('/'); $I->assertEquals(['config', 'bootstrap'], $sources); } @@ -40,11 +40,11 @@ public function testAfterSendWithRecreate(FunctionalTester $I, \Codeception\Modu $sources[] = 'bootstrap'; }); $I->assertEmpty($sources); - $I->amOnPage('/'); + $I->amOnRoute('/'); $I->assertEquals(['config', 'bootstrap'], $sources); $sources = []; - $I->amOnPage('/'); + $I->amOnRoute('/'); // The module should fall back to the CLEAN_CLEAR method and keep event handlers intact. $I->assertEquals(['config', 'bootstrap'], $sources); @@ -66,14 +66,14 @@ public function testAfterSendWithForcedRecreate(FunctionalTester $I, \Codeceptio }); $I->assertEmpty($sources); - $I->amOnPage('/'); + $I->amOnRoute('/'); // We recreated the response component, since it has an event handler in its config // that event handler will still work. $I->assertEquals(['config'], $sources); $sources = []; - $I->amOnPage('/'); + $I->amOnRoute('/'); // We recreated the response component, since it has an event handler in its config // that event handler will still work. diff --git a/tests/cases/locale-urls/functional/LocaleUrlCest.php b/tests/cases/locale-urls/functional/LocaleUrlCest.php index f146389..c9e7638 100644 --- a/tests/cases/locale-urls/functional/LocaleUrlCest.php +++ b/tests/cases/locale-urls/functional/LocaleUrlCest.php @@ -13,12 +13,12 @@ public function testInstantiation(FunctionalTester $I) public function testMultipleGet(FunctionalTester $I) { - $I->amOnPage('/en/site/form'); - $I->amOnPage('/en/site/form'); + $I->amOnRoute('/en/site/form'); + $I->amOnRoute('/en/site/form'); } public function testFormSubmit(FunctionalTester $I) { - $I->amOnPage('site/form'); + $I->amOnRoute('site/form'); $I->seeResponseCodeIs(200); $I->fillField('#test', 'test'); @@ -28,7 +28,7 @@ public function testFormSubmit(FunctionalTester $I) public function testFormSubmit2(FunctionalTester $I) { - $I->amOnPage('/en/site/form'); + $I->amOnRoute('/en/site/form'); $I->seeResponseCodeIs(200); $I->submitForm('form', [ 'login-form[login]' => 'user', diff --git a/tests/cases/mock-mailer/functional/MockMailerCest.php b/tests/cases/mock-mailer/functional/MockMailerCest.php index 9699896..fb61035 100644 --- a/tests/cases/mock-mailer/functional/MockMailerCest.php +++ b/tests/cases/mock-mailer/functional/MockMailerCest.php @@ -12,14 +12,14 @@ public function testInstantiation(FunctionalTester $I) public function testCountMailSentWithoutRedirect(FunctionalTester $I) { - $I->amOnPage('site/send-mail-without-redirect'); + $I->amOnRoute('site/send-mail-without-redirect'); $I->seeEmailIsSent(1); } public function testCountMailSentWithRedirect(FunctionalTester $I) { - $I->amOnPage('site/send-mail-with-redirect'); + $I->amOnRoute('site/send-mail-with-redirect'); $I->seeEmailIsSent(1); } From cf146373ade75a71787726991cf5554ba582a5aa Mon Sep 17 00:00:00 2001 From: Luke English Date: Wed, 23 Feb 2022 20:30:47 +0000 Subject: [PATCH 11/21] removed nbproject from gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 31a345f..241050f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ /.idea/ -/nbproject/ /vendor/ /composer.lock tests/_support From b1df3587b68f8d1f65945a8a7eff2330f5ae446b Mon Sep 17 00:00:00 2001 From: Luke English Date: Wed, 23 Feb 2022 20:31:26 +0000 Subject: [PATCH 12/21] require php8 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 8d5af08..4c391e1 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,8 @@ ], "minimum-stability": "dev", "require": { - "php": ">=8.1.0", - "codeception/codeception": "dev-5.0-interfaces as 5.0.0", + "php": "^8.0", + "codeception/codeception": "^5.0.0-alpha2", "codeception/lib-innerbrowser": "^3.0" }, "require-dev": { From 7d601c723e158a083e162841002e57a79e6989c3 Mon Sep 17 00:00:00 2001 From: Luke English Date: Wed, 23 Feb 2022 20:33:33 +0000 Subject: [PATCH 13/21] bump codeception/verify to 2.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4c391e1..133ea85 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "require-dev": { "yiisoft/yii2": "dev-master", "yiisoft/yii2-app-advanced": "dev-master", - "codeception/verify": "<2", + "codeception/verify": "^2.2", "codemix/yii2-localeurls": "^1.7", "codeception/module-asserts": "^3.0", "codeception/module-filesystem": "^3.0" From d8cd0fe7e61ef3ccbb1caebf5a41f3dd740df28f Mon Sep 17 00:00:00 2001 From: Luke English Date: Wed, 23 Feb 2022 20:47:11 +0000 Subject: [PATCH 14/21] codeception/verify bumped to dev-master --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 133ea85..bfade1e 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "require-dev": { "yiisoft/yii2": "dev-master", "yiisoft/yii2-app-advanced": "dev-master", - "codeception/verify": "^2.2", + "codeception/verify": "dev-master", "codemix/yii2-localeurls": "^1.7", "codeception/module-asserts": "^3.0", "codeception/module-filesystem": "^3.0" From bfd2c8a3df22bbecd1b998cb9ecddbd27ed23a21 Mon Sep 17 00:00:00 2001 From: Luke English Date: Wed, 23 Feb 2022 22:00:44 +0000 Subject: [PATCH 15/21] removing closure from bootstrap --- tests/bootstrap.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 86d3fb6..f10531f 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,11 +2,9 @@ defined('YII_DEBUG') || define('YII_DEBUG', true); defined('YII_ENV') || define('YII_ENV', 'test'); -call_user_func(function() { - require dirname(__DIR__) . '/vendor/autoload.php'; - $container = new \yii\di\Container(); - Yii::$container = $container; -}); +require dirname(__DIR__) . '/vendor/autoload.php'; + +Yii::$container = new \yii\di\Container(); $link = dirname(__DIR__) . '/vendor/yiisoft/yii2-app-advanced/vendor'; if (!file_exists($link) && !symlink(dirname(__DIR__) . '/vendor', $link)) { From 2aa353f7265258b05cfa33f7a9aaa6aca2d0acbd Mon Sep 17 00:00:00 2001 From: Gustavo Nieves <64917965+TavoNiievez@users.noreply.github.com> Date: Wed, 23 Feb 2022 17:46:55 -0500 Subject: [PATCH 16/21] Don't test in php 7.4 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d2093f1..1203ebb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - php: [7.4, 8.0, 8.1] + php: [8.0, 8.1] steps: - name: Checkout code From 21d1e10ca801120e399d55932ea0b56328009629 Mon Sep 17 00:00:00 2001 From: Luke English Date: Thu, 24 Feb 2022 00:11:30 +0000 Subject: [PATCH 17/21] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bfade1e..4c391e1 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "require-dev": { "yiisoft/yii2": "dev-master", "yiisoft/yii2-app-advanced": "dev-master", - "codeception/verify": "dev-master", + "codeception/verify": "<2", "codemix/yii2-localeurls": "^1.7", "codeception/module-asserts": "^3.0", "codeception/module-filesystem": "^3.0" From 09092222e7b3ef631355a5860e60fdbfc199cb5a Mon Sep 17 00:00:00 2001 From: Luke English Date: Thu, 24 Feb 2022 14:30:25 +0000 Subject: [PATCH 18/21] --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 241050f..31a345f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /.idea/ +/nbproject/ /vendor/ /composer.lock tests/_support From 654ef56f7c27c1c47fc9ed234e7e91e099babf89 Mon Sep 17 00:00:00 2001 From: Luke English Date: Thu, 24 Feb 2022 22:55:53 +0000 Subject: [PATCH 19/21] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4c391e1..bfade1e 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "require-dev": { "yiisoft/yii2": "dev-master", "yiisoft/yii2-app-advanced": "dev-master", - "codeception/verify": "<2", + "codeception/verify": "dev-master", "codemix/yii2-localeurls": "^1.7", "codeception/module-asserts": "^3.0", "codeception/module-filesystem": "^3.0" From bd34ba294cb5c6ac69abfcd69e3e95fbb4d682c8 Mon Sep 17 00:00:00 2001 From: Luke English Date: Thu, 24 Feb 2022 23:02:18 +0000 Subject: [PATCH 20/21] codeception/verify 2.2 --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bfade1e..6cadf21 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ "require-dev": { "yiisoft/yii2": "dev-master", "yiisoft/yii2-app-advanced": "dev-master", - "codeception/verify": "dev-master", + "phpunit/phpunit": "dev-master as 9.5.99", + "codeception/verify": "^2.2", "codemix/yii2-localeurls": "^1.7", "codeception/module-asserts": "^3.0", "codeception/module-filesystem": "^3.0" From e1a5790586cfa677d8f263db1308767fad58a2ae Mon Sep 17 00:00:00 2001 From: Luke English Date: Fri, 25 Feb 2022 12:44:08 +0000 Subject: [PATCH 21/21] className() is deprecated --- src/Codeception/Lib/Connector/Yii2.php | 2 +- src/Codeception/Lib/Connector/Yii2/FixturesStore.php | 2 +- src/Codeception/Module/Yii2.php | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Codeception/Lib/Connector/Yii2.php b/src/Codeception/Lib/Connector/Yii2.php index ff62658..8211220 100644 --- a/src/Codeception/Lib/Connector/Yii2.php +++ b/src/Codeception/Lib/Connector/Yii2.php @@ -116,7 +116,7 @@ public function resetApplication($closeSession = true) } Yii::$app = null; \yii\web\UploadedFile::reset(); - if (method_exists(\yii\base\Event::className(), 'offAll')) { + if (method_exists(\yii\base\Event::class, 'offAll')) { \yii\base\Event::offAll(); } Yii::setLogger(null); diff --git a/src/Codeception/Lib/Connector/Yii2/FixturesStore.php b/src/Codeception/Lib/Connector/Yii2/FixturesStore.php index 53023ae..113c0a3 100644 --- a/src/Codeception/Lib/Connector/Yii2/FixturesStore.php +++ b/src/Codeception/Lib/Connector/Yii2/FixturesStore.php @@ -29,7 +29,7 @@ public function fixtures() public function globalFixtures() { return [ - InitDbFixture::className() + InitDbFixture::class ]; } } diff --git a/src/Codeception/Module/Yii2.php b/src/Codeception/Module/Yii2.php index 1d6ac7c..69d75c7 100644 --- a/src/Codeception/Module/Yii2.php +++ b/src/Codeception/Module/Yii2.php @@ -132,7 +132,7 @@ * * ```php * haveFixtures(['posts' => PostsFixture::className()]); + * $I->haveFixtures(['posts' => PostsFixture::class]); * ``` * * or, if you need to load fixtures before the test, you @@ -143,7 +143,7 @@ * // inside Cest file or Codeception\TestCase\Unit * public function _fixtures() * { - * return ['posts' => PostsFixture::className()] + * return ['posts' => PostsFixture::class] * } * ``` * @@ -444,9 +444,9 @@ public function amLoggedInAs($user) * ```php * haveFixtures([ - * 'posts' => PostsFixture::className(), + * 'posts' => PostsFixture::class, * 'user' => [ - * 'class' => UserFixture::className(), + * 'class' => UserFixture::class, * 'dataFile' => '@tests/_data/models/user.php', * ], * ]); @@ -462,7 +462,7 @@ public function amLoggedInAs($user) * public function _fixtures(){ * return [ * 'user' => [ - * 'class' => UserFixture::className(), + * 'class' => UserFixture::class, * 'dataFile' => codecept_data_dir() . 'user.php' * ] * ]; @@ -512,7 +512,7 @@ function ($fixturesStore) { * * ```php * haveFixtures(['users' => UserFixture::className()]); + * $I->haveFixtures(['users' => UserFixture::class]); * * $users = $I->grabFixture('users'); *