From 45d0f248c6e8c43a6d4ecd76ccb175d875332d4a Mon Sep 17 00:00:00 2001 From: W0rma Date: Mon, 16 Nov 2026 08:41:15 +0100 Subject: [PATCH 01/14] Fix PHP examples in guides that fail with syntax or fatal errors - add missing semicolon / fix invalid use statement (AdvancedUsage) - rename duplicate addUser() method (AdvancedUsage) - close #[Given]/#[Then] attributes and drop duplicated "Given" (BDD) - remove stray quote in strict locator example (AcceptanceTests) - add return/property types required by Codeception 5 interfaces and base classes (ModulesAndHelpers, Customization, Data) - use string assertions for strings and fix undefined variable (ModulesAndHelpers) - assertContain -> assertContains (UnitTests) --- docs/AcceptanceTests.md | 2 +- docs/AdvancedUsage.md | 6 +++--- docs/BDD.md | 6 +++--- docs/Customization.md | 6 +++--- docs/Data.md | 2 +- docs/ModulesAndHelpers.md | 14 +++++++------- docs/UnitTests.md | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/docs/AcceptanceTests.md b/docs/AcceptanceTests.md index 6d51b81d9..6faee3631 100644 --- a/docs/AcceptanceTests.md +++ b/docs/AcceptanceTests.md @@ -462,7 +462,7 @@ It is important to understand that SmartWait works only with a specific locators * `#locator` - CSS ID locator, works * `//locator` - general XPath locator, works -* `['css' => 'button'']` - strict locator, works +* `['css' => 'button']` - strict locator, works But it won't be executed for all other locator types. See the example: diff --git a/docs/AdvancedUsage.md b/docs/AdvancedUsage.md index 16d44070d..295197867 100644 --- a/docs/AdvancedUsage.md +++ b/docs/AdvancedUsage.md @@ -208,7 +208,7 @@ The concept of groups was taken from PHPUnit and behaves in the same way. You ca namespace Tests\Acceptance; use Codeception\Attribute\Group; -use Tests\Support\AcceptanceTester +use Tests\Support\AcceptanceTester; class UserCest { @@ -383,7 +383,7 @@ final class ModeratorCest // But you can also pass multiple methods in each attribute: #[Before('login', 'cleanup')] - public function addUser(FunctionalTester $I): void + public function addAdmin(FunctionalTester $I): void { // ... } @@ -586,7 +586,7 @@ $scenario->current('capabilities'); You can inject `\Codeception\Scenario` like this: ```php -use Codeception\Scenario $scenario; +use Codeception\Scenario; public function myTest(Scenario $scenario) { diff --git a/docs/BDD.md b/docs/BDD.md index 85cbe3d53..c6e5e8d84 100644 --- a/docs/BDD.md +++ b/docs/BDD.md @@ -225,7 +225,7 @@ public function amAuthorized($role) Parameters can be also passed in non-regex strings using ":" params placeholder. ```php -#[Given('Given I am logged in as :role') +#[Given('I am logged in as :role')] ``` This will match any word (passed in double quotes) or a number passed: @@ -399,7 +399,7 @@ Tables is a recommended ways to pass arrays into test scenarios. Inside a step definition data is stored in argument passed as `\Behat\Gherkin\Node\TableNode` instance. ```php - #[Given('i have products in my cart') + #[Given('i have products in my cart')] public function iHaveProductsInCart(\Behat\Gherkin\Node\TableNode $products) { // iterate over all rows @@ -452,7 +452,7 @@ paths: This string is passed as a standard PHP string parameter ```php - #[Then('i see in file :filename') + #[Then('i see in file :filename')] public function seeInFile($fileName, $fileContents) { // note: module "Asserts" is enabled in this suite diff --git a/docs/Customization.md b/docs/Customization.md index 393897afd..c68c9329c 100644 --- a/docs/Customization.md +++ b/docs/Customization.md @@ -459,17 +459,17 @@ class MyFormat implements \Codeception\Test\Loader\LoaderInterface $this->settings = $settings; } - public function loadTests($filename) + public function loadTests(string $filename): void { //Load file and create tests } - public function getTests() + public function getTests(): array { return $this->tests; } - public function getPattern() + public function getPattern(): string { return '~Myformat\.php$~'; } diff --git a/docs/Data.md b/docs/Data.md index 9f9a44d20..0a3877d5c 100644 --- a/docs/Data.md +++ b/docs/Data.md @@ -299,7 +299,7 @@ class Categories extends \Codeception\Snapshot $this->i = $I; } - protected function fetchData() + protected function fetchData(): array|string|false { // fetch texts from all 'a.category' elements on a page return $this->i->grabMultiple('a.category'); diff --git a/docs/ModulesAndHelpers.md b/docs/ModulesAndHelpers.md index c7812133d..aa260dd2e 100644 --- a/docs/ModulesAndHelpers.md +++ b/docs/ModulesAndHelpers.md @@ -64,7 +64,7 @@ it might declare a conflict rule to be used with other modules. For instance, We with all modules implementing the `Codeception\Lib\Interfaces\Web` interface. ```php -public function _conflicts() +public function _conflicts(): string { return 'Codeception\Lib\Interfaces\Web'; } @@ -189,10 +189,10 @@ In your helpers you can use these assertions: function seeCanCheckEverything($thing) { $this->assertTrue(isset($thing), "this thing is set"); - $this->assertFalse(empty($any), "this thing is not empty"); + $this->assertFalse(empty($thing), "this thing is not empty"); $this->assertNotNull($thing, "this thing is not null"); - $this->assertContains("world", $thing, "this thing contains 'world'"); - $this->assertNotContains("bye", $thing, "this thing doesn't contain 'bye'"); + $this->assertStringContainsString("world", $thing, "this thing contains 'world'"); + $this->assertStringNotContainsString("bye", $thing, "this thing doesn't contain 'bye'"); $this->assertEquals("hello world", $thing, "this thing is 'Hello world'!"); // ... } @@ -359,7 +359,7 @@ Here is how it is done in the Db module: ```php class Db extends \Codeception\Module { - protected $requiredFields = ['dsn', 'user', 'password']; + protected array $requiredFields = ['dsn', 'user', 'password']; // ... } ``` @@ -372,8 +372,8 @@ as well as their values. In the WebDriver module we use the default Selenium Ser ```php class WebDriver extends \Codeception\Module { - protected $requiredFields = ['browser', 'url']; - protected $config = ['host' => '127.0.0.1', 'port' => '4444']; + protected array $requiredFields = ['browser', 'url']; + protected array $config = ['host' => '127.0.0.1', 'port' => '4444']; // ... } diff --git a/docs/UnitTests.md b/docs/UnitTests.md index 75a14d3f9..06c52add6 100644 --- a/docs/UnitTests.md +++ b/docs/UnitTests.md @@ -461,7 +461,7 @@ $this->assertUserCanPostToBlog($user, $blog); // instead of just calling a bunch of assertions $this->assertNotNull($user); $this->assertNotNull($blog); -$this->assertContain($user, $blog->getOwners()); +$this->assertContains($user, $blog->getOwners()); ``` With custom assertion methods you can improve readability of your tests and keep them focused around the specification. From 1918fb8b14b219da8fa31613a4ba4c7a5b57b001 Mon Sep 17 00:00:00 2001 From: W0rma Date: Mon, 16 Nov 2026 08:41:50 +0100 Subject: [PATCH 02/14] Fix references to non-existent methods and config keys in guides - grabServiceFromContainer() -> grabService() (Symfony module) - getModuleNames() -> getCurrentModuleNames() (Extension) - remove step.before/after. events, which are never dispatched - step decorators are configured in step_decorators with class names - Db module: repopulate -> populate - SOAP module: response -> xmlResponse - seeEmailIsSent() takes no recipient/subject arguments --- docs/APITesting.md | 4 ++-- docs/Customization.md | 12 +++++------- docs/FunctionalTests.md | 2 +- docs/Introduction.md | 2 +- docs/ModulesAndHelpers.md | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/docs/APITesting.md b/docs/APITesting.md index dc1950dce..84d5e8405 100644 --- a/docs/APITesting.md +++ b/docs/APITesting.md @@ -361,7 +361,7 @@ $I->seeSoapResponseIncludes(\Codeception\Util\Xml::build() It's up to you to decide whether to use `XmlBuilder` or plain XML. `XmlBuilder` will return XML string as well. -You may extend current functionality by using `SOAP` module in your helper class. To access the SOAP response as `\DOMDocument` you can use `response` property of `SOAP` module. +You may extend current functionality by using `SOAP` module in your helper class. To access the SOAP response as `\DOMDocument` you can use `xmlResponse` property of `SOAP` module. ```php getModule('SOAP')->response; + $response = $this->getModule('SOAP')->xmlResponse; $this->assertTrue($response->schemaValidate($schema)); } } diff --git a/docs/Customization.md b/docs/Customization.md index c68c9329c..997404236 100644 --- a/docs/Customization.md +++ b/docs/Customization.md @@ -183,7 +183,7 @@ Extensions have some basic methods you can use: * `writeln` - prints to the screen with a new-line character at the end * `getModule` - allows you to access a module * `hasModule` - checks if a module is enabled -* `getModuleNames` - list all enabled modules +* `getCurrentModuleNames` - list all enabled modules * `_reconfigure` - can be implemented instead of overriding the constructor ### Enabling Extension @@ -271,8 +271,6 @@ public function testAdminCreatingNewBlogPost(AcceptanceTester $I) This test will trigger the following events: * `test.before.admin` -* `step.before.admin` -* `step.after.admin` * `test.success.admin` * `test.fail.admin` * `test.after.admin` @@ -347,13 +345,13 @@ List of available step decorators: - [TryTo](https://github.com/Codeception/Codeception/blob/5.0.0/src/Codeception/Step/TryTo.php) - failed action will be ignored. - [Retry](https://github.com/Codeception/Codeception/blob/5.0.0/src/Codeception/Step/Retry.php) - failed action will be retried automatically. -Step decorators can be added to suite config inside `steps` block: +Step decorators can be added to suite config inside `step_decorators` block: ```yaml step_decorators: - - Codeception/Step/TryTo - - Codeception/Step/Retry - - Codeception/Step/ConditionalAssertion + - Codeception\Step\TryTo + - Codeception\Step\Retry + - Codeception\Step\ConditionalAssertion ``` diff --git a/docs/FunctionalTests.md b/docs/FunctionalTests.md index f58708b04..2bafa11f2 100644 --- a/docs/FunctionalTests.md +++ b/docs/FunctionalTests.md @@ -209,7 +209,7 @@ class Functional extends \Codeception\Module { function doSomethingWithMyService() { - $service = $this->getModule('Symfony')->grabServiceFromContainer('myservice'); + $service = $this->getModule('Symfony')->grabService('myservice'); $service->doSomething(); } } diff --git a/docs/Introduction.md b/docs/Introduction.md index eefbfacea..01a4ef8c8 100644 --- a/docs/Introduction.md +++ b/docs/Introduction.md @@ -83,7 +83,7 @@ public function trySignupForm(FunctionalTester $I): void 'email' => 'miles@example.com' ]); $I->see('Thank you for Signing Up!'); - $I->seeEmailIsSent('miles@example.com', 'Thank you for your registration'); + $I->seeEmailIsSent(); $I->seeInDatabase('users', ['email' => 'miles@example.com']); } ``` diff --git a/docs/ModulesAndHelpers.md b/docs/ModulesAndHelpers.md index aa260dd2e..c7e5e63d6 100644 --- a/docs/ModulesAndHelpers.md +++ b/docs/ModulesAndHelpers.md @@ -390,7 +390,7 @@ modules: browser: 'firefox' - Db: cleanup: false - repopulate: false + populate: false ``` From 1c79fbf3054600afbc4719da9e304bb96db56cc2 Mon Sep 17 00:00:00 2001 From: W0rma Date: Mon, 16 Nov 2026 08:43:19 +0100 Subject: [PATCH 03/14] Fix invalid or ineffective YAML in config examples - module part must be a key, not a list item (Data) - fix indentation of Phalcon5/Phalcon4 module options (FunctionalTests, for/phalcon) - step_decorators is a top-level suite key (for/phalcon) - modules.config must be a map keyed by module name (for/laravel) - drop no-op 'config: - Yii2' entry (for/yii) --- docs/Data.md | 4 ++-- docs/FunctionalTests.md | 4 ++-- for/laravel.md | 2 +- for/phalcon.md | 16 ++++++++-------- for/yii.md | 2 -- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/docs/Data.md b/docs/Data.md index 0a3877d5c..496e4981b 100644 --- a/docs/Data.md +++ b/docs/Data.md @@ -169,7 +169,7 @@ If you want to use ORM for integration testing only, you should enable the frame modules: enabled: - Laravel: - - part: ORM + part: ORM ``` Similarly for Yii2 framework: @@ -178,7 +178,7 @@ Similarly for Yii2 framework: modules: enabled: - Yii2: - - part: ORM + part: ORM ``` This way no web actions will be added to `$I` object. diff --git a/docs/FunctionalTests.md b/docs/FunctionalTests.md index 2bafa11f2..844e87f83 100644 --- a/docs/FunctionalTests.md +++ b/docs/FunctionalTests.md @@ -143,8 +143,8 @@ modules: enabled: - Phalcon5: bootstrap: 'app/config/bootstrap.php' - cleanup: true - savepoints: true + cleanup: true + savepoints: true ``` [See the full reference](https://codeception.com/docs/modules/Phalcon4) diff --git a/for/laravel.md b/for/laravel.md index 3b55cbe70..f16ab6101 100644 --- a/for/laravel.md +++ b/for/laravel.md @@ -142,7 +142,7 @@ modules: depends: Laravel - \Helper\Api config: - - Laravel: + Laravel: environment_file: .env.testing ``` diff --git a/for/phalcon.md b/for/phalcon.md index 2be2084c4..e6dde6840 100644 --- a/for/phalcon.md +++ b/for/phalcon.md @@ -48,10 +48,10 @@ modules: - Asserts - \Helper\Unit - Phalcon4: - bootstrap: public/index.php - cleanup: true - savepoints: true - step_decorators: ~ + bootstrap: public/index.php + cleanup: true + savepoints: true +step_decorators: ~ ``` To generate a plain PHPUnit test for class `Users`, run: @@ -87,10 +87,10 @@ modules: # add a framework module here - \Helper\Functional - Phalcon4: - bootstrap: public/index.php - cleanup: true - savepoints: true - step_decorators: ~ + bootstrap: public/index.php + cleanup: true + savepoints: true +step_decorators: ~ ``` Then use [Cest](https://codeception.com/docs/07-AdvancedUsage) or Cept to create a test. diff --git a/for/yii.md b/for/yii.md index 592e369e2..86575245c 100644 --- a/for/yii.md +++ b/for/yii.md @@ -136,8 +136,6 @@ modules: url: /api/v1 depends: Yii2 - \ApiBundle\Helper\Api - config: - - Yii2 ``` From ccffba70c3a7faca6e8e6e4750b6c98212a32523 Mon Sep 17 00:00:00 2001 From: W0rma Date: Mon, 16 Nov 2026 08:52:04 +0100 Subject: [PATCH 04/14] Update PHP requirement on install page to 8.2+ Codeception 5.3 requires PHP ^8.2. --- install.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.html b/install.html index 59c333e12..9f563b94f 100644 --- a/install.html +++ b/install.html @@ -8,7 +8,7 @@

