Full-stack testing PHP framework

Last update: Aug 12, 2022

Codeception

Latest Stable Total Downloads Scrutinizer Code Quality

Modern PHP Testing for everyone

Codeception is a modern full-stack testing framework for PHP. Inspired by BDD, it provides an absolutely new way of writing acceptance, functional and even unit tests. Powered by PHPUnit.

Build Webdriver
Build status Build Status

Contributions

At Codeception we are glad to receive contributions from the community. If you want to send additions or fixes to the code or the documentation please check the Contributing guide.

At a Glance

Describe what you test and how you test it. Use PHP to write descriptions faster.

Run tests and see what actions were taken and what results were seen.

Sample test

$I->amOnPage('/');
$I->click('Pages');
$I->click('New');
$I->see('New Page');
$I->submitForm('form#new_page', ['title' => 'Movie Review']);
$I->see('page created'); // notice generated
$I->see('Movie Review','h1'); // head of page of is our title
$I->seeInCurrentUrl('pages/movie-review'); // slug is generated
$I->seeInDatabase('pages', ['title' => 'Movie Review']); // data is stored in database

For unit testing you can stay on classic PHPUnit tests, as Codeception can run them too.

Installation

Composer

php composer.phar require "codeception/codeception"

TODO: Document how to install the modules, e.g.

php composer.phar require "codeception/module-phpbrowser"

Phar

Download codecept.phar

Copy it into your project.

You can also make Codeception an executable and it put it into your $PATH, for instance:

wget http://codeception.com/codecept.phar

chmod +x codecept.phar

sudo mv codecept.phar /usr/local/bin/codecept

You can then run Codecept in the command line using: codecept bootstrap, codecept run, etc

Run CLI utility:

php codecept.phar

See also Installation | QuickStart

Getting Started

After you successfully installed Codeception, run this command:

codecept bootstrap

This will create a default directory structure and default test suites.

Documentation

View Documentation

The documentation source files can be found at https://github.com/Codeception/codeception.github.com/tree/master/docs/.

License

MIT

(c) Codeception Team 2011-2020

GitHub

