Codeception: Fatal error: Declaration of Codeception\Test\Test::run(?PHPUnit\Framework\TestResult $result = NULL) must be compatible with PHPUnit\Framework\Test::run

What are you trying to achieve?

Run all tests

What do you get instead?

Fatal Error

Fatal error: Declaration of Codeception\Test\Test::run(?PHPUnit\Framework\TestResult $result = NULL) must be compatible with PHPUnit\Framework\Test::run(?PHPUnit\Framework\TestResult $result = NULL): PHPUnit\Framework\TestResult in /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/codeception/codeception/src/Codeception/Test/Test.php on line 18

Call Stack:
    0.0003     346368   1. {main}() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/codeception/codeception/codecept:0
    0.3112    2053088   2. Codeception\Application->run() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/codeception/codeception/codecept:42
    0.3112    2053088   3. Symfony\Component\Console\Application->run() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/codeception/codeception/src/Codeception/Application.php:108
    0.3288    2135752   4. Symfony\Component\Console\Application->doRun() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/symfony/console/Application.php:148
    0.3289    2135752   5. Symfony\Component\Console\Application->doRunCommand() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/symfony/console/Application.php:248
    0.3290    2135752   6. Symfony\Component\Console\Command\Command->run() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/symfony/console/Application.php:946
    0.3296    2142736   7. Codeception\Command\Run->execute() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/symfony/console/Command/Command.php:252
    0.3781    2451416   8. Codeception\Command\Run->runSuites() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/codeception/codeception/src/Codeception/Command/Run.php:361
    0.3781    2451416   9. Codeception\Codecept->run() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/codeception/codeception/src/Codeception/Command/Run.php:466
    0.3869    2459592  10. Codeception\Codecept->runSuite() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/codeception/codeception/src/Codeception/Codecept.php:158
    1.7759    4340168  11. Codeception\SuiteManager->loadTests() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/codeception/codeception/src/Codeception/Codecept.php:188
    1.8535    5369776  12. Codeception\Test\Loader->loadTests() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/codeception/codeception/src/Codeception/SuiteManager.php:95
    1.8590    5423544  13. Codeception\Test\Loader\Cest->loadTests() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/codeception/codeception/src/Codeception/Test/Loader.php:134
    1.8642    5426536  14. spl_autoload_call() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/codeception/codeception/src/Codeception/Test/Loader/Cest.php:98
    1.8642    5426584  15. Composer\Autoload\ClassLoader->loadClass() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/codeception/codeception/src/Codeception/Test/Loader/Cest.php:98
    1.8647    5426744  16. Composer\Autoload\includeFile() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/composer/ClassLoader.php:322
    1.8670    5428824  17. include('/app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/codeception/codeception/src/Codeception/Test/Cest.php') /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/composer/ClassLoader.php:440
    1.8670    5428824  18. spl_autoload_call() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/codeception/codeception/src/Codeception/Test/Cest.php:16
    1.8670    5428872  19. Composer\Autoload\ClassLoader->loadClass() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/codeception/codeception/src/Codeception/Test/Cest.php:16
    1.8674    5429032  20. Composer\Autoload\includeFile() /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/composer/ClassLoader.php:322
    1.8689    5430480  21. include('/app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/codeception/codeception/src/Codeception/Test/Test.php') /app/public/wp-content/plugins/woocommerce-waitlist/tests/vendor/composer/ClassLoader.php:440

Details

  • Codeception version: 2.4.1
  • PHP Version: 7.1.4
  • Operating System: macOS 10.13.4
  • Installation type: Composer
  • List of installed packages (composer show)
  • Suite configuration:
paths:
    tests: tests
    output: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs
actor_suffix: Tester
extensions:
    enabled:
        - Codeception\Extension\RunFailed
    commands:
        - Codeception\Command\GenerateWPUnit
        - Codeception\Command\GenerateWPRestApi
        - Codeception\Command\GenerateWPRestController
        - Codeception\Command\GenerateWPRestPostTypeController
        - Codeception\Command\GenerateWPAjax
        - Codeception\Command\GenerateWPCanonical
        - Codeception\Command\GenerateWPXMLRPC
        - Codeception\Command\DbSnapshot
        - tad\Codeception\Command\SearchReplace

Installed components

Dump of composer show:

antecedent/patchwork               2.1.8     Method redefinition (monkey-patching) functionality for PHP.
bacon/bacon-string-utils           1.1.0     BaconStringUtils contain utitilies to work with strings.
behat/gherkin                      v4.5.1    Gherkin DSL parser for PHP 5.3
codeception/codeception            2.4.1     BDD-style testing framework
codeception/phpunit-wrapper        7.1.2     PHPUnit classes used by Codeception
codeception/stub                   1.0.4     Flexible Stub wrapper for PHPUnit's Mock Builder
composer/ca-bundle                 1.1.1     Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.
composer/composer                  1.6.5     Composer helps you declare, manage and install dependencies of PHP projects, ensuring you have the right stack everywhere.
composer/semver                    1.4.2     Semver library that offers utilities, version constraint parsing and validation.
composer/spdx-licenses             1.4.0     SPDX licenses list and validation library.
dg/mysql-dump                      v1.4.0    MySQL database dump.
doctrine/inflector                 v1.3.0    Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator              1.1.0     A small, lightweight utility to instantiate objects in PHP without invoking their constructors
facebook/webdriver                 1.6.0     A PHP client for Selenium WebDriver
gumlet/php-image-resize            1.8.0     PHP class to re-size and scale images
guzzlehttp/guzzle                  6.3.3     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
hautelook/phpass                   0.3.5     Portable PHP password hashing framework
illuminate/contracts               v5.6.22   The Illuminate Contracts package.
illuminate/support                 v5.6.22   The Illuminate Support package.
jakoch/phantomjs-installer         2.1.1-p08 A Composer package which installs the PhantomJS binary (Linux, Windows, Mac) into `/bin` of your project.
jonnyw/php-phantomjs               v4.6.1    A PHP wrapper for loading pages through PhantomJS
justinrainbow/json-schema          5.2.7     A library to validate a json schema.
lucatume/codeception-setup-local   1.0.3     Flexible local setup for Codeception
lucatume/wp-browser                1.24.4    WordPress extension of the PhpBrowser class.
lucatume/wp-browser-commons        1.2.8.2   Common libraries of the WP-Browser package.
mikemclin/laravel-wp-password      2.0.1     Laravel package that checks and creates WordPress password hashes
mustache/mustache                  v2.12.0   A Mustache implementation in PHP.
myclabs/deep-copy                  1.7.0     Create deep copies (clones) of your objects
nb/oxymel                          v0.1.0    A sweet XML builder
nesbot/carbon                      1.27.0    A simple API extension for DateTime.
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 embedded in...
phpdocumentor/type-resolver        0.4.0     
phpspec/prophecy                   1.7.6     Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage          6.0.4     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                  2.0.0     Utility class for timing
phpunit/php-token-stream           3.0.0     Wrapper around PHP's tokenizer extension.
phpunit/phpunit                    7.1.5     The PHP Unit Testing framework.
phpunit/phpunit-mock-objects       6.1.1     Mock Object library for PHPUnit
psr/container                      1.0.0     Common Container Interface (PHP FIG PSR-11)
psr/http-message                   1.0.1     Common interface for HTTP messages
psr/log                            1.0.2     Common interface for logging libraries
psr/simple-cache                   1.0.1     Common interfaces for simple caching
ramsey/array_column                1.1.3     Provides functionality for array_column() to projects using PHP earlier than version 5.5.
rmccue/requests                    v1.7.0    A HTTP library written in PHP, for human beings.
sebastian/code-unit-reverse-lookup 1.0.1     Looks up which function or method a line of code belongs to
sebastian/comparator               3.0.0     Provides the functionality to compare PHP values for equality
sebastian/diff                     3.0.0     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
seld/cli-prompt                    1.0.3     Allows you to prompt for user input on the command line, and optionally hide the characters they type
seld/jsonlint                      1.7.1     JSON Linter
seld/phar-utils                    1.0.1     PHAR file format utilities, for when PHP phars you up
symfony/browser-kit                v4.0.9    Symfony BrowserKit Component
symfony/config                     v3.4.9    Symfony Config Component
symfony/console                    v3.4.9    Symfony Console Component
symfony/css-selector               v4.0.9    Symfony CssSelector Component
symfony/debug                      v3.4.9    Symfony Debug Component
symfony/dependency-injection       v3.4.9    Symfony DependencyInjection Component
symfony/dom-crawler                v4.0.9    Symfony DomCrawler Component
symfony/event-dispatcher           v3.4.9    Symfony EventDispatcher Component
symfony/filesystem                 v2.8.39   Symfony Filesystem Component
symfony/finder                     v3.4.9    Symfony Finder Component
symfony/polyfill-mbstring          v1.8.0    Symfony polyfill for the Mbstring extension
symfony/process                    v3.4.9    Symfony Process Component
symfony/translation                v3.4.9    Symfony Translation Component
symfony/yaml                       v3.4.9    Symfony Yaml Component
theseer/tokenizer                  1.1.0     A small library for converting tokenized PHP source code into XML and potentially other formats
twig/twig                          v1.35.3   Twig, the flexible, fast, and secure template language for PHP
vlucas/phpdotenv                   v2.4.0    Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
webmozart/assert                   1.3.0     Assertions to validate method input/output with nice error messages.
wp-cli/autoload-splitter           v0.1.5    Composer plugin for splitting a generated autoloader into two distinct parts.
wp-cli/cache-command               v1.0.6    Manages object and transient caches.
wp-cli/checksum-command            v1.0.9    Verifies file integrity by comparing to published checksums.
wp-cli/config-command              v1.2.0    Generates and reads the wp-config.php file.
wp-cli/core-command                v1.0.9    Downloads, installs, updates, and manages a WordPress installation.
wp-cli/cron-command                v1.0.5    Tests, runs, and deletes WP-Cron events; manages WP-Cron schedules.
wp-cli/db-command                  v1.3.3    Performs basic database operations using credentials stored in wp-config.php.
wp-cli/embed-command               v1.0.0    Inspects oEmbed providers, clears embed cache, and more.
wp-cli/entity-command              v1.2.0    Manage WordPress core entities.
wp-cli/eval-command                v1.0.5    Executes arbitrary PHP code or files.
wp-cli/export-command              v1.0.6    Exports WordPress content to a WXR file.
wp-cli/extension-command           v1.1.10   Manages plugins and themes, including installs, activations, and updates.
wp-cli/import-command              v1.0.6    Imports content from a given WXR file.
wp-cli/language-command            v1.0.6    Installs, activates, and manages language packs.
wp-cli/media-command               v1.1.4    Imports files as attachments, regenerates thumbnails, or lists registered image sizes.
wp-cli/mustangostang-spyc          0.6.3     A simple YAML loader/dumper class for PHP (WP-CLI fork)
wp-cli/package-command             v1.0.13   Lists, installs, and removes WP-CLI packages.
wp-cli/php-cli-tools               v0.11.9   Console utilities for PHP
wp-cli/rewrite-command             v1.0.5    Lists or flushes the site's rewrite rules, updates the permalink structure.
wp-cli/role-command                v1.1.0    Adds, removes, lists, and resets roles and capabilities.
wp-cli/scaffold-command            v1.1.3    Generates code for post types, taxonomies, blocks, plugins, child themes, etc.
wp-cli/search-replace-command      v1.3.0    Searches/replaces strings in the database.
wp-cli/server-command              v1.0.9    Launches PHP's built-in web server for a specific WordPress installation.
wp-cli/shell-command               v1.0.5    Opens an interactive PHP console for running and testing PHP code.
wp-cli/super-admin-command         v1.0.6    Lists, adds, or removes super admin users on a multisite installation.
wp-cli/widget-command              v1.0.5    Adds, moves, and removes widgets; lists sidebars.
wp-cli/wp-cli                      v1.5.1    The command line interface for WordPress
wp-cli/wp-config-transformer       v1.2.1    Programmatically edit a wp-config.php file.
xamin/handlebars.php               v0.10.4   Handlebars processor for php

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (5 by maintainers)