Installation

Requirements

- PHP 5.6+ + PHP 8.2+ CURL enabled
From 28dcf6e8bbab1334440728ed5aaa7d3856e9b566 Mon Sep 17 00:00:00 2001 From: W0rma Date: Mon, 16 Nov 2026 08:55:36 +0100 Subject: [PATCH 05/14] Fix outdated quickstart, configuration reference, CI and parallel docs quickstart: - FirstCest example matches what Codeception 5 generates Configuration reference: - 'reporters' is no longer supported - remove 'lint' and 'log_incomplete_skipped', which have no effect - colors defaults to true on every OS; shuffle defaults to false - document support_namespace, suite-level shuffle and step_decorators - suite_namespace is computed and cannot be configured - suite dist config is .suite.dist.yml - use Codeception 5 helper namespace - link to non-numbered guide pages so anchors are kept ContinuousIntegration: - JUnit report is report.xml - GitHub Actions: define PHP version (matrix was undefined and rendered empty by Liquid), checkout@v4, drop deprecated --no-suggest - GitLab: use a PHP 8.4 image - remove outdated Travis CI section ParallelExecution: - fix image paths - write XML results to the path the merge step reads from --- docs/ContinuousIntegration.md | 28 +++++----------- docs/ParallelExecution.md | 6 ++-- docs/reference/Configuration.md | 59 +++++++++++++++++++++------------ quickstart.html | 10 ++++-- 4 files changed, 57 insertions(+), 46 deletions(-) diff --git a/docs/ContinuousIntegration.md b/docs/ContinuousIntegration.md index c8c893d7d..a5eea00a0 100644 --- a/docs/ContinuousIntegration.md +++ b/docs/ContinuousIntegration.md @@ -49,11 +49,11 @@ Then we can start the very first job and check the execution progress. If tests ### XML Reports -But we don't want to analyze console output for each failing build. Especially If Jenkins can collect and display the results inside its web UI. Codeception can export its results using JUnit XML format. To generate XML report on each build we will need to append `--xml` option to Codeception execution command. Codeception will print `result.xml` file containing information about test status with steps and stack traces for failing tests. +But we don't want to analyze console output for each failing build. Especially If Jenkins can collect and display the results inside its web UI. Codeception can export its results using JUnit XML format. To generate XML report on each build we will need to append `--xml` option to Codeception execution command. Codeception will print `report.xml` file into `tests/_output` containing information about test status with steps and stack traces for failing tests. Now let's update our build step to generate xml: -```php +```bash php vendor/bin/codecept run --xml ``` @@ -71,7 +71,7 @@ Now for all builds we will see results trend graph that shows us percentage of p To get more details on steps executed you can generate HTML report and use Jenkins to display them. -```php +```bash php vendor/bin/codecept run --html ``` @@ -101,11 +101,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php }} + php-version: '8.4' extensions: curl, mbstring, openssl, pdo, pdo_sqlite ini-values: memory_limit=-1, date.timezone='UTC' coverage: xdebug @@ -115,7 +115,7 @@ jobs: run: composer validate - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-interaction --no-suggest + run: composer install --prefer-dist --no-progress --no-interaction - name: Run tests run: php vendor/bin/codecept run @@ -125,11 +125,11 @@ jobs: ![report](https://codeception.com/images/gitlab/logo.png) -If a file `.gitlab-ci.yml` exists in the root of the git repository, GitLab will run a pipeline each time you push to the gitlab server. The file configures the docker image that will be called. Below is a sample which loads a php7 docker image, clones your files, installs composer dependencies, runs the built-in php webserver and finally runs codeception: +If a file `.gitlab-ci.yml` exists in the root of the git repository, GitLab will run a pipeline each time you push to the gitlab server. The file configures the docker image that will be called. Below is a sample which loads a PHP 8.4 docker image, clones your files, installs composer dependencies, runs the built-in php webserver and finally runs codeception: ```yaml # Select image from https://hub.docker.com/_/php/ -image: php:7.0 +image: php:8.4 # Select what we should cache cache: @@ -189,16 +189,4 @@ test: junit: tests/_output/report.xml ``` -## TravisCI - -![Travis CI](https://codeception.com/images/travis.png) - -Travis CI is popular service CI with good GitHub integration. Codeception is self-tested with Travis CI. There nothing special about configuration. Just add to the bottom line of travis configuration: - -``` -php vendor/bin/codecept run -``` - -Travis doesn't provide visualization for XML or HTML reports so you can't view reports in format any different than console output. However, Codeception produces nice console output with detailed error reports. - diff --git a/docs/ParallelExecution.md b/docs/ParallelExecution.md index c3c2a15e8..2d1b07358 100644 --- a/docs/ParallelExecution.md +++ b/docs/ParallelExecution.md @@ -48,7 +48,7 @@ Splitting test by shards is done automatically with zero-config. However, in thi To get an aggregated report without an extra stage and without managing artifacts use [Testomat.io](https://testomat.io). This is a SaaS platform that can receive test results from different parallel run and show them in the one interface. -![](images/testomatio-report.png) +![](/images/testomatio-report.png) By running tests with Testomat.io reporter attached results will be sent to a centralized server. By default each execution will create its own report. To store results from different shards in one report set the Run title for them. You can use a common environment variable, like number of a build, to create the unique title which will be the same for all jobs. If build id is stored as $BUILDID variable, execution script for shard #3 can be following: @@ -60,7 +60,7 @@ TESTOMATIO={apiKey} TESTOMATIO_TITLE="Build $BUILDID" ./vendor/bin/codecept run While sharding provides a simplified setup for testing the complete pipeline schema may look like this. -![](images/codeception-pipeline.png) +![](/images/codeception-pipeline.png) * On the first stage, tests should be split into groups. The group file should be committed into the repository or passed to next stage as an artifact. * On the second stage tests are executed. XML, HTML, and CodeCoverage reports must be stored as artifacts. @@ -230,7 +230,7 @@ public function parallelRun() $this->taskCodecept() // use built-in Codecept task ->suite('Acceptance') // run acceptance tests ->group("paracept_$i") // for all paracept_* groups - ->xml("tests/_log/result_$i.xml") // save XML results + ->xml("result_paracept_$i.xml") // save XML results to tests/_output ); } return $parallel->run(); diff --git a/docs/reference/Configuration.md b/docs/reference/Configuration.md index ccbe12097..40a9867ce 100644 --- a/docs/reference/Configuration.md +++ b/docs/reference/Configuration.md @@ -19,7 +19,7 @@ Bootstrap script that will be executed before all suites. A script should be put ### `coverage` -[CodeCoverage](https://codeception.com/docs/11-Codecoverage#Configuration) settings. +[CodeCoverage](https://codeception.com/docs/Codecoverage#Configuration) settings. ### `extends` @@ -27,15 +27,15 @@ Allows you to specify a file (relative to the `codeception.yml` file) that holds ### `extensions` -Allows to enable and configure [Codeception extensions](https://codeception.com/docs/08-Customization#Extension), [Group Objects](https://codeception.com/docs/08-Customization#Group-Objects), and [Custom Commands](https://codeception.com/docs/08-Customization#Custom-Commands). +Allows to enable and configure [Codeception extensions](https://codeception.com/docs/Customization#Extension), [Group Objects](https://codeception.com/docs/Customization#Group-Objects), and [Custom Commands](https://codeception.com/docs/Customization#Custom-Commands). ### `gherkin` -[Gherkin options](https://codeception.com/docs/07-BDD#Configuration). +[Gherkin options](https://codeception.com/docs/BDD#Configuration). ### `include` -Include additional Codeception configurations for [multiple applications setup](https://codeception.com/docs/08-Customization#Namespaces). +Include additional Codeception configurations for [multiple applications setup](https://codeception.com/docs/Customization#Namespaces). ### `modules` @@ -53,11 +53,11 @@ modules: ### `namespace` -Sets the namespace under which all new tests and support classes will be generated. Allows to configure [multiple test setups for one runner](https://codeception.com/docs/08-Customization#Namespaces). +Sets the namespace under which all new tests and support classes will be generated. Allows to configure [multiple test setups for one runner](https://codeception.com/docs/Customization#Namespaces). ### `params` -Allows to pass [external parameters](https://codeception.com/docs/06-ModulesAndHelpers#Dynamic-Configuration-With-Parameters) into module configuration. +Allows to pass [external parameters](https://codeception.com/docs/ModulesAndHelpers#Dynamic-Configuration-With-Parameters) into module configuration. ### `paths` @@ -74,11 +74,11 @@ paths: ### `reporters` -Allows to [change default reporters](https://codeception.com/docs/08-Customization#Custom-Reporters) of Codeception +No longer supported since Codeception 5: a warning is printed if this option is set. Custom reporters must be implemented as [extensions](https://codeception.com/docs/Reporting#Custom-Reporter). ### `settings` -Provide additional options for the test runner. They may dramatically change the way Codeception is executed. For instance, take a note of `shuffle` option which allows to randomize tests execution order and `lint` option that toggles parsing a test file (using `php -l`) before loading it. +Provide additional options for the test runner. They may dramatically change the way Codeception is executed. For instance, take a note of `shuffle` option which allows to randomize tests execution order. Syntax example: {% highlight yaml %} @@ -90,7 +90,7 @@ Possible settings: * `backup_globals: true`: Controls whether PHPUnit attempts to backup global variables, see https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.backupGlobals * `be_strict_about_changes_to_global_state: false`: PHPUnit can be strict about tests that manipulate global state, see https://phpunit.de/manual/current/en/risky-tests.html#risky-tests.global-state-manipulation -* `colors: true`: By default this is false on Windows. Use [ANSICON](https://github.com/adoxa/ansicon) to colorize output. +* `colors: true`: Colorize console output. On older Windows consoles you may need [ANSICON](https://github.com/adoxa/ansicon) to display colors. * `convert_deprecations_to_exceptions: false` Converts E_DEPRECATED and E_USER_DEPRECATED events to exceptions. Introduced in Codeception 4.2.0 * `disallow_test_output: false`: PHPUnit can be strict about output during tests, see https://phpunit.de/manual/current/en/risky-tests.html#risky-tests.output-during-test-execution * `editor_url: 'atom://core/open/file?filename=%%file%%&line=%%line%%'`: In the console output, the test runner will replace all references to files with "clickable" URL's, allowing you to open the file directly in your IDE. Depending on your operating system, you may have to set up an appropriate uri handler. Syntax for some common editors (same as in [PHPStan](https://phpstan.org/user-guide/output-format#opening-file-in-an-editor)): @@ -99,12 +99,14 @@ Possible settings: * Atom: `'atom://core/open/file?filename=%%file%%&line=%%line%%'` * `error_level: E_ALL & ~E_DEPRECATED`: Set the error_reporting level. You can specify either a predefined constant or an integer value, see https://www.php.net/manual/en/function.error-reporting.php and https://www.php.net/manual/en/errorfunc.constants.php. For PHP < 8.4 `E_ALL & ~E_STRICT & ~E_DEPRECATED` is used by default. * `memory_limit: 1024M`: Tests (especially functional) can take a lot of memory. We set a high limit for them by default. -* `lint: true`: Enable/disable syntax of test files before loading. For PHP < 7 `exec('php -l')` is used. Disable if you need to speed up tests execution. -* `log_incomplete_skipped: false`: Log the incomplete and skipped tests into junit report ,see https://phpunit.de/manual/current/en/appendixes.configuration.html Section logging > junit * `report_useless_tests: false`: PHPUnit can be strict about tests that do not test anything, see https://phpunit.de/manual/current/en/risky-tests.html#risky-tests.useless-tests -* `shuffle: true`: Randomize test order +* `shuffle: false`: Set to `true` to randomize test order * `strict_xml: false`: Generate XML JUnit report using strict schema. Avoid putting additional report fields like steps or scenario names to it. Required for XML reports on Jenkins CI +### `support_namespace` + +Namespace of support classes (actors, helpers, page objects, step objects etc.), relative to `namespace`. `codecept bootstrap` sets it to `Support`, so actors are generated as `Tests\Support\AcceptanceTester`. + ## Suite Configuration: `Unit.suite.yml`, `Functional.suite.yml` etc. Each suite has its own configuration inside the directory set by `paths: tests: ` in `codeception.yml`. Alphabetical list of options: @@ -119,15 +121,15 @@ Bootstrap script that will be executed before current suite. A script should be ### `coverage` -Per suite [CodeCoverage](https://codeception.com/docs/11-Codecoverage#Configuration) settings. +Per suite [CodeCoverage](https://codeception.com/docs/Codecoverage#Configuration) settings. ### `env` -Override any configuration per [environment](https://codeception.com/docs/07-AdvancedUsage#Environments). +Override any configuration per [environment](https://codeception.com/docs/AdvancedUsage#Environments). ### `error_level` -[error level](https://codeception.com/docs/04-FunctionalTests#Error-Reporting) for runner in the current suite. Can be specified for unit, integration, functional tests. Passes value to `error_reporting` function. +[error level](https://codeception.com/docs/FunctionalTests#Error-Reporting) for runner in the current suite. Can be specified for unit, integration, functional tests. Passes value to `error_reporting` function. ### `extends` @@ -135,15 +137,15 @@ Allows you to specify a file (relative to `*.suite.yml`) that holds some already ### `gherkin` -Per suite [Gherkin](https://codeception.com/docs/07-BDD#Configuration) settings. +Per suite [Gherkin](https://codeception.com/docs/BDD#Configuration) settings. ### `groups` -[groups](https://codeception.com/docs/07-AdvancedUsage#Groups) with the list of tests of for corresponding group. +[groups](https://codeception.com/docs/AdvancedUsage#Groups) with the list of tests of for corresponding group. ### `formats` -[formats](https://codeception.com/docs/07-AdvancedUsage#Formats) with the list of extra test format classes. +[formats](https://codeception.com/docs/Customization#Formats) with the list of extra test format classes. ### `modules` @@ -155,7 +157,7 @@ modules: - PhpBrowser: # built-in modules are listed by their names url: http://localhost # module configuration - Db # Module without configuration (or inherited from `codeception.yml`) - - \Helper\Acceptance # helper names are listed by their class names, starting with `\` + - \Tests\Support\Helper\Acceptance # helper names are listed by their class names, starting with `\` # Additional modules configuration; can be used for modules which are not currently enabled config: @@ -170,15 +172,30 @@ modules: Default namespace of actor, support classes and tests. +### `shuffle` + +Set to `true` to randomize the execution order of tests in the current suite. + +### `step_decorators` + +List of [step decorators](https://codeception.com/docs/Customization#Step-Decorators) used to generate additional actions in the actor class. Set to `~` to disable them. + +{% highlight yaml %} +step_decorators: + - Codeception\Step\ConditionalAssertion + - Codeception\Step\TryTo + - Codeception\Step\Retry +{% endhighlight %} + ### `suite_namespace` -Default namespace for new tests of this suite (ignores `namespace` option) +Namespace of the tests of this suite. It is always computed as `namespace` + `\` + suite name (e.g. `Tests\Acceptance`), so a value set in the suite config is ignored. ## Configuration Templates: `*.dist.yml` To provide the same configuration template for your development team, you can create a `codeception.dist.yml` config file, which will be loaded before `codeception.yml`. The dist config provides shared options, while local `codeception.yml` files override them on a per-installation basis. Therefore, `codeception.yml` should be ignored by your VCS system. -Config templates can also be used for suite configuration, by creating a `suitename.Suite.dist.yml` file. +Config templates can also be used for suite configuration, by creating a `.suite.dist.yml` file (e.g. `Acceptance.suite.dist.yml`). Configuration loading order: diff --git a/quickstart.html b/quickstart.html index ad4a57445..b95880c09 100644 --- a/quickstart.html +++ b/quickstart.html @@ -81,9 +81,15 @@