https://github.com/Codeception/Codeception
Comments
  • 1. Suggestion: Generate namespaced Cest files by default

    I'm guessing that the majority of framework users wants their tests to be namespaced properly. Right?

    Documentation is poor (not to say: inexistant), with https://codeception.com/docs/08-Customization#Namespaces being the only reference I found.

    So here's what I did, and I'm suggesting to make this the default behavior of codecept g:cest functional First, to save people from having to copy-paste it into their Cest files later on:

    1. Add this to composer.json (this might already be implemented in recent versions):
      "autoload-dev": {
          "psr-4": {
              "Tests\\": "tests/"
          }
      },
      
    2. Add this to codeception.yml:
      namespace: Tests
      
    3. Add this on top of every (functional) Cest file:
      namespace Tests\functional;
      use Tests\FunctionalTester;
      

    I'm not 100% sure if this is the best way to do it, so please doublecheck.

    This would also solve https://github.com/Codeception/Codeception/issues/4874

    Reviewed by ThomasLandauer at 2019-10-20 14:56
  • 2. [Yii2] Used database connections are not getting closed

    What are you trying to achieve?

    Trying to run suite of tests

    What do you get instead?

    Failures

    Provide console output if related. Use -vvv mode for more details.

    - ManagerTest: Check oem company monitor  Destroying application
      Starting application
      [Fixtures] Loading fixtures
      [yii\db\Connection::open] 'Opening DB connection: pgsql:host=localhost;port=5432;dbname=front_test'
      [Fixtures] Opened database connection: pgsql:host=localhost;port=5432;dbname=front_test
      [yii\db\Connection::open] 'Opening DB connection: pgsql:host=localhost;port=5432;dbname=back_test'
      [Fixtures] Opened database connection: pgsql:host=localhost;port=5432;dbname=back_test
      [Fixtures] Closing database connection: pgsql:host=localhost;port=5432;dbname=front_test
      [Fixtures] Closing database connection: pgsql:host=localhost;port=5432;dbname=back_test
      [Fixtures] Done
      [yii\db\Connection::open] 'Opening DB connection: pgsql:host=localhost;port=5432;dbname=front_test'
      [yii\web\Session::open] 'Session started'
      [yii\web\User::login] 'User \'1256\' logged in from  with duration 86400.'
    

    Eventually get this

    ---------
    300) ApiUserTesterCest: Test the forgot password request
     Test  tests/api/ApiUserTesterCest.php:ForgotPasswordRequest
                                                                                      
      [yii\db\Exception] SQLSTATE[08006] [7] FATAL:  sorry, too many clients already  
                                                                                      
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Connection.php:624
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Connection.php:687
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Connection.php:613
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Connection.php:996
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Connection.php:983
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Schema.php:463
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Connection.php:881
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Command.php:209
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Command.php:1099
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Command.php:1120
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Command.php:442
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/pgsql/Schema.php:182
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Schema.php:237
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/pgsql/QueryBuilder.php:200
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/db/Command.php:959
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/test/InitDbFixture.php:96
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/test/InitDbFixture.php:78
    /srv/www/xyzweb/src/private/protected/vendor/yiisoft/yii2/test/FixtureTrait.php:117
    /srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Module/Yii2.php:467
    /srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Module/Yii2.php:285
    /srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Module/Yii2.php:259
    /srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Subscriber/Module.php:56
    /srv/www/xyzweb/src/private/protected/vendor/symfony/event-dispatcher/EventDispatcher.php:212
    /srv/www/xyzweb/src/private/protected/vendor/symfony/event-dispatcher/EventDispatcher.php:44
    /srv/www/xyzweb/src/private/protected/vendor/codeception/phpunit-wrapper/src/Listener.php:133
    /srv/www/xyzweb/src/private/protected/vendor/codeception/phpunit-wrapper/src/Listener.php:102
    /srv/www/xyzweb/src/private/protected/vendor/phpunit/phpunit/src/Framework/TestResult.php:395
    /srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Test/Test.php:75
    /srv/www/xyzweb/src/private/protected/vendor/phpunit/phpunit/src/Framework/TestSuite.php:755
    /srv/www/xyzweb/src/private/protected/vendor/codeception/phpunit-wrapper/src/Runner.php:106
    /srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/SuiteManager.php:157
    /srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Codecept.php:189
    /srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Codecept.php:158
    /srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Command/Run.php:466
    /srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Command/Run.php:361
    /srv/www/xyzweb/src/private/protected/vendor/symfony/console/Command/Command.php:252
    /srv/www/xyzweb/src/private/protected/vendor/symfony/console/Application.php:946
    /srv/www/xyzweb/src/private/protected/vendor/symfony/console/Application.php:248
    /srv/www/xyzweb/src/private/protected/vendor/symfony/console/Application.php:148
    /srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/src/Codeception/Application.php:108
    /srv/www/xyzweb/src/private/protected/vendor/codeception/codeception/codecept:42
    

    Details

    • Codeception version: 2.4.1
    • PHP Version: 7.0
    • Operating System: Ubuntu 16.04
    • Installation type: Composer
    • List of installed packages (composer show) alexandernst/yii2-device-detect 0.0.12 Yii2 extension for Mobile-Detect library behat/gherkin v4.5.1 Gherkin DSL parser for PHP 5.3 bower-asset/bootstrap v3.3.7 The most popular front-end framework for developing responsive, mobile first projects on the web. bower-asset/inputmask 3.3.11 Inputmask is a javascript library which creates an input mask. Inputmask can run against vanilla javascript, jQuery and jql... bower-asset/jquery 3.2.1
      bower-asset/jquery-ui 1.12.1
      bower-asset/punycode v1.3.2
      bower-asset/yii2-pjax 2.0.7.1
      braintree/braintree_php 3.30.0 Braintree PHP Client Library cebe/markdown 1.1.2 A super fast, highly extensible markdown parser for PHP codeception/codeception 2.4.1 BDD-style testing framework codeception/phpunit-wrapper 6.0.9 PHPUnit classes used by Codeception codeception/specify 1.0 BDD code blocks for PHPUnit and Codeception codeception/stub 1.0.2 Flexible Stub wrapper for PHPUnit's Mock Builder codeception/verify 1.0.0 BDD assertion library for PHPUnit crossjoin/css v1.0.3 CSS reader and writer with full CSS3 support, already supporting huge parts of the current CSS4 spec. It supports media quer... crossjoin/pre-mailer v1.0.5 Crossjoin\PreMailer converts CSS in a given HTML source to inline styles and optimizes it for sending it via e-mail. It also... doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in PHP without invoking their constructors ezyang/htmlpurifier v4.10.0 Standards compliant HTML filter written in PHP facebook/webdriver 1.5.0 A PHP client for Selenium WebDriver firebase/php-jwt v5.0.0 A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec. flow/jsonpath 0.4.0 JSONPath implementation for parsing, searching and flattening arrays guzzlehttp/guzzle 6.3.2 Guzzle is a PHP HTTP client library guzzlehttp/promises v1.3.1 Guzzle promises library guzzlehttp/psr7 1.4.2 PSR-7 message implementation that also provides common utility methods imagine/imagine v0.7.1 Image processing for PHP 5.3 kamranahmedse/php-geocode v2.0 A wrapper around the Google Geocoding API to get different details such as latitude, longitude, country, city, district, pos... mobiledetect/mobiledetectlib 2.8.31 Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific ... myclabs/deep-copy 1.7.0 Create deep copies (clones) of your objects phar-io/manifest 1.0.1 Component for reading phar.io manifest information from a PHP Archive (PHAR) phar-io/version 1.0.1 Library for handling version information and constraints phpdocumentor/reflection-common 1.0.1 Common reflection classes used by phpdocumentor to reflect the code structure phpdocumentor/reflection-docblock 4.3.0 With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is e... phpdocumentor/type-resolver 0.4.0
      phpmailer/phpmailer v5.2.26 PHPMailer is a full-featured email creation and transfer class for PHP phpoffice/phpexcel 1.8.1 PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine phpspec/prophecy 1.7.5 Highly opinionated mocking framework for PHP 5.3+ phpunit/php-code-coverage 5.3.2 Library that provides collection, processing, and rendering functionality for PHP code coverage information. phpunit/php-file-iterator 1.4.5 FilterIterator implementation that filters files based on a list of suffixes. phpunit/php-text-template 1.2.1 Simple template engine. phpunit/php-timer 1.0.9 Utility class for timing phpunit/php-token-stream 2.0.2 Wrapper around PHP's tokenizer extension. phpunit/phpunit 6.5.7 The PHP Unit Testing framework. phpunit/phpunit-mock-objects 5.0.6 Mock Object library for PHPUnit piwik/piwik-php-tracker 1.2.0 PHP Client for Piwik Analytics Tracking API psr/http-message 1.0.1 Common interface for HTTP messages psr/log 1.0.2 Common interface for logging libraries sebastian/code-unit-reverse-lookup 1.0.1 Looks up which function or method a line of code belongs to sebastian/comparator 2.1.3 Provides the functionality to compare PHP values for equality sebastian/diff 2.0.1 Diff implementation sebastian/environment 3.1.0 Provides functionality to handle HHVM/PHP environments sebastian/exporter 3.1.0 Provides the functionality to export PHP variables for visualization sebastian/global-state 2.0.0 Snapshotting of global state sebastian/object-enumerator 3.0.3 Traverses array structures and object graphs to enumerate all referenced objects sebastian/object-reflector 1.1.1 Allows reflection of object attributes, including inherited and non-public ones sebastian/recursion-context 3.0.0 Provides functionality to recursively process PHP variables sebastian/resource-operations 1.0.0 Provides a list of PHP built-in functions that operate on resources sebastian/version 2.0.1 Library that helps with managing the version number of Git-hosted PHP projects symfony/browser-kit v3.4.8 Symfony BrowserKit Component symfony/console v3.4.8 Symfony Console Component symfony/css-selector v2.8.38 Symfony CssSelector Component symfony/debug v3.4.8 Symfony Debug Component symfony/dom-crawler v3.4.8 Symfony DomCrawler Component symfony/event-dispatcher v3.4.8 Symfony EventDispatcher Component symfony/finder v3.4.8 Symfony Finder Component symfony/polyfill-mbstring v1.7.0 Symfony polyfill for the Mbstring extension symfony/process v3.4.8 Symfony Process Component symfony/yaml v3.4.8 Symfony Yaml Component theseer/tokenizer 1.1.0 A small library for converting tokenized PHP source code into XML and potentially other formats webmozart/assert 1.3.0 Assertions to validate method input/output with nice error messages. yiidoc/yii2-redactor 2.0.1 Extension redactor for Yii2 Framework. yiisoft/yii2 2.0.15.1 Yii PHP Framework Version 2 yiisoft/yii2-bootstrap 2.0.8 The Twitter Bootstrap extension for the Yii framework yiisoft/yii2-composer 2.0.6 The composer plugin for Yii extension installer yiisoft/yii2-imagine 2.1.1 The Imagine integration for the Yii framework yiisoft/yii2-jui 2.0.7 The Jquery UI extension for the Yii framework yiisoft/yii2-redis 2.0.8 Redis Cache, Session and ActiveRecord for the Yii framework yurkinx/yii2-image dev-master 2737b1e Yii2 extension for image manipulating using Kohana Image Library.
    • Suite configuration:
    class_name: UnitTester
    modules:
        enabled:
            - Yii2:
                part: [orm, fixtures]
                cleanup: true
                transaction: false
    coverage:
        enabled: true
        remote: false
        include:
          - models/*
          - components/*
          - forms/*
    
    Reviewed by scottix at 2018-04-06 22:19
  • 3. Test code or tested code did not (only) close its own output buffers

    I am getting this error now and then in combination with Yii2. I drilled the issue down to the occurence of an error NOTICE.

    When I change error_reporting(E_NOTICE) to error_reporting(E_ERROR), the code continues.

    It took quite a while to traverse through the code to get to this error. Isnt there a better response than "Test code or tested code did not (only) close its own output buffers"?

    I prefer maximal insights. Why not outputting errors to the log area? Or to the console?

    thanx

    Reviewed by dynasource at 2014-08-01 19:20
  • 4. PHP 7.0 / PHPunit 5.1 support

    I couldn't find an issue tracking progress on making Codeception compatible with PHP7.0. What's missing to make it run with PHPunit 5.1?

    • codeception/codeception 2.1.5 requires phpunit/phpunit ~4.8.0 -> no matching package found.

    Related issue: #2730

    Reviewed by oparoz at 2016-01-12 21:28
  • 5. Adds gitlab CI configuration

    Gitlab CI configuration was "work in progress". This Pull Request gives a sample .gitlab-ci.yml file that will run codecept with the built-in php webserver.

    Reviewed by richardbrinkman at 2016-11-15 08:22
  • 6. Flash message and session error messages

    Hi, I am unable to see session error message using see function nor seefrorm erro or session error fuction returns true, the output html donesn't show flash messages

    Reviewed by umang-ranium at 2015-07-03 09:55
  • 7. Fatal Error when testing form.

    I am new to codeception so I apologize if I have any misunderstanding with the usage.
    I got the following error when I try to run a form I made.

    $I->submitForm('#apply-online', array(
        'apply_name' => 'foobar',
        'apply_tel' => '800-123-1111',
        'apply_email' => '[email protected]',
        'apply_msg' => 'A Test',
        'agree' => 'on',
    ));
    

    Fatal error: Call to undefined method Symfony\Component\DomCrawler\Field\InputFormField::addChoice() in phar:///Applications/MAMP/htdocs/myform/codecept.phar/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Form.php on line 374 FATAL ERROR OCCURRED. TESTS NOT FINISHED.


    In addition to that I tried to following what the site said @ http://codeception.com/docs/04-AcceptanceTests I got errors when I use $I->press('Update'); following in the example. But I got problem with $I->click('Update');

    This is from the example.

    $I = new WebGuy($scenario);
    $I->amOnPage('testform.html');
    $I->fillField('Name', 'Miles');
    // we can use input name, or id
    $I->fillField('user[email]','[email protected]');
    $I->selectOption('Gender','Male');
    $I->press('Update');
    
    Reviewed by awsp at 2012-12-11 01:08
  • 8. [WIP] Add alpine base for Docker

    Add php:7.0-alpine instead of php:7.0-cli as a base, so it could have a lot smaller image.

    Image size comparison:

    | Base | Docker Hub | HDD | |----------------|-----------:|-------:| | php:7.0-cli | 187 MB | 456 MB | | php:7.0-alpine | 42 MB | 102 MB |

    Reviewed by herloct at 2016-11-19 16:36
  • 9. Yii2 rework, new PR same changes.

    • No more static variables
    • No more database connection caching (that didn't actually work)
    • Support for multiple database connections / database services with names other than 'db'

    This needs more testing; I've tested it in a few of my production apps.

    Also somewhere in the docs we should update the "contract" about application state:

    1. When a test starts you get a fresh application.
    2. Just before a request is executed the Request and Response component are reloaded.
    3. Application state is persisted after the request and reused for the next request (as long as it is not in the Request or Response component.
    4. All PDO based connections are supported as long as they are subclasses of yii\db\Connection and fire the AFTER_OPEN event.

    Database handling (for transactions)

    1. All caches are cleared at the end of a test.
    2. At the start of a test we register an event handler for AFTER_OPEN.
    3. When the event is fired we generate a cache key based on connection settings.
    4. We store the PDO object in the cache.
    5. We store an entry in the dsn cache, this is used to identify unsupported cases (think connecting to the same database with different credentials, in which case the transaction creates 2 world views which could cause issues).
    6. If we detect a duplicate PDO object we replace the new PDO with the existing one, this causes the new connection to be closed immediately and guarantees us that the new Connection object uses the same PDO object and thus has the same world view.
    Reviewed by SamMousa at 2018-03-29 07:12
  • 10. Class 'PHPUnit\Framework\ExceptionWrapper' not found

    What are you trying to achieve?

    Trying to run my unit tests. If they pass, everything is well. If the tests fail, an exception is thrown

    What do you get instead?

    $ sudo vendor/bin/codecept run unit Services/Html/MyTest.php -vvv
    PHP Warning:  Class 'PHPUnit\Framework\ExceptionWrapper' not found in /var/www/vagrant/htdocs/vendor/codeception/codeception/shim.php on line 25
    PHP Stack trace:
    PHP   1. {main}() /var/www/vagrant/htdocs/vendor/codeception/codeception/codecept:0
    PHP   2. require_once() /var/www/vagrant/htdocs/vendor/codeception/codeception/codecept:7
    PHP   3. include_once() /var/www/vagrant/htdocs/vendor/codeception/codeception/autoload.php:45
    PHP   4. class_alias() /var/www/vagrant/htdocs/vendor/codeception/codeception/shim.php:25
    
    Warning: Class 'PHPUnit\Framework\ExceptionWrapper' not found in /var/www/vagrant/htdocs/vendor/codeception/codeception/shim.php on line 25
    
    Call Stack:
        0.0001     365608   1. {main}() /var/www/vagrant/htdocs/vendor/codeception/codeception/codecept:0
        0.0018     393048   2. require_once('/var/www/vagrant/htdocs/vendor/codeception/codeception/autoload.php') /var/www/vagrant/htdocs/vendor/codeception/codeception/codecept:7
        0.0753    2958504   3. include_once('/var/www/vagrant/htdocs/vendor/codeception/codeception/shim.php') /var/www/vagrant/htdocs/vendor/codeception/codeception/autoload.php:45
        0.0929    3738248   4. class_alias() /var/www/vagrant/htdocs/vendor/codeception/codeception/shim.php:25
    
    Codeception PHP Testing Framework v2.3.6
    Powered by PHPUnit 6.4.4 by Sebastian Bergmann and contributors.
    
    Unit Tests (1) 
    - MyTest: Index
      [Database] Transaction started
    
    
      [Symfony\Component\Debug\Exception\FatalThrowableError]
      Class 'PHPUnit\Framework\ExceptionWrapper' not found
    
    

    Test details are irrelevant, any test failure will cause the exception. If the tests do not fail, everything works as expected

    Details

    • Codeception version: 2.3.6
    • PHPUnit version: 6.4.4
    • PHP Version: 7
    • Operating System: Ubuntu 16
    • Installation type: Composer
    • Suite configuration: irrelevant, no changes were made
    Reviewed by elimentz at 2017-11-12 01:04
  • 11. PHP 7 + coverage tests using C3 on Travis = Segmentation fault

    Extracted from #2712

    I launch 2 commands in a row on Travis

    $ php vendor/bin/codecept run acceptance --env firefox
    $ php vendor/bin/codecept run api,integration,unit -vvv --coverage --coverage-xml --coverage-html 
    

    The second one will fail with this error message

    [GuzzleHttp\Exception\ConnectException]
    cURL error 7: couldn't connect to host

    in tests/_output/phpbuiltinserver.errors.txt, I get:

    [Wed Jan 13 14:36:32 2016] Failed to listen on localhost:8000 (reason: Address already in use) [Wed Jan 13 14:36:40 2016] ::1:48142 [200]: /c3/report/clear

    or

    [Wed Jan 20 11:28:02 2016] ::1:50413 [200]: /index.php/apps/gallery/files/list?location=&mediatypes=image%2Fpng%3Bimage%2Fjpeg%3Bimage%2Fgif%3Bapplication%2Fpostscript&features=&etag [Wed Jan 20 11:28:10 2016] ::1:50425 [200]: /c3/report/clear

    This does not happen on older version of PHP

    Reviewed by oparoz at 2016-01-20 07:59
  • 12. How to check if an elemet is unique by xpath

    What are you trying to achieve?

    I wanna check that a json element is unique

    What do you get instead?

    The xpath expression does not work

    1) IdempotencyCest: Test
     Test  tests/api/setrex/v3/sync-data/IdempotencyCest.php:test
     Step  See response json matches xpath "count(//documentid[text() ='4821726c1947cdf3eebacade98173939'])=1"
     Fail  Received JSON did not match the XPath `count(//documentid[text() ='4821726c1947cdf3eebacade98173939'])=1`.
    Json Response: 
    

    Provide test source code if related

    $I->seeResponseJsonMatchesXpath("count(//documentid[text() ='4821726c1947cdf3eebacade98173939'])=1");        
    

    Details

     public function seeResponseJsonMatchesXpath(string $xPath): void
        {
            $response = $this->connectionModule->_getResponseContent();
            $this->assertGreaterThan(
                0,
                (new JsonArray($response))->filterByXPath($xPath)->length,
                "Received JSON did not match the XPath `{$xPath}`.\nJson Response: \n" . $response
            );
        }
    

    Does not support any number of occurance, even use $path->evaluate to get a meaninful result for count(//..)=1

     /**
         * @return DOMNodeList|bool
         */
        public function filterByXPath(string $xPath)
        {
            $path = new DOMXPath($this->toXml());
            return $path->query($xPath);
        }
    

    Thanks in advance

    • Codeception version: ^4.2
    • PHP Version: 7.4
    • Operating System: PHP Docker
    • Installation type: Phar || Composer
    • List of installed packages (composer show)
    • Suite configuration:
    # paste suite config here
    
    Reviewed by pamoller at 2022-08-09 11:35
  • 13. Trying to fix `vendor/bin/codecept bootstrap` command for Codeception 5

    I don't really know what I'm doing here, so this is probably not the right way to fix it!

    Anyway - when following https://codeception.com/quickstart, I'm getting v1.0.0 of module-phpbrowser and module-asserts added to composer.json, which aren't compatible with Codeception 5.

    Output:

    $ php vendor/bin/codecept bootstrap
     Bootstrapping Codeception 
    
    File codeception.yml created       <- global configuration
     Adding codeception/module-phpbrowser for PhpBrowser to composer.json
     Adding codeception/module-asserts for Asserts to composer.json
    2 new packages added to require-dev
    ? composer.json updated. Do you want to run "composer update"? (y/n) y
     Running composer update
    Loading composer repositories with package information
    Updating dependencies
    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - codeception/module-phpbrowser[1.0.0, ..., 1.0.1] require php >=5.6.0 <8.0 -> your php version (8.1.8) does not satisfy that requirement.
        - codeception/module-phpbrowser 1.0.2 requires codeception/codeception ^4.0 -> found codeception/codeception[4.0.0, ..., 4.2.1] but it conflicts with your root composer.json require (^5.0).
        - codeception/module-phpbrowser 1.0.3 requires codeception/codeception ^4.1 -> found codeception/codeception[4.1.0, ..., 4.2.1] but it conflicts with your root composer.json require (^5.0).
        - Root composer.json requires codeception/module-phpbrowser ^1.0.0 -> satisfiable by codeception/module-phpbrowser[1.0.0, 1.0.1, 1.0.2, 1.0.3].
    
    Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
     Composer installation failed. Please check composer.json and try to run "composer update" manually
    
    In ModuleContainer.php line 100:
                                                         
      Module Asserts is not installed.                   
      Use Composer to install corresponding package:     
                                                         
      composer require codeception/module-asserts --dev  
                                                         
    
    bootstrap [-s|--namespace [NAMESPACE]] [-a|--actor [ACTOR]] [-e|--empty] [--] [<path>]
    
    Reviewed by ThomasLandauer at 2022-08-08 16:29
  • 14. Codeception 5 does not load new coverage settings from codeception.yml

    What are you trying to achieve?

    Enable path coverage in configuration file

    coverage:
        enabled: true
        path_coverage: true
    

    What do you get instead?

    Only configuration override using parameter -o 'c overage: path_coverage: true' works.

    Reviewed by Naktibalda at 2022-08-07 11:55
  • 15. Codeception 5 templates generate composer.json requiring incompatible versions of modules

    What are you trying to achieve?

    Get working test suite after bootstrap

    What do you get instead?

        "require": {
            "codeception/codeception": "^5.0",
            "codeception/module-asserts": "^1.0.0"
        }
    

    Provide console output if related. Use -vvv mode for more details.

     Adding codeception/module-asserts for Asserts to composer.json
    1 new packages added to require
    ? composer.json updated. Do you want to run "composer update"? (y/n) y
     Running composer update
    Loading composer repositories with package information
    Info from https://repo.packagist.org: #StandWithUkraine
    Updating dependencies
    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - codeception/module-asserts[1.0.0, ..., 1.3.0] require php >=5.6.0 <8.0 -> your php version (8.1.8) does not satisfy that requirement.
        - codeception/lib-asserts[1.13.0, ..., 1.13.1] require php >=5.6.0 <8.0 -> your php version (8.1.8) does not satisfy that requirement.
        - codeception/codeception[5.0.0-alpha1, ..., 5.0.0-alpha3] require phpunit/phpunit dev-master as 9.5.99 -> found phpunit/phpunit[dev-main, 3.7.0, ..., 3.7.38, 4.0.0, ..., 4.8.36, 5.0.0, ..., 5.7.27, 6.0.0, ..., 6.5.14, 7.0.0, ..., 7.5.20, 8.0.0, ..., 8.5.x-dev, 9.0.0, ..., 9.5.x-dev, 10.0.x-dev (alias of dev-main)] but it does not match the constraint. Perhaps dev-master was renamed to dev-main?
        - codeception/module-asserts 1.3.1 requires codeception/codeception *@dev -> satisfiable by codeception/codeception[5.0.0-alpha1, ..., 5.0.x-dev].
        - codeception/codeception[5.0.0-RC1, ..., 5.0.x-dev] require codeception/lib-asserts 2.0.*@dev -> satisfiable by codeception/lib-asserts[2.0.0].
        - You can only install one version of a package, so only one of these can be installed: codeception/lib-asserts[1.0.0, ..., 1.13.2, 2.0.0].
        - codeception/module-asserts 1.3.1 requires codeception/lib-asserts ^1.13.1 -> satisfiable by codeception/lib-asserts[1.13.1, 1.13.2].
        - Root composer.json requires codeception/module-asserts ^1.0.0 -> satisfiable by codeception/module-asserts[1.0.0, ..., 1.3.1].
    
    
    Reviewed by Naktibalda at 2022-08-06 18:00
  • 16. Fixed false negative message about missing stecman/symfony-console-completion packege

    class_exists(ConsoleCompletion::class) return always false in position before import class namespaces.

    The output of this message provokes a problem with establishing a session and adding session handlers. Like this:

      session_set_save_handler(): Session save handler cannot be changed after headers have already been sent  
    
    Reviewed by geega at 2022-08-05 15:47