Most upvoted comments

@DavertMik Are we sure this is fixed? There’s no return type declared in the line of code you linked (which is a difference declared in the error @leglesslizard posted), and I’m seeing a similar issue with toString():

Codeception PHP Testing Framework v2.4.2
Powered by PHPUnit 7.1.5 by Sebastian Bergmann and contributors.
PHP Fatal error:  Declaration of Codeception\Test\Test::toString() must be compatible with PHPUnit\Framework\SelfDescribing::toString(): string in /vagrant/lib/vendor/codeception/codeception/src/Codeception/Test/Test.php on line 18
PHP Stack trace:
PHP   1. {main}() /vagrant/lib/vendor/codeception/codeception/codecept:0
PHP   2. Codeception\Application->run() /vagrant/lib/vendor/codeception/codeception/codecept:42
PHP   3. Codeception\Application->run() /vagrant/lib/vendor/codeception/codeception/src/Codeception/Application.php:108
PHP   4. Codeception\Application->doRun() /vagrant/lib/vendor/symfony/console/Application.php:122
PHP   5. Codeception\Application->doRunCommand() /vagrant/lib/vendor/symfony/console/Application.php:215
PHP   6. Codeception\Command\Run->run() /vagrant/lib/vendor/symfony/console/Application.php:858
PHP   7. Codeception\Command\Run->execute() /vagrant/lib/vendor/symfony/console/Command/Command.php:240
PHP   8. Codeception\Command\Run->runSuites() /vagrant/lib/vendor/codeception/codeception/src/Codeception/Command/Run.php:361
PHP   9. Codeception\Codecept->run() /vagrant/lib/vendor/codeception/codeception/src/Codeception/Command/Run.php:466
PHP  10. Codeception\Codecept->runSuite() /vagrant/lib/vendor/codeception/codeception/src/Codeception/Codecept.php:158
PHP  11. Codeception\SuiteManager->loadTests() /vagrant/lib/vendor/codeception/codeception/src/Codeception/Codecept.php:188
PHP  12. Codeception\Test\Loader->loadTests() /vagrant/lib/vendor/codeception/codeception/src/Codeception/SuiteManager.php:95
PHP  13. Codeception\Test\Loader\Cept->loadTests() /vagrant/lib/vendor/codeception/codeception/src/Codeception/Test/Loader.php:134
PHP  14. spl_autoload_call() /vagrant/lib/vendor/codeception/codeception/src/Codeception/Test/Loader/Cept.php:21
PHP  15. Composer\Autoload\ClassLoader->loadClass() /vagrant/lib/vendor/codeception/codeception/src/Codeception/Test/Loader/Cept.php:21
PHP  16. Composer\Autoload\includeFile() /vagrant/lib/vendor/composer/ClassLoader.php:322
PHP  17. include() /vagrant/lib/vendor/composer/ClassLoader.php:444
PHP  18. spl_autoload_call() /vagrant/lib/vendor/codeception/codeception/src/Codeception/Test/Cept.php:12
PHP  19. Composer\Autoload\ClassLoader->loadClass() /vagrant/lib/vendor/codeception/codeception/src/Codeception/Test/Cept.php:12
PHP  20. Composer\Autoload\includeFile() /vagrant/lib/vendor/composer/ClassLoader.php:322
PHP  21. include() /vagrant/lib/vendor/composer/ClassLoader.php:444