4. Write a Basic Test

{% highlight php %} amOnPage('/'); $I->see('Home'); From 6f1c36a1c6e674e2060e926ed62d34dd9b6fada1 Mon Sep 17 00:00:00 2001 From: W0rma Date: Mon, 16 Nov 2026 09:01:19 +0100 Subject: [PATCH 06/14] Simplify error_level default description The suite setting error_level always defaults to 'E_ALL & ~E_DEPRECATED', which overrides the PHP-version-dependent fallback in ErrorHandler, so the PHP < 8.4 note was misleading. Instead, hint that E_STRICT is deprecated as of PHP 8.4. --- docs/FunctionalTests.md | 2 +- docs/UnitTests.md | 2 +- docs/reference/Configuration.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/FunctionalTests.md b/docs/FunctionalTests.md index 844e87f83..c7e38d57a 100644 --- a/docs/FunctionalTests.md +++ b/docs/FunctionalTests.md @@ -219,7 +219,7 @@ Also check all available *Public Properties* of the used modules to get full acc ## Error Reporting -By default Codeception uses the `E_ALL & ~E_DEPRECATED` error reporting level (PHP < 8.4: `E_ALL & ~E_STRICT & ~E_DEPRECATED`). +By default Codeception uses the `E_ALL & ~E_DEPRECATED` error reporting level. In functional tests you might want to change this level depending on your framework's error policy. The error reporting level can be set in the suite configuration file: diff --git a/docs/UnitTests.md b/docs/UnitTests.md index 06c52add6..67e77a62c 100644 --- a/docs/UnitTests.md +++ b/docs/UnitTests.md @@ -489,7 +489,7 @@ public function testSingleton() ## Error Reporting -By default Codeception uses the `E_ALL & ~E_DEPRECATED` error reporting level (PHP < 8.4: `E_ALL & ~E_STRICT & ~E_DEPRECATED`). +By default Codeception uses the `E_ALL & ~E_DEPRECATED` error reporting level. In unit tests you might want to change this level depending on your framework's error policy. The error reporting level can be set in the suite configuration file: diff --git a/docs/reference/Configuration.md b/docs/reference/Configuration.md index 40a9867ce..253999f9c 100644 --- a/docs/reference/Configuration.md +++ b/docs/reference/Configuration.md @@ -97,7 +97,7 @@ Possible settings: * PhpStorm: `'phpstorm://open?file=%%file%%&line=%%line%%'` * Visual Studio Code: `'vscode://file/%%file%%:%%line%%'` * Atom: `'atom://core/open/file?filename=%%file%%&line=%%line%%'` -* `error_level: E_ALL & ~E_DEPRECATED`: Set the error_reporting level. You can specify either a predefined constant or an integer value, see https://www.php.net/manual/en/function.error-reporting.php and https://www.php.net/manual/en/errorfunc.constants.php. For PHP < 8.4 `E_ALL & ~E_STRICT & ~E_DEPRECATED` is used by default. +* `error_level: E_ALL & ~E_DEPRECATED`: Set the error_reporting level. You can specify either a predefined constant or an integer value, see https://www.php.net/manual/en/function.error-reporting.php and https://www.php.net/manual/en/errorfunc.constants.php. `E_STRICT` is deprecated as of PHP 8.4: remove it from your `error_level` if you still reference it, to avoid a deprecation notice. * `memory_limit: 1024M`: Tests (especially functional) can take a lot of memory. We set a high limit for them by default. * `report_useless_tests: false`: PHPUnit can be strict about tests that do not test anything, see https://phpunit.de/manual/current/en/risky-tests.html#risky-tests.useless-tests * `shuffle: false`: Set to `true` to randomize test order From 76301510564d15752ac3317e34f5a08e02b6e99c Mon Sep 17 00:00:00 2001 From: W0rma Date: Mon, 16 Nov 2026 09:06:19 +0100 Subject: [PATCH 07/14] Fix obvious mistakes in guides - GettingStarted: --steps output uses the actual test name - AdvancedUsage: 2 environments run tests 2 times; SignUpCest uses AcceptanceTester so it belongs to Tests\Acceptance; @example is an annotation and the Cest example uses the #[DataProvider] attribute; remove stray backtick - Customization: the configured directory is output, not log - Data: link seeInDatabase to its own anchor; snapshot class lives in Tests\Support\Snapshot --- docs/AdvancedUsage.md | 10 +++++----- docs/Customization.md | 2 +- docs/Data.md | 8 ++++---- docs/GettingStarted.md | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/AdvancedUsage.md b/docs/AdvancedUsage.md index 295197867..d983e6718 100644 --- a/docs/AdvancedUsage.md +++ b/docs/AdvancedUsage.md @@ -285,7 +285,7 @@ class EndpointCest ## Example Annotation -As well as the `\Codeception\Attribute\Examples` attribute, available for Cest tests, the `@example` attribute allows you to +As well as the `\Codeception\Attribute\Examples` attribute, available for Cest tests, the `@example` annotation allows you to inject test parameters in place of an actual [DataProvider](#dataprovider-attribute) for Unit tests. ```php @@ -311,7 +311,7 @@ class ExampleTest extends \Codeception\Test\Unit ## DataProvider Attribute -You can also use the `@dataProvider` annotation for creating dynamic examples for [Cest classes](#Cest-Classes), using a **protected method** for providing example data: +You can also use the `#[DataProvider]` attribute for creating dynamic examples for [Cest classes](#Cest-Classes), using a **protected method** for providing example data: ```php Wildcards (`*`) can be used to specify multiple directories at once. diff --git a/docs/Data.md b/docs/Data.md index 496e4981b..459e2bcdc 100644 --- a/docs/Data.md +++ b/docs/Data.md @@ -101,7 +101,7 @@ $I->see('Top 10 Testing Frameworks'); All added records will be deleted at the end of the test. If you want to check that a table record was created -use [`seeInDatabase`](https://codeception.com/docs/modules/Db#haveInDatabase) method: +use [`seeInDatabase`](https://codeception.com/docs/modules/Db#seeInDatabase) method: ```php $I->amOnPage('/posts/1'); @@ -310,7 +310,7 @@ class Categories extends \Codeception\Snapshot Inside a test you can inject the snapshot class and call `assert` method on it: ```php -public function testCategoriesAreTheSame(AcceptanceTester $I, \Tests\Snapshot\Categories $snapshot) +public function testCategoriesAreTheSame(AcceptanceTester $I, \Tests\Support\Snapshot\Categories $snapshot) { $I->amOnPage('/categories'); // if previously saved array of users does not match current set, test will fail @@ -332,7 +332,7 @@ The assertion performed by `assertData` will not display the typical diff output To have the diff displayed when running tests, you can call the snapshot method `shouldShowDiffOnFail`: ```php -public function testCategoriesAreTheSame(AcceptanceTester $I, \Tests\Snapshot\Categories $snapshot) +public function testCategoriesAreTheSame(AcceptanceTester $I, \Tests\Support\Snapshot\Categories $snapshot) { $I->amOnPage('/categories'); // I want to see the diff in case the snapshot data changes @@ -349,7 +349,7 @@ By default, all snapshot files are stored in json format, so if you have to work To fix this, you can call the snapshot method `shouldSaveAsJson(false)` and set the file extension by calling `setSnapshotFileExtension()`: ```php -public function testCategoriesAreTheSame(AcceptanceTester $I, \Tests\Snapshot\Categories $snapshot) +public function testCategoriesAreTheSame(AcceptanceTester $I, \Tests\Support\Snapshot\Categories $snapshot) { // I fetch an HTML page $I->amOnPage('/categories.html'); diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index c5cf46406..f0b6117cc 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -159,7 +159,7 @@ We should see a step-by-step report on the performed actions: ```bash Acceptance Tests (1) ------------------------------- -SigninCest: Login to website +SigninCest: sign in successfully Signature: SigninCest.php:signInSuccessfully Test: tests/Acceptance/SigninCest.php:signInSuccessfully Scenario -- From 1f66edfe9064b82644e7ef5d4916bb4d2af19c24 Mon Sep 17 00:00:00 2001 From: W0rma Date: Mon, 16 Nov 2026 09:09:50 +0100 Subject: [PATCH 08/14] Update outdated references in Data guide - link to the non-numbered ModulesAndHelpers page with the correct anchor - Laravel5 module is now called Laravel; link current Laravel factory docs - fzaninotto/Faker is archived; link FakerPHP/Faker --- docs/Data.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/Data.md b/docs/Data.md index 459e2bcdc..886639ccf 100644 --- a/docs/Data.md +++ b/docs/Data.md @@ -34,7 +34,7 @@ modules: ```
-Use module parameters +Use module parameters to set the database credentials from environment variables or from application configuration files.
@@ -161,7 +161,7 @@ $I->click('Delete'); $I->dontSeeRecord('posts', ['id' => $id]); ``` -Laravel5 module provides the method `have` which uses the [factory](https://laravel.com/docs/9.x/database-testing#creating-models-using-factories) method to generate models with fake data. +[Laravel](https://codeception.com/docs/modules/Laravel) module provides the method `have` which uses the [factory](https://laravel.com/docs/eloquent-factories) method to generate models with fake data. If you want to use ORM for integration testing only, you should enable the framework module with only the `ORM` part enabled: @@ -227,7 +227,7 @@ Doctrine also provides methods to create and check data: ### DataFactory Preparing data for testing is a very creative, although boring, task. If you create a record, -you need to fill in all the fields of the model. It is much easier to use [Faker](https://github.com/fzaninotto/Faker) +you need to fill in all the fields of the model. It is much easier to use [Faker](https://github.com/FakerPHP/Faker) for this task, which is more effective to set up data generation rules for models. Such a set of rules is called *factories* and are provided by the [DataFactory](https://codeception.com/docs/modules/DataFactory) module. From ac27fa52b812ec7136e42fc82b98cf6bb018d518 Mon Sep 17 00:00:00 2001 From: W0rma Date: Mon, 16 Nov 2026 09:11:00 +0100 Subject: [PATCH 09/14] Fix Symfony docs - Symfony module looks for App\Kernel in src/ by default, not AppKernel in app/ - for/symfony: front matter must come first, otherwise Jekyll does not process the page --- docs/FunctionalTests.md | 2 +- for/symfony.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/FunctionalTests.md b/docs/FunctionalTests.md index c7e38d57a..5783aeb8a 100644 --- a/docs/FunctionalTests.md +++ b/docs/FunctionalTests.md @@ -90,7 +90,7 @@ modules: depends: Symfony # connect to Symfony ``` -By default this module will search for AppKernel in the `app` directory. +By default this module will search for the `App\Kernel` class in the `src` directory. Use the `kernel_class` and `app_path` options to change this. The module uses the Symfony Profiler to provide additional information and assertions. diff --git a/for/symfony.md b/for/symfony.md index 55f093ed0..4b388ab52 100644 --- a/for/symfony.md +++ b/for/symfony.md @@ -1,4 +1,3 @@ - --- layout: page title: Codeception for Symfony @@ -7,6 +6,8 @@ sidebar: | --- + + From a1b7882366644a5450d61437444bdf663ac8faf3 Mon Sep 17 00:00:00 2001 From: W0rma Date: Mon, 16 Nov 2026 09:12:09 +0100 Subject: [PATCH 10/14] Update Customization guide for Codeception 5 - actors and helpers are generated in the Support / Support\Helper namespaces - link to the multi-application meta-config section - test.before/after are triggered for all tests, including PHPUnit TestCases - tests/_bootstrap.php no longer exists; refer to bootstrap files - group objects live in Tests\Support\Group and are generated with generate:groupobject --- docs/Customization.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/docs/Customization.md b/docs/Customization.md index d0fdb086d..9e0d47981 100644 --- a/docs/Customization.md +++ b/docs/Customization.md @@ -19,10 +19,10 @@ php vendor/bin/codecept bootstrap --namespace frontend ``` This will bootstrap a new project with the `namespace: frontend` parameter in the `codeception.yml` file. -Helpers will be in the `frontend\Codeception\Module` namespace and Actor classes will be in the `frontend` namespace. +Actor classes will be in the `frontend\Support` namespace and Helpers will be in the `frontend\Support\Helper` namespace. Once each of your applications (bundles) has its own namespace and different Helper or Actor classes, -you can execute all the tests in a single runner. Run the Codeception tests as usual, using the meta-config we created earlier: +you can execute all the tests in a single runner. Run the Codeception tests as usual, using a meta-config which [includes all applications](#One-Runner-for-Multiple-Applications): ```bash php vendor/bin/codecept run @@ -137,9 +137,10 @@ All listed events are available as constants in `Codeception\Events` class. | `result.print.after` | After result was printed | [Result, Printer](https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Event/PrintResultEvent.php) There may be some confusion between `test.start`/`test.before` and `test.after`/`test.end`. -The start and end events are triggered by PHPUnit, but the before and after events are triggered by Codeception. -Thus, when you are using classical PHPUnit tests (extended from `PHPUnit\Framework\TestCase`), -the before/after events won't be triggered for them. During the `test.before` event you can mark a test +The start and end events are triggered by the suite around each test, while the before and after events are triggered +from inside the test and are also dispatched per group (see [Group Objects](#Group-Objects)). +All of them are triggered for every kind of test, including classical PHPUnit tests (extended from `PHPUnit\Framework\TestCase`). +During the `test.before` event you can mark a test as skipped or incomplete, which is not possible in `test.start`. You can learn more from [Codeception internal event listeners](https://github.com/Codeception/Codeception/tree/5.0/src/Codeception/Subscriber). @@ -188,8 +189,8 @@ Extensions have some basic methods you can use: ### Enabling Extension -Once you've implemented a simple extension class, you can require it in `tests/_bootstrap.php`, -load it with Composer's autoloader defined in `composer.json`, or store the class inside `tests/Support`dir. +Once you've implemented a simple extension class, you can require it in a [bootstrap file](#Bootstrap), +load it with Composer's autoloader defined in `composer.json`, or store the class inside `tests/Support` dir. You can then enable it in `codeception.yml` @@ -279,7 +280,7 @@ A group object is built to listen for these events. It is useful when an additio for some of your tests. Let's say you want to load fixtures for tests that belong to the `admin` group: ```php Date: Mon, 16 Nov 2026 09:13:23 +0100 Subject: [PATCH 11/14] Update ModulesAndHelpers guide for Codeception 5 - generated actions are stored in tests/Support/_generated - Db::$dbh is deprecated and PDO has no close()/open(); use _getDbh() - WebDriver module is built on php-webdriver/webdriver; fix RemoteWebDriver namespace - link to non-numbered guide pages so anchors are kept --- docs/ModulesAndHelpers.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/ModulesAndHelpers.md b/docs/ModulesAndHelpers.md index c7e5e63d6..7f33b8c19 100644 --- a/docs/ModulesAndHelpers.md +++ b/docs/ModulesAndHelpers.md @@ -42,7 +42,7 @@ The FunctionalTester class has its methods defined in modules. Actually, it does but rather acts as a proxy. It knows which module executes this action and passes parameters into it. To make your IDE see all of the FunctionalTester methods, you should run the `codecept build` command. It generates method signatures from enabled modules and saves them into a trait which is included in an actor. -In the current example, the `tests/support/_generated/FunctionalTesterActions.php` file will be generated. +In the current example, the `tests/Support/_generated/FunctionalTesterActions.php` file will be generated. By default, Codeception automatically rebuilds the Actions trait on each change of the suite configuration. ## Standard Modules @@ -207,20 +207,20 @@ For example, for your module you might need to access the responses or internal Modules can interact with each other through the `getModule` method. Please note that this method will throw an exception if the required module was not loaded. -Let's imagine that we are writing a module that reconnects to a database. -It's supposed to use the dbh connection value from the Db module. +Let's imagine that we are writing a module that runs a custom query. +It's supposed to use the PDO connection of the Db module. ```php -function reconnectToDatabase() +function seeNumberOfUsers(int $num): void { - $dbh = $this->getModule('Db')->dbh; - $dbh->close(); - $dbh->open(); + $dbh = $this->getModule('Db')->_getDbh(); + $count = (int) $dbh->query('SELECT COUNT(*) FROM users')->fetchColumn(); + $this->assertSame($num, $count); } ``` By using the `getModule` function, you get access to all of the public methods and properties of the requested module. -The `dbh` property was defined as public specifically to be available to other modules. +The `_getDbh()` method was defined as public specifically to be available to other modules. Modules may also contain methods that are exposed for use in helper classes. Those methods start with a `_` prefix and are not available in Actor classes, so can be accessed only from modules and extensions. @@ -242,9 +242,9 @@ function seeNumResults($num) } ``` -In this example we use the API of the facebook/php-webdriver library, -a Selenium WebDriver client the module is build on. -You can also access the `webDriver` property of a module to get access to the `Facebook\WebDriver\RemoteWebDriver` instance +In this example we use the API of the php-webdriver/webdriver library, +a Selenium WebDriver client the module is built on. +You can also access the `webDriver` property of a module to get access to the `Facebook\WebDriver\Remote\RemoteWebDriver` instance for direct Selenium interaction. ### Extending a Module @@ -503,9 +503,9 @@ At the end of a test all configuration changes will be rolled back to the origin ### Runtime Configuration of a Test Sometimes it is needed to set custom configuration for a specific test only. -For [Cest](https://codeception.com/docs/07-AdvancedUsage#Cest-Classes) and [Test\Unit](https://codeception.com/docs/05-UnitTests) +For [Cest](https://codeception.com/docs/AdvancedUsage#Cest-Classes) and [Test\Unit](https://codeception.com/docs/UnitTests) formats you can use `#[Prepare]` attribute which executes the code before other hooks are executed. This allows `#[Prepare]` -to change the module configuration in runtime. `#[Prepare]` uses [dependency injection](https://codeception.com/docs/07-AdvancedUsage#Dependency-Injection) +to change the module configuration in runtime. `#[Prepare]` uses [dependency injection](https://codeception.com/docs/AdvancedUsage#Dependency-Injection) to automatically inject required modules into a method. To run a specific test only in Chrome browser, you can call `_reconfigure` from WebDriver module for a test itself using `#[Prepare]`. @@ -529,7 +529,7 @@ protected function useChrome(\Codeception\Module\WebDriver $webdriver) Prepare methods can invoke all methods of a module, as well as hidden API methods (starting with `_`). Use them to customize the module setup for a specific test. -To change module configuration for a specific group of tests use [GroupObjects](https://codeception.com/docs/08-Customization#Group-Objects). +To change module configuration for a specific group of tests use [GroupObjects](https://codeception.com/docs/Customization#Group-Objects). ## Conclusion From 6b7f4db83186008fd296469a195afa6c4b28d4bc Mon Sep 17 00:00:00 2001 From: W0rma Date: Mon, 16 Nov 2026 09:14:02 +0100 Subject: [PATCH 12/14] GettingStarted: show the Cest as generated by Codeception 5 The generated Cest is final, uses strict types and void return types and has no _after method. --- docs/GettingStarted.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index f0b6117cc..79187a05e 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -80,24 +80,29 @@ This will generate the `SigninCest.php` file inside the `tests/Acceptance` direc ```php Date: Mon, 16 Nov 2026 09:16:30 +0100 Subject: [PATCH 13/14] Remove references to outdated versions in guides - AdvancedUsage: sample run output from Codeception 5 instead of 2.4.5 - APITesting: drop module-rest 1.4.1 note, Symfony2 -> Symfony, assertRegExp -> assertMatchesRegularExpression - Codecoverage: Xdebug 3 uses xdebug.mode=coverage instead of remote_enable; phpdbg is only supported with PHPUnit 9; replace 'whitelisted' wording - UnitTests: link current PHPUnit assertions docs --- docs/APITesting.md | 6 ++---- docs/AdvancedUsage.md | 5 ++--- docs/Codecoverage.md | 6 +++--- docs/UnitTests.md | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/docs/APITesting.md b/docs/APITesting.md index 84d5e8405..3e1bac17d 100644 --- a/docs/APITesting.md +++ b/docs/APITesting.md @@ -21,7 +21,7 @@ We will put all the api tests there. > **NOTE:** REST API testing requires the `codeception/module-rest` package to be installed. -The REST web service is accessed via HTTP with standard methods: `GET`, `POST`, `PUT`, `DELETE`. They allow users to receive and manipulate entities from the service. Accessing a WebService requires an HTTP client, so for using it you need the module `PhpBrowser` or one of framework modules set up. For example, we can use the `Symfony` module for Symfony2 applications in order to ignore web server and test web service internally. +The REST web service is accessed via HTTP with standard methods: `GET`, `POST`, `PUT`, `DELETE`. They allow users to receive and manipulate entities from the service. Accessing a WebService requires an HTTP client, so for using it you need the module `PhpBrowser` or one of framework modules set up. For example, we can use the `Symfony` module for Symfony applications in order to ignore web server and test web service internally. Configure modules in `Api.suite.yml`: @@ -137,8 +137,6 @@ To send a request with custom method use `send` action: $response = $I->send('TRACE', '/posts'); ``` -> sendAsJson methods were introduced in module-rest 1.4.1 - If API endpoint accepts JSON you can use `send` methods with `AsJson` suffix to convert data automatically. In this case `Content-Type` header is sent with `application/json` value and response if JSON is parsed: @@ -249,7 +247,7 @@ class Api extends \Codeception\Module public function seeResponseIsHtml() { $response = $this->getModule('REST')->response; - $this->assertRegExp('~^.*?<\/html>~m', $response); + $this->assertMatchesRegularExpression('~^.*?<\/html>~m', $response); } } diff --git a/docs/AdvancedUsage.md b/docs/AdvancedUsage.md index d983e6718..27f774be1 100644 --- a/docs/AdvancedUsage.md +++ b/docs/AdvancedUsage.md @@ -622,10 +622,9 @@ codecept run -o "settings: shuffle: true" Tests will be randomly reordered on each run. When tests are executed in shuffle mode a seed value will be printed. Copy this seed value from the output to be able to rerun tests in the same order. -```yaml +```bash $ codecept run -Codeception PHP Testing Framework v2.4.5 -Powered by PHPUnit 5.7.27 by Sebastian Bergmann and contributors. +Codeception PHP Testing Framework v5.3.7 https://stand-with-ukraine.pp.ua [Seed] 1872290562 ``` diff --git a/docs/Codecoverage.md b/docs/Codecoverage.md index d164cfd1a..e5c68a312 100644 --- a/docs/Codecoverage.md +++ b/docs/Codecoverage.md @@ -17,7 +17,7 @@ The required information is provided by [SebastianBergmann\CodeCoverage](https:/ | Driver | Description | | --- | --- | | [Xdebug](https://github.com/xdebug/xdebug) | Great for debugging, but too slow when collecting coverage | -| [phpdbg](https://www.php.net/manual/en/book.phpdbg.php) | Faster than `Xdebug` but inaccurate | +| [phpdbg](https://www.php.net/manual/en/book.phpdbg.php) | Faster than `Xdebug` but inaccurate. Only supported with PHPUnit 9 | | [pcov](https://github.com/krakjoe/pcov) | Fast and accurate, but no debug functionality — perfect for CI | ![Code Coverage Example](https://codeception.com/images/coverage.png) @@ -63,7 +63,7 @@ coverage: high_limit: 60 ``` -By default, show all whitelisted files in `--coverage-text` output not just the ones with coverage information is set to false, config option: +By default, `--coverage-text` output only shows files with coverage information. To show all included files, set `show_uncovered` to `true` (default: `false`): ```yaml @@ -108,7 +108,7 @@ XML clover reports are used by IDEs (like PHPStorm) or Continuous Integration se If you run your application via Webserver (Apache, Nginx, PHP WebServer) you don't have a direct access to tested code, so collecting coverage becomes a non-trivial task. The same goes for scripts that are tested on different nodes. -To get access to this code you need `xdebug` installed with `remote_enable` option turned on. +To get access to this code you need `xdebug` installed with coverage enabled (`xdebug.mode=coverage` in Xdebug 3). Codeception also requires a little spy to interact with your application. As your application runs standalone, without even knowing it is being tested, a small file should be included in order to collect coverage info. diff --git a/docs/UnitTests.md b/docs/UnitTests.md index 67e77a62c..1367b66a7 100644 --- a/docs/UnitTests.md +++ b/docs/UnitTests.md @@ -107,7 +107,7 @@ There are pretty many assertions you can use inside tests. The most common are: * `$this->assertNull()` * `$this->assertEmpty()` -Assertion methods come from PHPUnit. [See the complete reference at phpunit.de](https://phpunit.de/manual/current/en/appendixes.assertions.html). +Assertion methods come from PHPUnit. [See the complete reference at phpunit.de](https://docs.phpunit.de/en/main/assertions.html). ### Fluent Assertions From 4608f7f037333883a8bbccb8179065989a7ee038 Mon Sep 17 00:00:00 2001 From: W0rma Date: Mon, 16 Nov 2026 09:17:22 +0100 Subject: [PATCH 14/14] Codecoverage: remote coverage works with pcov as well c3 selects the driver via php-code-coverage's Selector, which supports pcov and Xdebug for line coverage; path coverage requires Xdebug. --- docs/Codecoverage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Codecoverage.md b/docs/Codecoverage.md index e5c68a312..fe9c9f904 100644 --- a/docs/Codecoverage.md +++ b/docs/Codecoverage.md @@ -108,7 +108,7 @@ XML clover reports are used by IDEs (like PHPStorm) or Continuous Integration se If you run your application via Webserver (Apache, Nginx, PHP WebServer) you don't have a direct access to tested code, so collecting coverage becomes a non-trivial task. The same goes for scripts that are tested on different nodes. -To get access to this code you need `xdebug` installed with coverage enabled (`xdebug.mode=coverage` in Xdebug 3). +To get access to this code you need a coverage driver on the server: `pcov` or `xdebug` with coverage enabled (`xdebug.mode=coverage`). Path coverage (`path_coverage: true`) requires `xdebug`. Codeception also requires a little spy to interact with your application. As your application runs standalone, without even knowing it is being tested, a small file should be included in order to collect coverage info.