SimpleTest is a framework for unit testing, web site testing and mock objects for PHP

SimpleTest SimpleTest is a framework for unit testing, web site testing and mock objects for PHP. Installation Downloads All downloads are stored on G

Jun 20, 2022
The modern, simple and intuitive PHP unit testing framework.

atoum PHP version atoum version 5.3 -> 5.6 1.x -> 3.x 7.2 -> 8.x 4.x (current) A simple, modern and intuitive unit testing framework for PHP! Just lik

Jul 27, 2022
AST based PHP Mutation Testing Framework

Infection - Mutation Testing framework Please read documentation here: infection.github.io Twitter: @infection_php Discord: https://discord.gg/ZUmyHTJ

Aug 11, 2022
The PHP Unit Testing framework.

PHPUnit PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks. Installat

Aug 6, 2022
PHP unit testing framework with built in mocks and stubs. Runs in the browser, or via the command line.

Enhance PHP A unit testing framework with mocks and stubs. Built for PHP, in PHP! Quick Start: Just add EnhanceTestFramework.php and you are ready to

Aug 14, 2022
Pest is an elegant PHP Testing Framework with a focus on simplicity
Pest is an elegant PHP Testing Framework with a focus on simplicity

Pest is an elegant PHP Testing Framework with a focus on simplicity. It was carefully crafted to bring the joy of testing to PHP. Explore the docs: pe

