From cecc76a2d68295c4d26e2c5737862d5331d7ca67 Mon Sep 17 00:00:00 2001 From: Ben Croker Date: Mon, 19 Aug 2019 08:46:11 +0200 Subject: [PATCH 01/11] Update codeception.yml --- codeception.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codeception.yml b/codeception.yml index 005d2b824c5..a54d03e64e3 100644 --- a/codeception.yml +++ b/codeception.yml @@ -5,8 +5,8 @@ paths: data: tests/_data support: tests/_support envs: tests/_envs +bootstrap: _bootstrap.php settings: - bootstrap: _bootstrap.php colors: true memory_limit: 2048M coverage: @@ -60,4 +60,4 @@ groups: test: [tests/unit/test] validators: [tests/unit/validators] web: [tests/unit/web] - app: [tests/unit/AppTest.php] \ No newline at end of file + app: [tests/unit/AppTest.php] From 8dd24c2698c38b55dcd994a1e382abe7e51d31d1 Mon Sep 17 00:00:00 2001 From: Ben Croker Date: Mon, 19 Aug 2019 08:47:39 +0200 Subject: [PATCH 02/11] Update getting-started.md --- docs/testing/testing-craft/getting-started.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/testing/testing-craft/getting-started.md b/docs/testing/testing-craft/getting-started.md index 99cff3e365f..4621dc8e15c 100644 --- a/docs/testing/testing-craft/getting-started.md +++ b/docs/testing/testing-craft/getting-started.md @@ -49,8 +49,7 @@ paths: data: tests/_data support: tests/_support envs: tests/_envs -settings: - bootstrap: _bootstrap.php +bootstrap: _bootstrap.php params: - tests/.env modules: From 4aaebbd2d0c355a77b6cfc7a23288e3798485d64 Mon Sep 17 00:00:00 2001 From: Ben Croker Date: Mon, 19 Aug 2019 08:49:54 +0200 Subject: [PATCH 03/11] Prevent `headers already sent` error when running tests in PhpStorm --- docs/testing/testing-craft/getting-started.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/testing/testing-craft/getting-started.md b/docs/testing/testing-craft/getting-started.md index 4621dc8e15c..749d4364b82 100644 --- a/docs/testing/testing-craft/getting-started.md +++ b/docs/testing/testing-craft/getting-started.md @@ -108,6 +108,9 @@ define('CRAFT_TRANSLATIONS_PATH', __DIR__ . '/_craft/translations'); define('CRAFT_VENDOR_PATH', dirname(__DIR__).'/vendor'); TestSetup::configureCraft(); + +// Prevent `headers already sent` error when running tests in PhpStorm +ob_start (); ``` ### Required `Craft::$app` setup code From 7ddfae84dab116fff2c0700eb54c20178605c924 Mon Sep 17 00:00:00 2001 From: Ben Croker Date: Mon, 19 Aug 2019 08:54:51 +0200 Subject: [PATCH 04/11] Update getting-started.md --- docs/testing/testing-craft/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/testing/testing-craft/getting-started.md b/docs/testing/testing-craft/getting-started.md index 749d4364b82..6901b83a8f4 100644 --- a/docs/testing/testing-craft/getting-started.md +++ b/docs/testing/testing-craft/getting-started.md @@ -110,7 +110,7 @@ define('CRAFT_VENDOR_PATH', dirname(__DIR__).'/vendor'); TestSetup::configureCraft(); // Prevent `headers already sent` error when running tests in PhpStorm -ob_start (); +ob_start(); ``` ### Required `Craft::$app` setup code From e3d1eba2a14b03eb87b5ba7cf55cc44522f23b07 Mon Sep 17 00:00:00 2001 From: lemiwinkz Date: Mon, 19 Aug 2019 11:36:58 +0200 Subject: [PATCH 05/11] 3.0 => 3.1 --- composer.json | 2 +- composer.lock | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 9315db5d76e..d27b25b279d 100644 --- a/composer.json +++ b/composer.json @@ -52,7 +52,7 @@ "zendframework/zend-feed": "^2.8.0" }, "require-dev": { - "codeception/codeception": "^3.0", + "codeception/codeception": "^3.1", "codeception/mockery-module": "^0.3", "codeception/phpunit-wrapper": "^7.7", "codeception/specify": "^0.4", diff --git a/composer.lock b/composer.lock index 8252605cd99..8a284473571 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8c7cc8eee6ad166d0697b16203122521", + "content-hash": "1d2ecf568567401e5037bcc997796545", "packages": [ { "name": "cebe/markdown", @@ -3200,22 +3200,22 @@ }, { "name": "codeception/codeception", - "version": "3.0.3", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/Codeception/Codeception.git", - "reference": "feb566a9dc26993611602011ae3834d8e3c1dd7f" + "reference": "9ed9146567770e564fdd2b656edb385330f7fae7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/Codeception/zipball/feb566a9dc26993611602011ae3834d8e3c1dd7f", - "reference": "feb566a9dc26993611602011ae3834d8e3c1dd7f", + "url": "https://api.github.com/repos/Codeception/Codeception/zipball/9ed9146567770e564fdd2b656edb385330f7fae7", + "reference": "9ed9146567770e564fdd2b656edb385330f7fae7", "shasum": "" }, "require": { "behat/gherkin": "^4.4.0", "codeception/phpunit-wrapper": ">6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.0.3", - "codeception/stub": "^2.0", + "codeception/stub": "^2.0 | ^3.0", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", @@ -3235,6 +3235,7 @@ "require-dev": { "codeception/specify": "~0.3", "doctrine/annotations": "^1", + "doctrine/data-fixtures": "^1", "doctrine/orm": "^2", "flow/jsonpath": "~0.2", "monolog/monolog": "~1.8", @@ -3290,7 +3291,7 @@ "functional testing", "unit testing" ], - "time": "2019-07-18T16:21:08+00:00" + "time": "2019-08-18T16:44:20+00:00" }, { "name": "codeception/mockery-module", From 78554eff5a6593d0ecb0867bba69e550a31a0e0a Mon Sep 17 00:00:00 2001 From: lemiwinkz Date: Mon, 19 Aug 2019 12:16:11 +0200 Subject: [PATCH 06/11] Autoload the Craft fixtures in composer --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d27b25b279d..80240943b9b 100644 --- a/composer.json +++ b/composer.json @@ -78,7 +78,8 @@ }, "autoload": { "psr-4": { - "craft\\": "src/" + "craft\\": "src/", + "crafttests\\fixtures\\": "tests/fixtures/" } } } From 37232632574afc1187fc3d9b2bade3f5f0cdf8d9 Mon Sep 17 00:00:00 2001 From: Ben Croker Date: Mon, 19 Aug 2019 13:31:02 +0200 Subject: [PATCH 07/11] Prevent `headers already sent` error when running tests in PhpStorm --- src/test/TestSetup.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/TestSetup.php b/src/test/TestSetup.php index dd45b0aea02..5a161f47239 100644 --- a/src/test/TestSetup.php +++ b/src/test/TestSetup.php @@ -321,6 +321,9 @@ public static function configureCraft(): bool Craft::setAlias('@templates', $templatesPath); Craft::setAlias('@translations', $translationsPath); + // Prevent `headers already sent` error when running tests in PhpStorm + ob_start (); + return true; } From 342765911e8921ae08e693bb856ac68a5b8c2983 Mon Sep 17 00:00:00 2001 From: Ben Croker Date: Mon, 19 Aug 2019 13:32:26 +0200 Subject: [PATCH 08/11] Revert --- docs/testing/testing-craft/getting-started.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/testing/testing-craft/getting-started.md b/docs/testing/testing-craft/getting-started.md index 6901b83a8f4..4621dc8e15c 100644 --- a/docs/testing/testing-craft/getting-started.md +++ b/docs/testing/testing-craft/getting-started.md @@ -108,9 +108,6 @@ define('CRAFT_TRANSLATIONS_PATH', __DIR__ . '/_craft/translations'); define('CRAFT_VENDOR_PATH', dirname(__DIR__).'/vendor'); TestSetup::configureCraft(); - -// Prevent `headers already sent` error when running tests in PhpStorm -ob_start(); ``` ### Required `Craft::$app` setup code From bc77372c5a51be393239ac95209eb0709cedbb19 Mon Sep 17 00:00:00 2001 From: lemiwinkz Date: Fri, 23 Aug 2019 13:20:11 +0200 Subject: [PATCH 09/11] Cleanup No need for these setup classes. --- src/test/internal/example-test-suite/codeception.yml | 2 +- .../example-test-suite/tests/functional/_bootstrap.php | 1 - .../internal/example-test-suite/tests/unit/_bootstrap.php | 1 - tests/acceptance/_bootstrap.php | 3 --- tests/functional/_bootstrap.php | 5 ----- tests/unit/_bootstrap.php | 7 ------- 6 files changed, 1 insertion(+), 18 deletions(-) delete mode 100644 src/test/internal/example-test-suite/tests/functional/_bootstrap.php delete mode 100644 src/test/internal/example-test-suite/tests/unit/_bootstrap.php delete mode 100644 tests/acceptance/_bootstrap.php delete mode 100644 tests/functional/_bootstrap.php delete mode 100644 tests/unit/_bootstrap.php diff --git a/src/test/internal/example-test-suite/codeception.yml b/src/test/internal/example-test-suite/codeception.yml index 7c4ae79f967..d0776038834 100644 --- a/src/test/internal/example-test-suite/codeception.yml +++ b/src/test/internal/example-test-suite/codeception.yml @@ -5,8 +5,8 @@ paths: data: tests/_data support: tests/_support envs: tests/_envs +bootstrap: _bootstrap.php settings: - bootstrap: _bootstrap.php params: - tests/.env modules: diff --git a/src/test/internal/example-test-suite/tests/functional/_bootstrap.php b/src/test/internal/example-test-suite/tests/functional/_bootstrap.php deleted file mode 100644 index b3d9bbc7f37..00000000000 --- a/src/test/internal/example-test-suite/tests/functional/_bootstrap.php +++ /dev/null @@ -1 +0,0 @@ - Date: Fri, 23 Aug 2019 13:29:31 +0200 Subject: [PATCH 10/11] Ensure #8dd24c2698c38b55dcd994a1e382abe7e51d31d1 doesn't cause any confusion --- docs/testing/testing-craft/getting-started.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/testing/testing-craft/getting-started.md b/docs/testing/testing-craft/getting-started.md index 4621dc8e15c..a7e2800c371 100644 --- a/docs/testing/testing-craft/getting-started.md +++ b/docs/testing/testing-craft/getting-started.md @@ -11,9 +11,11 @@ This guide can be used for setting up tests for a Craft site & Modules/Plugins. [[toc]] -## Step 1: Install Codeception 3.x +## Step 1: Install Codeception 3.1 or higher + +Follow instruction 1 and 2 Codeception's [website](https://codeception.com/quickstart). Ensure you install +`codeception/codeception` at `3.1`or higher. -Follow instruction 1 and 2 Codeception's [website](https://codeception.com/quickstart) ::: tip If you are setting up tests for a Craft CMS Site and not a module/plugin, when running `composer install` on production, add the `--no-dev` flag to avoid From 5daf1515ed977a23933e41062a04f3ff7b65d31f Mon Sep 17 00:00:00 2001 From: lemiwinkz Date: Fri, 23 Aug 2019 13:31:06 +0200 Subject: [PATCH 11/11] Personal preference --- src/test/TestSetup.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/TestSetup.php b/src/test/TestSetup.php index 5a161f47239..5022b28e35d 100644 --- a/src/test/TestSetup.php +++ b/src/test/TestSetup.php @@ -322,8 +322,9 @@ public static function configureCraft(): bool Craft::setAlias('@translations', $translationsPath); // Prevent `headers already sent` error when running tests in PhpStorm + // https://stackoverflow.com/questions/31175636/headers-already-sent-running-unit-tests-in-phpstorm ob_start (); - + return true; }