Here’s a truncated output of my composer show, to prove I’m running the latest of Codeception and PHPUnit Wrapper:

...
codeception/codeception             2.4.2              BDD-style testing framework
codeception/phpunit-wrapper         7.1.3              PHPUnit classes used by Codeception
codeception/stub                    2.0.1              Flexible Stub wrapper for PHPUnit's Mock Builder
...
phpunit/dbunit                      4.0.0              PHPUnit extension for database interaction testing
phpunit/php-code-coverage           6.0.5              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                   2.0.0              Utility class for timing
phpunit/php-token-stream            3.0.0              Wrapper around PHP's tokenizer extension.
phpunit/phpunit                     7.1.5              The PHP Unit Testing framework.
phpunit/phpunit-mock-objects        6.1.2              Mock Object library for PHPUnit
...
sebastian/code-unit-reverse-lookup  1.0.1              Looks up which function or method a line of code belongs to
sebastian/comparator                3.0.0              Provides the functionality to compare PHP values for equality
sebastian/diff                      3.0.0              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/finder-facade             1.2.2              FinderFacade is a convenience wrapper for Symfony's Finder component.
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/phpcpd                    4.0.0              Copy/Paste Detector (CPD) for PHP code.
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
...

Thanks for raising a new issue.

Reposting my comment.

Fatal error: Declaration of Codeception\Test\Test::run(?PHPUnit\Framework\TestResult $result = NULL) must be compatible with PHPUnit\Framework\Test::run(?PHPUnit\Framework\TestResult $result = NULL): PHPUnit\Framework\TestResult in /Applications/MAMP/htdocs/wad-tests/vendor/codeception/codeception/src/Codeception/Test/Test.php on line 18

@DavertMik it looks like Test format is incompatible with PhpUnit 7. Have you got any ideas how to fix it without breaking compatibility with older versions of PhpUnit?

@leglesslizard You could get around this issue, by restricting version of PhpUnit to 6.* "phpunit/phpunit": "6.*"