Aug 13, 2022
Humbug - a Mutation Testing framework for PHP

Humbug is a Mutation Testing framework for PHP to measure the real effectiveness of your test suites and assist in their improvement. It eats Code Coverage for breakfast.

Jul 27, 2022
A drop in fake logger for testing with the Laravel framework.
A drop in fake logger for testing with the Laravel framework.

Log fake for Laravel A bunch of Laravel facades / services are able to be faked, such as the Dispatcher with Bus::fake(), to help with testing and ass

Aug 2, 2022
Unit testing tips by examples in PHP

Unit testing tips by examples in PHP Introduction In these times, the benefits of writing unit tests are huge. I think that most of the recently start

Aug 2, 2022
PHP libraries that makes Selenium WebDriver + PHPUnit functional testing easy and robust
PHP libraries that makes Selenium WebDriver + PHPUnit functional testing easy and robust

Steward: easy and robust testing with Selenium WebDriver + PHPUnit Steward is a set of libraries made to simplify writing and running robust functiona

Jul 2, 2022
PHPArch is a work in progress architectural testing library for PHP projects

PHPArch What is this? Installation Simple Namespace validation Available Validators Defining an architecture Syntactic sugar: Bulk definition of compo

Jul 28, 2022
An effort to make testing PHP code as easy and fun as its JavaScript equivalent

