From d30c80ef60ab57b3bec1d3f7fac80a596a4dc559 Mon Sep 17 00:00:00 2001 From: DBX12 Date: Tue, 26 Oct 2021 07:40:25 +0200 Subject: [PATCH 01/12] Add dependencies for tests to require-dev Also added dev dependencies for modules used in test cases --- composer.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/composer.json b/composer.json index 3fb5f18..c137edc 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,14 @@ "codeception/lib-innerbrowser": "^1.0", "codeception/codeception": "^4.0" }, + "require-dev": { + "yiisoft/yii2": "dev-master", + "yiisoft/yii2-app-advanced": "dev-master", + "codeception/verify": "<2", + "codemix/yii2-localeurls": "^1.7", + "codeception/module-asserts": "^1.3", + "codeception/module-filesystem": "^1.0" + }, "autoload":{ "classmap": ["src/"] }, From 371bdca84a9aa2c6243caa6d8afe36873a97fd5c Mon Sep 17 00:00:00 2001 From: DBX12 Date: Tue, 26 Oct 2021 08:10:26 +0200 Subject: [PATCH 02/12] Copy changes to .gitignore from codeception/yii2-tests repository --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5501822..241050f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ /.idea/ /vendor/ /composer.lock -/framework-tests \ No newline at end of file +tests/_support +tests/_output +tests/cases/yii2-app-advanced/_data/db.sqlite From 0a80982c6322c5fa6c5a3efe03ad19f7b28275d2 Mon Sep 17 00:00:00 2001 From: DBX12 Date: Tue, 26 Oct 2021 08:14:44 +0200 Subject: [PATCH 03/12] Bootstrap codeception --- codeception.yml | 10 ++++++++++ tests/_data/.gitkeep | 0 2 files changed, 10 insertions(+) create mode 100644 codeception.yml create mode 100644 tests/_data/.gitkeep diff --git a/codeception.yml b/codeception.yml new file mode 100644 index 0000000..f0446cc --- /dev/null +++ b/codeception.yml @@ -0,0 +1,10 @@ +paths: + tests: tests + output: tests/_output + data: tests/_data + support: tests/_support + envs: tests/_envs +actor_suffix: Tester +extensions: + enabled: + - Codeception\Extension\RunFailed diff --git a/tests/_data/.gitkeep b/tests/_data/.gitkeep new file mode 100644 index 0000000..e69de29 From 7604f7679dd57ced0f22e97799e8529a918399cc Mon Sep 17 00:00:00 2001 From: DBX12 Date: Tue, 26 Oct 2021 08:17:06 +0200 Subject: [PATCH 04/12] Copy test cases and config from codeception/yii2-tests repository The codeception.yml was already adapted to the new paths. --- codeception.yml | 12 ++- tests/bootstrap.php | 20 +++++ tests/cases/closeConnections/codeception.yml | 12 +++ tests/cases/closeConnections/config.php | 12 +++ .../fixtures/EmptyFixture.php | 16 ++++ .../closeConnections/functional.suite.yml | 5 ++ .../functional/FixturesCest.php | 35 ++++++++ .../functional/FixturesInBeforeCest.php | 35 ++++++++ .../functional/NoFixturesCest.php | 25 ++++++ .../helpers/SqlliteHelper.php | 32 +++++++ .../closeConnectionsNoCleanup/codeception.yml | 12 +++ .../closeConnectionsNoCleanup/config.php | 12 +++ .../functional.suite.yml | 5 ++ .../functional/FixturesCest.php | 38 +++++++++ .../functional/FixturesInBeforeCest.php | 37 +++++++++ .../functional/ThirdCest.php | 40 +++++++++ tests/cases/events/codeception.yml | 15 ++++ tests/cases/events/config.php | 22 +++++ .../events/controllers/SiteController.php | 13 +++ tests/cases/events/functional.suite.yml | 11 +++ .../cases/events/functional/ResponseCest.php | 83 +++++++++++++++++++ tests/cases/locale-urls/codeception.yml | 15 ++++ tests/cases/locale-urls/config.php | 31 +++++++ .../controllers/SiteController.php | 33 ++++++++ tests/cases/locale-urls/functional.suite.yml | 13 +++ .../locale-urls/functional/LocaleUrlCest.php | 40 +++++++++ tests/cases/mock-mailer/codeception.yml | 14 ++++ tests/cases/mock-mailer/config.php | 15 ++++ .../controllers/SiteController.php | 39 +++++++++ tests/cases/mock-mailer/functional.suite.yml | 11 +++ .../mock-mailer/functional/MockMailerCest.php | 26 ++++++ .../codeception.yml | 13 +++ .../pageCacheHeaderAlreadySent/config.php | 12 +++ .../controllers/UserController.php | 22 +++++ .../functional.suite.yml | 12 +++ .../functional/PageCest.php | 13 +++ tests/cases/simple/codeception.yml | 18 ++++ tests/cases/simple/config.php | 23 +++++ .../simple/controllers/SiteController.php | 72 ++++++++++++++++ tests/cases/simple/functional.suite.yml | 13 +++ tests/cases/simple/functional/SimpleCest.php | 74 +++++++++++++++++ tests/cases/simple/helpers/DummyUser.php | 77 +++++++++++++++++ tests/cases/simple/helpers/EmptyString.php | 27 ++++++ tests/cases/sqlite/codeception.yml | 15 ++++ tests/cases/sqlite/config.php | 24 ++++++ tests/cases/sqlite/fixtures/TestFixture.php | 36 ++++++++ tests/cases/sqlite/functional.suite.yml | 13 +++ tests/cases/sqlite/functional/SqLiteCest.php | 46 ++++++++++ tests/cases/yii2-app-advanced/codeception.yml | 15 ++++ tests/cases/yii2-app-advanced/config.php | 32 +++++++ tests/cases/yii2-app-advanced/migrate.php | 17 ++++ 51 files changed, 1299 insertions(+), 4 deletions(-) create mode 100644 tests/bootstrap.php create mode 100644 tests/cases/closeConnections/codeception.yml create mode 100644 tests/cases/closeConnections/config.php create mode 100644 tests/cases/closeConnections/fixtures/EmptyFixture.php create mode 100644 tests/cases/closeConnections/functional.suite.yml create mode 100644 tests/cases/closeConnections/functional/FixturesCest.php create mode 100644 tests/cases/closeConnections/functional/FixturesInBeforeCest.php create mode 100644 tests/cases/closeConnections/functional/NoFixturesCest.php create mode 100644 tests/cases/closeConnections/helpers/SqlliteHelper.php create mode 100644 tests/cases/closeConnectionsNoCleanup/codeception.yml create mode 100644 tests/cases/closeConnectionsNoCleanup/config.php create mode 100644 tests/cases/closeConnectionsNoCleanup/functional.suite.yml create mode 100644 tests/cases/closeConnectionsNoCleanup/functional/FixturesCest.php create mode 100644 tests/cases/closeConnectionsNoCleanup/functional/FixturesInBeforeCest.php create mode 100644 tests/cases/closeConnectionsNoCleanup/functional/ThirdCest.php create mode 100644 tests/cases/events/codeception.yml create mode 100644 tests/cases/events/config.php create mode 100644 tests/cases/events/controllers/SiteController.php create mode 100644 tests/cases/events/functional.suite.yml create mode 100644 tests/cases/events/functional/ResponseCest.php create mode 100644 tests/cases/locale-urls/codeception.yml create mode 100644 tests/cases/locale-urls/config.php create mode 100644 tests/cases/locale-urls/controllers/SiteController.php create mode 100644 tests/cases/locale-urls/functional.suite.yml create mode 100644 tests/cases/locale-urls/functional/LocaleUrlCest.php create mode 100644 tests/cases/mock-mailer/codeception.yml create mode 100644 tests/cases/mock-mailer/config.php create mode 100644 tests/cases/mock-mailer/controllers/SiteController.php create mode 100644 tests/cases/mock-mailer/functional.suite.yml create mode 100644 tests/cases/mock-mailer/functional/MockMailerCest.php create mode 100644 tests/cases/pageCacheHeaderAlreadySent/codeception.yml create mode 100644 tests/cases/pageCacheHeaderAlreadySent/config.php create mode 100644 tests/cases/pageCacheHeaderAlreadySent/controllers/UserController.php create mode 100644 tests/cases/pageCacheHeaderAlreadySent/functional.suite.yml create mode 100644 tests/cases/pageCacheHeaderAlreadySent/functional/PageCest.php create mode 100644 tests/cases/simple/codeception.yml create mode 100644 tests/cases/simple/config.php create mode 100644 tests/cases/simple/controllers/SiteController.php create mode 100644 tests/cases/simple/functional.suite.yml create mode 100644 tests/cases/simple/functional/SimpleCest.php create mode 100644 tests/cases/simple/helpers/DummyUser.php create mode 100644 tests/cases/simple/helpers/EmptyString.php create mode 100644 tests/cases/sqlite/codeception.yml create mode 100644 tests/cases/sqlite/config.php create mode 100644 tests/cases/sqlite/fixtures/TestFixture.php create mode 100644 tests/cases/sqlite/functional.suite.yml create mode 100644 tests/cases/sqlite/functional/SqLiteCest.php create mode 100644 tests/cases/yii2-app-advanced/codeception.yml create mode 100644 tests/cases/yii2-app-advanced/config.php create mode 100644 tests/cases/yii2-app-advanced/migrate.php diff --git a/codeception.yml b/codeception.yml index f0446cc..9143f3d 100644 --- a/codeception.yml +++ b/codeception.yml @@ -4,7 +4,11 @@ paths: data: tests/_data support: tests/_support envs: tests/_envs -actor_suffix: Tester -extensions: - enabled: - - Codeception\Extension\RunFailed +modules: + - Asserts +bootstrap: bootstrap.php +settings: + colors: true + memory_limit: 1024M +include: + - tests/cases/* diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..5f5e8d1 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,20 @@ + 'Simple', + 'basePath' => __DIR__, + + 'components' => [ + 'db' => [ + 'class' => yii\db\Connection::class, + 'dsn' => 'sqlite:' . \tests\helpers\SqlliteHelper::getTmpFile(), + ], + ], +]; \ No newline at end of file diff --git a/tests/cases/closeConnections/fixtures/EmptyFixture.php b/tests/cases/closeConnections/fixtures/EmptyFixture.php new file mode 100644 index 0000000..c8aeae6 --- /dev/null +++ b/tests/cases/closeConnections/fixtures/EmptyFixture.php @@ -0,0 +1,16 @@ + EmptyFixture::class, + ], + ]; + } + + protected function numberProvider() + { + return array_pad([], 5, ['count' => 0]); + } + + /** + * @param FunctionalTester $I + * @dataProvider numberProvider + */ + public function NoConnections(FunctionalTester $I, Example $example) + { + $I->assertEquals(SqlliteHelper::connectionCount(), $example['count']); + } + +} \ No newline at end of file diff --git a/tests/cases/closeConnections/functional/FixturesInBeforeCest.php b/tests/cases/closeConnections/functional/FixturesInBeforeCest.php new file mode 100644 index 0000000..21de51d --- /dev/null +++ b/tests/cases/closeConnections/functional/FixturesInBeforeCest.php @@ -0,0 +1,35 @@ +haveFixtures([ + [ + 'class' => EmptyFixture::class, + ], + ]); + } + + protected function numberProvider() + { + return array_pad([], 5, ['count' => 1]); + } + + /** + * @param FunctionalTester $I + * @dataProvider numberProvider + */ + public function NoConnections(FunctionalTester $I, Example $example) + { + $I->assertEquals(SqlliteHelper::connectionCount(), $example['count']); + } + +} \ No newline at end of file diff --git a/tests/cases/closeConnections/functional/NoFixturesCest.php b/tests/cases/closeConnections/functional/NoFixturesCest.php new file mode 100644 index 0000000..245be50 --- /dev/null +++ b/tests/cases/closeConnections/functional/NoFixturesCest.php @@ -0,0 +1,25 @@ + 0]); + } + + /** + * @param FunctionalTester $I + * @dataProvider numberProvider + */ + public function NoConnections(FunctionalTester $I, Example $example) + { + $I->assertEquals(SqlliteHelper::connectionCount(), $example['count']); + } +} \ No newline at end of file diff --git a/tests/cases/closeConnections/helpers/SqlliteHelper.php b/tests/cases/closeConnections/helpers/SqlliteHelper.php new file mode 100644 index 0000000..cf8c460 --- /dev/null +++ b/tests/cases/closeConnections/helpers/SqlliteHelper.php @@ -0,0 +1,32 @@ + 'Simple', + 'basePath' => __DIR__, + + 'components' => [ + 'db' => [ + 'class' => yii\db\Connection::class, + 'dsn' => 'sqlite:' . \tests\helpers\SqlliteHelper::getTmpFile(), + ], + ], +]; \ No newline at end of file diff --git a/tests/cases/closeConnectionsNoCleanup/functional.suite.yml b/tests/cases/closeConnectionsNoCleanup/functional.suite.yml new file mode 100644 index 0000000..b189d50 --- /dev/null +++ b/tests/cases/closeConnectionsNoCleanup/functional.suite.yml @@ -0,0 +1,5 @@ +actor: FunctionalTester +modules: + enabled: + - Yii2 + - Asserts \ No newline at end of file diff --git a/tests/cases/closeConnectionsNoCleanup/functional/FixturesCest.php b/tests/cases/closeConnectionsNoCleanup/functional/FixturesCest.php new file mode 100644 index 0000000..025a423 --- /dev/null +++ b/tests/cases/closeConnectionsNoCleanup/functional/FixturesCest.php @@ -0,0 +1,38 @@ + EmptyFixture::class, + ], + ]; + } + + public function NoConnections1(FunctionalTester $I) + { + $count = SqlliteHelper::connectionCount(); + $I->assertEquals(0, $count); + } + + public function NoConnections2(FunctionalTester $I) + { + $count = SqlliteHelper::connectionCount(); + $I->assertEquals(0, $count); + } + + public function NoConnections3(FunctionalTester $I) + { + $count = SqlliteHelper::connectionCount(); + $I->assertEquals(0, $count); + } + +} \ No newline at end of file diff --git a/tests/cases/closeConnectionsNoCleanup/functional/FixturesInBeforeCest.php b/tests/cases/closeConnectionsNoCleanup/functional/FixturesInBeforeCest.php new file mode 100644 index 0000000..acf6031 --- /dev/null +++ b/tests/cases/closeConnectionsNoCleanup/functional/FixturesInBeforeCest.php @@ -0,0 +1,37 @@ +haveFixtures([ + [ + 'class' => EmptyFixture::class, + ], + ]); + } + + public function OnlyOneConnection1(FunctionalTester $I) + { + $count = SqlliteHelper::connectionCount(); + $I->assertEquals(1, $count); + } + + public function OnlyOneConnection2(FunctionalTester $I) + { + $count = SqlliteHelper::connectionCount(); + $I->assertEquals(1, $count); + } + + public function OnlyOneConnection3(FunctionalTester $I) + { + $count = SqlliteHelper::connectionCount(); + $I->assertEquals(1, $count); + } +} \ No newline at end of file diff --git a/tests/cases/closeConnectionsNoCleanup/functional/ThirdCest.php b/tests/cases/closeConnectionsNoCleanup/functional/ThirdCest.php new file mode 100644 index 0000000..0cbc42e --- /dev/null +++ b/tests/cases/closeConnectionsNoCleanup/functional/ThirdCest.php @@ -0,0 +1,40 @@ +assertEquals(0, $count); + } + + public function OnlyOneConnection2(FunctionalTester $I) + { + $I->haveFixtures([ + [ + 'class' => EmptyFixture::class, + ], + ]); + + $count = SqlliteHelper::connectionCount(); + $I->assertEquals(1, $count); + } + + public function OnlyOneConnection3(FunctionalTester $I) + { + $I->haveFixtures([ + [ + 'class' => EmptyFixture::class, + ], + ]); + + $count = SqlliteHelper::connectionCount(); + $I->assertEquals(1, $count); + } +} \ No newline at end of file diff --git a/tests/cases/events/codeception.yml b/tests/cases/events/codeception.yml new file mode 100644 index 0000000..caf01d1 --- /dev/null +++ b/tests/cases/events/codeception.yml @@ -0,0 +1,15 @@ +paths: + tests: . + log: ../../_output + data: _data + support: ../../_support +namespace: tests\ +extensions: + enabled: + - Codeception\Extension\RunFailed +modules: + config: + Yii2: + configFile: config.php + transaction: true + cleanup: true \ No newline at end of file diff --git a/tests/cases/events/config.php b/tests/cases/events/config.php new file mode 100644 index 0000000..09869fd --- /dev/null +++ b/tests/cases/events/config.php @@ -0,0 +1,22 @@ + 'Response Events', + 'basePath' => __DIR__, + 'bootstrap' => [ + function(\yii\web\Application $application) { + $application->response->on(\yii\web\Response::EVENT_BEFORE_SEND, function($event) use ($application) { + $application->trigger('responseBeforeSendBootstrap'); + }); + } + ], + 'components' => [ + 'request' => [ + 'cookieValidationKey' => 'secret' + ], + 'response' => [ + 'on beforeSend' => function() { + \Yii::$app->trigger('responseBeforeSendConfig'); + } + ] + ] +]; \ No newline at end of file diff --git a/tests/cases/events/controllers/SiteController.php b/tests/cases/events/controllers/SiteController.php new file mode 100644 index 0000000..abcc66a --- /dev/null +++ b/tests/cases/events/controllers/SiteController.php @@ -0,0 +1,13 @@ +on('responseBeforeSendConfig', function(Event $event) use (&$sources) { + $sources[] = 'config'; + }); + \Yii::$app->on('responseBeforeSendBootstrap', function(Event $event) use (&$sources) { + $sources[] = 'bootstrap'; + }); + $I->assertEmpty($sources); + $I->amOnPage('/'); + $I->assertEquals(['config', 'bootstrap'], $sources); + + $sources = []; + $I->amOnPage('/'); + $I->assertEquals(['config', 'bootstrap'], $sources); + + } + + public function testAfterSendWithRecreate(FunctionalTester $I, \Codeception\Module\Yii2 $module) + { + $module->_reconfigure([ + 'responseCleanMethod' => Yii2::CLEAN_RECREATE + ]); + $module->client->startApp(); + $sources = []; + \Yii::$app->on('responseBeforeSendConfig', function(Event $event) use (&$sources) { + $sources[] = 'config'; + }); + \Yii::$app->on('responseBeforeSendBootstrap', function(Event $event) use (&$sources) { + $sources[] = 'bootstrap'; + }); + $I->assertEmpty($sources); + $I->amOnPage('/'); + $I->assertEquals(['config', 'bootstrap'], $sources); + + $sources = []; + $I->amOnPage('/'); + + // The module should fall back to the CLEAN_CLEAR method and keep event handlers intact. + $I->assertEquals(['config', 'bootstrap'], $sources); + + } + + public function testAfterSendWithForcedRecreate(FunctionalTester $I, \Codeception\Module\Yii2 $module) + { + $module->_reconfigure([ + 'responseCleanMethod' => Yii2::CLEAN_FORCE_RECREATE + ]); + $module->client->startApp(); + $sources = []; + \Yii::$app->on('responseBeforeSendConfig', function(Event $event) use (&$sources) { + $sources[] = 'config'; + }); + \Yii::$app->on('responseBeforeSendBootstrap', function(Event $event) use (&$sources) { + $sources[] = 'bootstrap'; + }); + + $I->assertEmpty($sources); + $I->amOnPage('/'); + + // 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('/'); + + // We recreated the response component, since it has an event handler in its config + // that event handler will still work. + $I->assertEquals(['config'], $sources); + + } +} \ No newline at end of file diff --git a/tests/cases/locale-urls/codeception.yml b/tests/cases/locale-urls/codeception.yml new file mode 100644 index 0000000..caf01d1 --- /dev/null +++ b/tests/cases/locale-urls/codeception.yml @@ -0,0 +1,15 @@ +paths: + tests: . + log: ../../_output + data: _data + support: ../../_support +namespace: tests\ +extensions: + enabled: + - Codeception\Extension\RunFailed +modules: + config: + Yii2: + configFile: config.php + transaction: true + cleanup: true \ No newline at end of file diff --git a/tests/cases/locale-urls/config.php b/tests/cases/locale-urls/config.php new file mode 100644 index 0000000..101c377 --- /dev/null +++ b/tests/cases/locale-urls/config.php @@ -0,0 +1,31 @@ + 'Simple', + 'basePath' => __DIR__, + 'controllerNamespace' => 'app\localeurls\controllers', + 'components' => [ + 'request' => [ + 'enableCsrfValidation' => false, + 'cookieValidationKey' => 'test' + ], + 'urlManager' => [ + 'class' => UrlManager::class, + 'enablePrettyUrl' => true, + 'showScriptName' => false, + 'enableLanguagePersistence' => false, + 'enableLocaleUrls' => true, + 'languages' => ['nl', 'en'] + ] + ], + 'on beforeRequest' => function(\yii\base\Event $event) { + $app = $event->sender; + if ($app->has('urlManager', true)) { + $config = $app->getComponents()['urlManager']; + \Codeception\Util\Debug::debug('Resetting url manager: ' . print_r($config, true)); + $app->set('urlManager', $config); + } + } +]; \ No newline at end of file diff --git a/tests/cases/locale-urls/controllers/SiteController.php b/tests/cases/locale-urls/controllers/SiteController.php new file mode 100644 index 0000000..d68f82a --- /dev/null +++ b/tests/cases/locale-urls/controllers/SiteController.php @@ -0,0 +1,33 @@ + + +
+ +Submit +
+ + + + +HTML; + + } + + public function actionPost() + { + \Yii::$app->response->statusCode = 201; + return print_r(\Yii::$app->request->bodyParams, true); + } +} \ No newline at end of file diff --git a/tests/cases/locale-urls/functional.suite.yml b/tests/cases/locale-urls/functional.suite.yml new file mode 100644 index 0000000..754807a --- /dev/null +++ b/tests/cases/locale-urls/functional.suite.yml @@ -0,0 +1,13 @@ +# 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: + - Yii2 + - Asserts +steps: + - Codeception\Step\ConditionalAssertion diff --git a/tests/cases/locale-urls/functional/LocaleUrlCest.php b/tests/cases/locale-urls/functional/LocaleUrlCest.php new file mode 100644 index 0000000..a945cb4 --- /dev/null +++ b/tests/cases/locale-urls/functional/LocaleUrlCest.php @@ -0,0 +1,40 @@ +assertInstanceOf(Application::class, \Yii::$app); + } + + public function testMultipleGet(FunctionalTester $I) + { + $I->amOnPage('/en/site/form'); + $I->amOnPage('/en/site/form'); + } + public function testFormSubmit(FunctionalTester $I) + { + $I->amOnPage(['site/form']); + $I->seeResponseCodeIs(200); + + $I->fillField('#test', 'test'); + $I->click('#submit'); + $I->canSeeResponseCodeIs(201); + } + + public function testFormSubmit2(FunctionalTester $I) + { + $I->amOnPage('/en/site/form'); + $I->seeResponseCodeIs(200); + $I->submitForm('form', [ + 'login-form[login]' => 'user', + 'login-form[password]' => 'test', + ]); + $I->canSeeResponseCodeIs(201); + } + +} \ No newline at end of file diff --git a/tests/cases/mock-mailer/codeception.yml b/tests/cases/mock-mailer/codeception.yml new file mode 100644 index 0000000..b0d1647 --- /dev/null +++ b/tests/cases/mock-mailer/codeception.yml @@ -0,0 +1,14 @@ +paths: + tests: . + log: ../../_output + data: _data + support: ../../_support +namespace: tests\ +extensions: + enabled: + - Codeception\Extension\RunFailed +modules: + config: + Yii2: + configFile: config.php + recreateApplication: true diff --git a/tests/cases/mock-mailer/config.php b/tests/cases/mock-mailer/config.php new file mode 100644 index 0000000..e6bd0ae --- /dev/null +++ b/tests/cases/mock-mailer/config.php @@ -0,0 +1,15 @@ + 'Simple', + 'basePath' => __DIR__, + 'controllerNamespace' => 'app\mockmailer\controllers', + 'components' => [ + 'request' => [ + 'enableCsrfValidation' => false, + 'cookieValidationKey' => 'test' + ], + 'mailer' => [ + 'class' => 'yii\swiftmailer\Mailer', + ], + ], +]; diff --git a/tests/cases/mock-mailer/controllers/SiteController.php b/tests/cases/mock-mailer/controllers/SiteController.php new file mode 100644 index 0000000..644557c --- /dev/null +++ b/tests/cases/mock-mailer/controllers/SiteController.php @@ -0,0 +1,39 @@ +doSendMail(); + + return __METHOD__; + } + + public function actionSendMailWithRedirect() + { + $this->doSendMail(); + + return $this->redirect(['site/index']); + } + + private function doSendMail() + { + return \Yii::$app->mailer->compose() + ->setFrom('from@domain.com') + ->setTo('to@domain.com') + ->setSubject('Message subject') + ->setTextBody('Plain text content') + ->setHtmlBody('HTML content') + ->send() + ; + } +} diff --git a/tests/cases/mock-mailer/functional.suite.yml b/tests/cases/mock-mailer/functional.suite.yml new file mode 100644 index 0000000..d2d1a2f --- /dev/null +++ b/tests/cases/mock-mailer/functional.suite.yml @@ -0,0 +1,11 @@ +# 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: + - Yii2 + - Asserts \ No newline at end of file diff --git a/tests/cases/mock-mailer/functional/MockMailerCest.php b/tests/cases/mock-mailer/functional/MockMailerCest.php new file mode 100644 index 0000000..78ff126 --- /dev/null +++ b/tests/cases/mock-mailer/functional/MockMailerCest.php @@ -0,0 +1,26 @@ +assertInstanceOf(Application::class, \Yii::$app); + } + + public function testCountMailSentWithoutRedirect(FunctionalTester $I) + { + $I->amOnPage(['site/send-mail-without-redirect']); + + $I->seeEmailIsSent(1); + } + + public function testCountMailSentWithRedirect(FunctionalTester $I) + { + $I->amOnPage(['site/send-mail-with-redirect']); + + $I->seeEmailIsSent(1); + } +} diff --git a/tests/cases/pageCacheHeaderAlreadySent/codeception.yml b/tests/cases/pageCacheHeaderAlreadySent/codeception.yml new file mode 100644 index 0000000..01393b5 --- /dev/null +++ b/tests/cases/pageCacheHeaderAlreadySent/codeception.yml @@ -0,0 +1,13 @@ +paths: + tests: . + log: ../../_output + data: _data + support: ../../_support +namespace: tests\ +extensions: + enabled: + - Codeception\Extension\RunFailed +modules: + config: + Yii2: + configFile: config.php \ No newline at end of file diff --git a/tests/cases/pageCacheHeaderAlreadySent/config.php b/tests/cases/pageCacheHeaderAlreadySent/config.php new file mode 100644 index 0000000..b65fa02 --- /dev/null +++ b/tests/cases/pageCacheHeaderAlreadySent/config.php @@ -0,0 +1,12 @@ + 'PageCache', + 'basePath' => __DIR__, + 'controllerNamespace' => 'app\pageCacheHeaderAlreadySent\controllers', + 'components' => [ + 'cache' => [ + 'class' => \yii\caching\DummyCache::class, + ], + ], +]; diff --git a/tests/cases/pageCacheHeaderAlreadySent/controllers/UserController.php b/tests/cases/pageCacheHeaderAlreadySent/controllers/UserController.php new file mode 100644 index 0000000..ef8b022 --- /dev/null +++ b/tests/cases/pageCacheHeaderAlreadySent/controllers/UserController.php @@ -0,0 +1,22 @@ + [ + 'class' => PageCache::class + ] + ]; + } + + public function actionIndex() + { + return 'test'; + } +} diff --git a/tests/cases/pageCacheHeaderAlreadySent/functional.suite.yml b/tests/cases/pageCacheHeaderAlreadySent/functional.suite.yml new file mode 100644 index 0000000..42a4352 --- /dev/null +++ b/tests/cases/pageCacheHeaderAlreadySent/functional.suite.yml @@ -0,0 +1,12 @@ +# Codeception Test Suite Configuration +# +# Suite for api tests +# Include one of framework modules (Symfony2, Yii2, Laravel5) to use it +# Remove this suite if you don't use frameworks +actor: FunctionalTester +modules: + enabled: + - Yii2 + - Asserts +steps: + - Codeception\Step\ConditionalAssertion diff --git a/tests/cases/pageCacheHeaderAlreadySent/functional/PageCest.php b/tests/cases/pageCacheHeaderAlreadySent/functional/PageCest.php new file mode 100644 index 0000000..6d9c545 --- /dev/null +++ b/tests/cases/pageCacheHeaderAlreadySent/functional/PageCest.php @@ -0,0 +1,13 @@ +amOnPage(['user/index']); + $I->canSeeResponseCodeIs(200); + + $I->amOnPage(['user/index']); + $I->canSeeResponseCodeIs(200); + } +} \ No newline at end of file diff --git a/tests/cases/simple/codeception.yml b/tests/cases/simple/codeception.yml new file mode 100644 index 0000000..cb08201 --- /dev/null +++ b/tests/cases/simple/codeception.yml @@ -0,0 +1,18 @@ +paths: + tests: . + log: ../../_output + data: _data + support: ../../_support +namespace: tests\ +extensions: + enabled: + - Codeception\Extension\RunFailed +settings: + shuffle: true + coolstuff: false +modules: + config: + Yii2: + configFile: config.php + transaction: true + cleanup: true \ No newline at end of file diff --git a/tests/cases/simple/config.php b/tests/cases/simple/config.php new file mode 100644 index 0000000..2e11ee3 --- /dev/null +++ b/tests/cases/simple/config.php @@ -0,0 +1,23 @@ + 'Simple', + 'basePath' => __DIR__, + 'controllerNamespace' => 'app\simple\controllers', + 'components' => [ + 'request' => [ + 'enableCsrfValidation' => false, + 'cookieValidationKey' => 'test' + ], + 'user' => [ + 'identityClass' => DummyUser::class + ] + ], + 'on beforeRequest' => function() { + if (isset(\Yii::$app->params['throw'])) { + throw \Yii::$app->params['throw']; + } + } +]; \ No newline at end of file diff --git a/tests/cases/simple/controllers/SiteController.php b/tests/cases/simple/controllers/SiteController.php new file mode 100644 index 0000000..7d8a550 --- /dev/null +++ b/tests/cases/simple/controllers/SiteController.php @@ -0,0 +1,72 @@ + + +
+ +Submit +
+ + + + +HTML; + + } + + public function actionPost() + { + \Yii::$app->response->statusCode = 201; + return print_r(\Yii::$app->request->bodyParams, true); + } + + public function actionException() + { + throw new \Exception('This is not an HttpException'); + } + + public function actionEnd() + { + \Yii::$app->response->statusCode = 500; + \Yii::$app->end(); + } + + + /** + * @param Action $action + * @return bool + * @throws \yii\web\BadRequestHttpException + */ + public function beforeAction($action) + { + if ($action->id === 'empty-response') { + \Yii::$app->response->stream = fopen('php://memory', 'r+'); + \Yii::$app->response->content = new EmptyString('Empty!'); + return false; + } + return parent::beforeAction($action); + } + + public function actionEmptyResponse() + { + // Dummy + } + + public function actionIndex() + { + return ''; + } +} \ No newline at end of file diff --git a/tests/cases/simple/functional.suite.yml b/tests/cases/simple/functional.suite.yml new file mode 100644 index 0000000..6da4e38 --- /dev/null +++ b/tests/cases/simple/functional.suite.yml @@ -0,0 +1,13 @@ +# 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: + - Yii2 + - Asserts +steps: + - Codeception\Step\ConditionalAssertion diff --git a/tests/cases/simple/functional/SimpleCest.php b/tests/cases/simple/functional/SimpleCest.php new file mode 100644 index 0000000..b171f9b --- /dev/null +++ b/tests/cases/simple/functional/SimpleCest.php @@ -0,0 +1,74 @@ +assertInstanceOf(Application::class, \Yii::$app); + } + + public function testFormSubmit(FunctionalTester $I) + { + $I->amOnPage(['site/form']); + $I->seeResponseCodeIs(200); + + $I->fillField('#test', 'test'); + $I->click('#submit'); + $I->canSeeResponseCodeIs(201); + } + + public function testFormSubmit2(FunctionalTester $I) + { + $I->amOnPage(['site/form']); + $I->seeResponseCodeIs(200); + $I->submitForm('form', [ + 'login-form[login]' => 'user', + 'login-form[password]' => 'test', + ]); + $I->canSeeResponseCodeIs(201); + } + + public function testException(FunctionalTester $I) + { + $I->expectException(new \Exception('This is not an HttpException'), function() use ($I) { + $I->amOnPage(['site/exception']); + }); + $I->assertInstanceOf(Application::class, \Yii::$app); + } + + 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']); + }); + } + + public function testExitException(FunctionalTester $I) + { + $I->amOnPage(['site/end']); + $I->seeResponseCodeIs(500); + } + + public function testEmptyResponse(FunctionalTester $I) + { + $I->amOnPage(['site/empty-response']); + $I->seeResponseCodeIs(200); + } + + public function testMissingUser(FunctionalTester $I) + { + $I->expectException(ModuleException::class, function() use ($I) { + $I->amLoggedInAs('nobody'); + }); + $I->amOnPage('site/index'); + $I->assertTrue(\Yii::$app->user->isGuest); + } +} \ No newline at end of file diff --git a/tests/cases/simple/helpers/DummyUser.php b/tests/cases/simple/helpers/DummyUser.php new file mode 100644 index 0000000..8d38582 --- /dev/null +++ b/tests/cases/simple/helpers/DummyUser.php @@ -0,0 +1,77 @@ +value = $value; + } + + public function getValue() + { + return $this->value; + } + + public function __toString() + { + return ''; + } +} \ No newline at end of file diff --git a/tests/cases/sqlite/codeception.yml b/tests/cases/sqlite/codeception.yml new file mode 100644 index 0000000..caf01d1 --- /dev/null +++ b/tests/cases/sqlite/codeception.yml @@ -0,0 +1,15 @@ +paths: + tests: . + log: ../../_output + data: _data + support: ../../_support +namespace: tests\ +extensions: + enabled: + - Codeception\Extension\RunFailed +modules: + config: + Yii2: + configFile: config.php + transaction: true + cleanup: true \ No newline at end of file diff --git a/tests/cases/sqlite/config.php b/tests/cases/sqlite/config.php new file mode 100644 index 0000000..e20ed92 --- /dev/null +++ b/tests/cases/sqlite/config.php @@ -0,0 +1,24 @@ + 'Simple', + 'basePath' => __DIR__, + + 'components' => [ + 'db' => [ + 'class' => yii\db\Connection::class, + 'dsn' => 'sqlite:' . tempnam(null, '/file0') + ], + 'db1' => [ + 'class' => yii\db\Connection::class, + 'dsn' => 'sqlite:' . tempnam(null, '/file1') + ], + 'db21' => [ + 'class' => yii\db\Connection::class, + 'dsn' => 'sqlite:' . ($name = tempnam(null, '/file2')) + ], + 'db22' => [ + 'class' => yii\db\Connection::class, + 'dsn' => 'sqlite:' . $name + ] + ] +]; \ No newline at end of file diff --git a/tests/cases/sqlite/fixtures/TestFixture.php b/tests/cases/sqlite/fixtures/TestFixture.php new file mode 100644 index 0000000..f57b62f --- /dev/null +++ b/tests/cases/sqlite/fixtures/TestFixture.php @@ -0,0 +1,36 @@ + 'int' + ]; + + public $dbComponents = []; + + public function load() { + foreach($this->dbComponents as $name) { + /** @var Connection $connection */ + $connection = \Yii::$app->get($name); + $connection->createCommand()->createTable($this->tableName, $this->tableConfig)->execute(); + } + } + + public function unload() + { + foreach($this->dbComponents as $name) { + /** @var Connection $connection */ + $connection = \Yii::$app->get($name); + if (in_array($this->tableName, $connection->getSchema()->getTableNames('', true))) { + $connection->createCommand()->dropTable($this->tableName)->execute(); + } + } + } +} \ No newline at end of file diff --git a/tests/cases/sqlite/functional.suite.yml b/tests/cases/sqlite/functional.suite.yml new file mode 100644 index 0000000..f582374 --- /dev/null +++ b/tests/cases/sqlite/functional.suite.yml @@ -0,0 +1,13 @@ +# 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: + - Yii2 + - Asserts +steps: + - Codeception\Step\ConditionalAssertion diff --git a/tests/cases/sqlite/functional/SqLiteCest.php b/tests/cases/sqlite/functional/SqLiteCest.php new file mode 100644 index 0000000..a581be8 --- /dev/null +++ b/tests/cases/sqlite/functional/SqLiteCest.php @@ -0,0 +1,46 @@ + TestFixture::class, + 'dbComponents' => ['db1', 'db21'] + ], + ]; + } + + public function testSharedPDO(FunctionalTester $I) + { + /** @var Connection $db1 */ + $db1 = $I->grabComponent('db1'); + $I->assertEquals(['test'], $db1->schema->getTableNames('', true)); + + /** @var Connection $db21 */ + $db21 = $I->grabComponent('db21'); + $I->assertEquals(['test'], $db21->schema->getTableNames('', true)); + + /** @var Connection $db22 */ + $db22 = $I->grabComponent('db22'); + + $I->assertEquals(['test'], $db22->schema->getTableNames('', true)); + } + + public function testTransaction(FunctionalTester $I) + { + /** @var Connection $db1 */ + $db1 = $I->grabComponent('db1'); + $I->assertFalse($db1->isActive); + $db1->open(); + $I->assertNotNull($db1->getTransaction()); + } +} diff --git a/tests/cases/yii2-app-advanced/codeception.yml b/tests/cases/yii2-app-advanced/codeception.yml new file mode 100644 index 0000000..6dc678b --- /dev/null +++ b/tests/cases/yii2-app-advanced/codeception.yml @@ -0,0 +1,15 @@ +namespace: frontend\tests +actor_suffix: Tester +paths: + tests: ../../vendor/yiisoft/yii2-app-advanced/frontend/tests + log: ../../_output + data: ../../vendor/yiisoft/yii2-app-advanced/frontend/tests/_data + support: ../../vendor/yiisoft/yii2-app-advanced/frontend/tests/_support +settings: + bootstrap: _bootstrap.php + colors: true + memory_limit: 1024M +modules: + config: + Yii2: + configFile: 'config.php' diff --git a/tests/cases/yii2-app-advanced/config.php b/tests/cases/yii2-app-advanced/config.php new file mode 100644 index 0000000..ac66135 --- /dev/null +++ b/tests/cases/yii2-app-advanced/config.php @@ -0,0 +1,32 @@ + [ + 'db' => [ + 'class' => yii\db\Connection::class, + 'dsn' => 'sqlite:' . codecept_output_dir('/db.sqlite') + ], + 'request' => [ + 'cookieValidationKey' => 'test' + ], + 'assetManager' => [ + 'basePath' => sys_get_temp_dir() + ], + 'mailer' => [ + 'viewPath' => '@common/mail', + ], + ], + 'aliases' => [ + '@bower' => '@vendor/bower-asset', + '@npm' => '@vendor/npm-asset' + ], + 'vendorPath' => __DIR__ . '/../../vendor' +]); + +return $config; \ No newline at end of file diff --git a/tests/cases/yii2-app-advanced/migrate.php b/tests/cases/yii2-app-advanced/migrate.php new file mode 100644 index 0000000..2257236 --- /dev/null +++ b/tests/cases/yii2-app-advanced/migrate.php @@ -0,0 +1,17 @@ + [ + 'db' => [ + 'class' => yii\db\Connection::class, + 'dsn' => 'sqlite:' . __DIR__ . '/_data/db.sqlite' + ], + ], + 'vendorPath' => __DIR__ . '/../../vendor' +]); + +return $config; From 4f43dc70afe9739ae9678f04b5f4884b814d1988 Mon Sep 17 00:00:00 2001 From: DBX12 Date: Tue, 26 Oct 2021 08:18:24 +0200 Subject: [PATCH 05/12] Configure autoload-dev --- composer.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/composer.json b/composer.json index c137edc..8dfa85f 100644 --- a/composer.json +++ b/composer.json @@ -33,6 +33,12 @@ "autoload":{ "classmap": ["src/"] }, + "autoload-dev": { + "classmap": [ + "vendor/yiisoft/yii2/Yii.php", + "tests/cases" + ] + }, "config": { "classmap-authoritative": true } From a2daff5b6563ad0ca82d80b05ecc8a3462182533 Mon Sep 17 00:00:00 2001 From: DBX12 Date: Tue, 26 Oct 2021 08:20:31 +0200 Subject: [PATCH 06/12] Correct paths used in tests --- tests/bootstrap.php | 6 +++--- tests/cases/yii2-app-advanced/codeception.yml | 6 +++--- tests/cases/yii2-app-advanced/config.php | 8 ++++---- tests/cases/yii2-app-advanced/migrate.php | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 5f5e8d1..a5c8389 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -3,7 +3,7 @@ defined('YII_ENV') || define('YII_ENV', 'test'); call_user_func(function() { - $loader = require __DIR__ . '/vendor/autoload.php'; + $loader = require __DIR__ . '/../vendor/autoload.php'; $container = new \yii\di\Container(); // call_user_func(function() use ($container) { @@ -14,7 +14,7 @@ Yii::$container = $container; }); -$link = __DIR__ . '/vendor/yiisoft/yii2-app-advanced/vendor'; -if (!file_exists($link) && !symlink(__DIR__ . '/vendor', $link)) { +$link = __DIR__ . '/../vendor/yiisoft/yii2-app-advanced/vendor'; +if (!file_exists($link) && !symlink(__DIR__ . '/../vendor', $link)) { die('failed to create symlink'); } \ No newline at end of file diff --git a/tests/cases/yii2-app-advanced/codeception.yml b/tests/cases/yii2-app-advanced/codeception.yml index 6dc678b..5cface3 100644 --- a/tests/cases/yii2-app-advanced/codeception.yml +++ b/tests/cases/yii2-app-advanced/codeception.yml @@ -1,10 +1,10 @@ namespace: frontend\tests actor_suffix: Tester paths: - tests: ../../vendor/yiisoft/yii2-app-advanced/frontend/tests + tests: ../../../vendor/yiisoft/yii2-app-advanced/frontend/tests log: ../../_output - data: ../../vendor/yiisoft/yii2-app-advanced/frontend/tests/_data - support: ../../vendor/yiisoft/yii2-app-advanced/frontend/tests/_support + data: ../../../vendor/yiisoft/yii2-app-advanced/frontend/tests/_data + support: ../../../vendor/yiisoft/yii2-app-advanced/frontend/tests/_support settings: bootstrap: _bootstrap.php colors: true diff --git a/tests/cases/yii2-app-advanced/config.php b/tests/cases/yii2-app-advanced/config.php index ac66135..82c61da 100644 --- a/tests/cases/yii2-app-advanced/config.php +++ b/tests/cases/yii2-app-advanced/config.php @@ -1,12 +1,12 @@ [ 'db' => [ 'class' => yii\db\Connection::class, @@ -26,7 +26,7 @@ '@bower' => '@vendor/bower-asset', '@npm' => '@vendor/npm-asset' ], - 'vendorPath' => __DIR__ . '/../../vendor' + 'vendorPath' => __DIR__ . '/../../../vendor' ]); return $config; \ No newline at end of file diff --git a/tests/cases/yii2-app-advanced/migrate.php b/tests/cases/yii2-app-advanced/migrate.php index 2257236..a910536 100644 --- a/tests/cases/yii2-app-advanced/migrate.php +++ b/tests/cases/yii2-app-advanced/migrate.php @@ -1,17 +1,17 @@ [ 'db' => [ 'class' => yii\db\Connection::class, 'dsn' => 'sqlite:' . __DIR__ . '/_data/db.sqlite' ], ], - 'vendorPath' => __DIR__ . '/../../vendor' + 'vendorPath' => __DIR__ . '/../../../vendor' ]); return $config; From 9ef11e3a9c011f19742901ec0acba352899d9411 Mon Sep 17 00:00:00 2001 From: DBX12 Date: Tue, 26 Oct 2021 08:21:20 +0200 Subject: [PATCH 07/12] Move bootstrap setting to top level in config file --- tests/cases/yii2-app-advanced/codeception.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cases/yii2-app-advanced/codeception.yml b/tests/cases/yii2-app-advanced/codeception.yml index 5cface3..744faf9 100644 --- a/tests/cases/yii2-app-advanced/codeception.yml +++ b/tests/cases/yii2-app-advanced/codeception.yml @@ -5,8 +5,8 @@ paths: log: ../../_output data: ../../../vendor/yiisoft/yii2-app-advanced/frontend/tests/_data support: ../../../vendor/yiisoft/yii2-app-advanced/frontend/tests/_support +bootstrap: _bootstrap.php settings: - bootstrap: _bootstrap.php colors: true memory_limit: 1024M modules: From 78685df9f6854de2dc7a3a2a0724f2f4188e6604 Mon Sep 17 00:00:00 2001 From: DBX12 Date: Tue, 26 Oct 2021 08:25:37 +0200 Subject: [PATCH 08/12] Update github workflow --- .github/workflows/main.yml | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d7ef845..d9c509e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,21 +27,7 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-progress --no-interaction --no-suggest - - name: Checkout Yii2 - uses: actions/checkout@v2 - with: - repository: Codeception/yii2-tests - path: framework-tests - - - name: Install Yii2 - run: | - composer require --no-update codeception/module-asserts - composer require --no-update codeception/module-filesystem - composer require --no-update codeception/codeception - composer update --no-dev --prefer-dist --no-interaction - working-directory: framework-tests - - name: Run test suite run: | - php vendor/bin/codecept build -c framework-tests - php vendor/bin/codecept run -c framework-tests + php vendor/bin/codecept build + php vendor/bin/codecept run From e9ecd4863837beff878d71a924435e9c3fb9a7f9 Mon Sep 17 00:00:00 2001 From: DBX12 Date: Tue, 26 Oct 2021 08:28:00 +0200 Subject: [PATCH 09/12] Set export-ignore for dirs tests and .github --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitattributes b/.gitattributes index 9cbc09b..6cdec7d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,3 +4,5 @@ /Robofile.php export-ignore /*.md export-ignore /*.yml export-ignore +/tests export-ignore +/.github export-ignore From 827b5f7c16d3e9e77abc570662855e45e8e6b144 Mon Sep 17 00:00:00 2001 From: DBX12 Date: Tue, 26 Oct 2021 14:04:09 +0200 Subject: [PATCH 10/12] Add repositories entry for asset-packagist.org --- composer.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8dfa85f..5e6d9d2 100644 --- a/composer.json +++ b/composer.json @@ -41,5 +41,11 @@ }, "config": { "classmap-authoritative": true - } + }, + "repositories": [ + { + "type": "composer", + "url": "https://asset-packagist.org" + } + ] } From 95a67d5a3a92374ec62035878a0bfa920e30ab47 Mon Sep 17 00:00:00 2001 From: DBX12 Date: Tue, 26 Oct 2021 14:08:40 +0200 Subject: [PATCH 11/12] Add test database db.sqlite to git --- tests/cases/yii2-app-advanced/_data/db.sqlite | Bin 0 -> 32768 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/cases/yii2-app-advanced/_data/db.sqlite diff --git a/tests/cases/yii2-app-advanced/_data/db.sqlite b/tests/cases/yii2-app-advanced/_data/db.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..5f5d7933220a208e4d44275b0cfe92b6e14d9bf1 GIT binary patch literal 32768 zcmeI*O-~a+7zglKwzN=$^-`Ol2@@{RK+J9niNu2zSrcL@FSZAa$?nh&bVJ|R-J+Zf z(QwwAAH$2^Koj)l-J^-|>cMz)rqC`eG$bZU()=g1JG=ADZs#|%o6Ho#>{4pUKRM8nSMc zRk%&}nOi6^cRD#gpJ<2Be0F&~Z^}s4@JrS%KL{dI$skZh)S2f!tGPw1#Jo}v)^Wm) zIG20exBS{JuXcq8m*o}al)Fk>4LI}ZJfHau&!%35mCJ%4Xu*>CFrCljsG-Yi7hKMK zUbL7WNVQHU%NzA#&+_OjwfDK}Y&!+!JGJVCpIpMy)-~l$Vl5Jm&&(*B%`Wuz%3{uA zd3>+Is|DV*JJiv!U4_%KpJqkPg!Wr`eWl|P7w-_53Wwu&V+wJqMgIJ>*Tn5oYwla} z7PC_FJu)?TX<$+YhNnW81{yMO@P!hIPfRF>E6veWadzD1&}?T0I!2V;K7R7N5Tn@> z139?8j5~U8PoI5+$a{m;>*WK>cjVLJ^eGcf7z5$BInk@_?dw@aJ1gh%&AI)k$f(*Y zqJ7hj#Rdri5P$##AOHafKmY;|fB*y_0D*rbu&9O(l~Bc4(2eArWf*!=*DY2oTIUzK ztU|5asK`~XlO>Jjio?^lpUL=uni8i->GR?gN!^&6OIl9V@t=J7dOWVkGQF9s)6Ew1 zxF~xc6>U Date: Wed, 27 Oct 2021 11:10:15 +0200 Subject: [PATCH 12/12] Remove commented code and unused variable $loader --- tests/bootstrap.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index a5c8389..71170fb 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,19 +2,9 @@ defined('YII_DEBUG') || define('YII_DEBUG', true); defined('YII_ENV') || define('YII_ENV', 'test'); -call_user_func(function() { - $loader = require __DIR__ . '/../vendor/autoload.php'; - - $container = new \yii\di\Container(); -// call_user_func(function() use ($container) { -// require __DIR__ .'/../src/config/di.php'; -// }); - -// Yii::$loader = $loader; - Yii::$container = $container; -}); +Yii::$container = new \yii\di\Container(); $link = __DIR__ . '/../vendor/yiisoft/yii2-app-advanced/vendor'; if (!file_exists($link) && !symlink(__DIR__ . '/../vendor', $link)) { die('failed to create symlink'); -} \ No newline at end of file +}