An effort to make testing PHP code as easy and fun as its JavaScript equivalent when using the excellent Jasmine, from which syntax and general usage is shamelessly borrowed.

Apr 22, 2022
:computer: Parallel testing for PHPUnit

ParaTest The objective of ParaTest is to support parallel testing in PHPUnit. Provided you have well-written PHPUnit tests, you can drop paratest in y

Aug 13, 2022
Few additional testing assertions for Laravel views

Laravel View Test Assertions Few additional assertions for testing Laravel views. Why Laravel has well established and documented way of testing reque

Jun 12, 2022
Real-world Project to learning about Unit Testing/TDD with Laravel for everybody

KivaNote - a Laravel TDD Sample Project Let me introduce you to KivaNote, a simple real-world application using Laravel to show you how the TDD & Unit

May 27, 2022
Magic Test allows you to write browser tests by simply clicking around on the application being tested, all without the slowness of constantly restarting the testing environment.

Magic Test for Laravel Magic Test allows you to write browser tests by simply clicking around on the application being tested, all without the slownes

Aug 9, 2022
Package for unit testing Laravel form request classes
Package for unit testing Laravel form request classes

Package for unit testing Laravel form request classes. Why Colin DeCarlo gave a talk on Laracon online 21 about unit testing Laravel form requests cla

May 11, 2022
A video course for laravel artisan to learn creating API using testing

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Aug 14, 2022
PHPUnit extension for database interaction testing.

This extension is no longer maintained DbUnit PHPUnit extension for database interaction testing. Installation Composer If you use Composer to manage

Jun 20, 2022