Codeception: Call to a member function resetApplication() on null

Created on 13 Nov 2018  路  11Comments  路  Source: Codeception/Codeception

What are you trying to achieve?

Run Cest

What do you get instead?

Error

$ codecept --debug run acceptance HomeCest
Codeception PHP Testing Framework v2.5.0
Powered by PHPUnit 7.3.5 by Sebastian Bergmann and contributors.
Running with seed:


Acceptance Tests (1) --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Modules: WebDriver, Yii2
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HomeCest: Ensure that home page works
Signature: HomeCest:ensureThatHomePageWorks
Test: tests\acceptance\HomeCest.php:ensureThatHomePageWorks
Scenario --
  WebDriver::debugWebDriverLogs method has been called when webDriver is not set
  WebDriver::_saveScreenshot method has been called when webDriver is not set
  WebDriver::_savePageSource method has been called when webDriver is not set
  Screenshot and page source were saved into '\tests/_output\' dir
 ERROR 

  Suite done, restoring $_SERVER to original
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Fatal error: Uncaught Error: Call to a member function resetApplication() on null in \vendor\codeception\base\src\Codeception\Module\Yii2.php on line 354

Error: Call to a member function resetApplication() on null in \vendor\codeception\base\src\Codeception\Module\Yii2.php on line 354

Call Stack:
    0.4024     412384   1. {main}() C:\Users\User\AppData\Roaming\Composer\vendor\codeception\codeception\codecept:0
    0.5401    6130488   2. Codeception\Application->run() C:\Users\User\AppData\Roaming\Composer\vendor\codeception\codeception\codecept:43
    0.5401    6130488   3. Codeception\Application->run() C:\Users\User\AppData\Roaming\Composer\vendor\codeception\codeception\src\Codeception\Application.php:108
    0.5639    6280128   4. Codeception\Application->doRun() C:\Users\User\AppData\Roaming\Composer\vendor\symfony\console\Application.php:145
    0.5641    6280128   5. Codeception\Application->doRunCommand() C:\Users\User\AppData\Roaming\Composer\vendor\symfony\console\Application.php:262
    0.5641    6280128   6. Codeception\Command\Run->run() C:\Users\User\AppData\Roaming\Composer\vendor\symfony\console\Application.php:886
    0.5648    6287256   7. Codeception\Command\Run->execute() C:\Users\User\AppData\Roaming\Composer\vendor\symfony\console\Command\Command.php:251
    0.6150    7582672   8. Codeception\Codecept->run() C:\Users\User\AppData\Roaming\Composer\vendor\codeception\codeception\src\Codeception\Command\Run.php:381
    0.6178    7587640   9. Codeception\Codecept->runSuite() C:\Users\User\AppData\Roaming\Composer\vendor\codeception\codeception\src\Codeception\Codecept.php:158
    0.6494    9922848  10. Codeception\SuiteManager->run() C:\Users\User\AppData\Roaming\Composer\vendor\codeception\codeception\src\Codeception\Codecept.php:191
    0.6518   10012120  11. Codeception\PHPUnit\Runner->doEnhancedRun() \vendor\codeception\base\src\Codeception\SuiteManager.php:158
    0.6521   10020824  12. Codeception\Suite->run() \vendor\codeception\phpunit-wrapper\src\Runner.php:117
    0.6522   10021016  13. Codeception\Test\Cest->run() \vendor\phpunit\phpunit\src\Framework\TestSuite.php:750
    1.8690   10231632  14. PHPUnit\Framework\TestResult->endTest() \vendor\codeception\base\src\Codeception\Test\Test.php:111
    1.8690   10231632  15. Codeception\PHPUnit\Listener->endTest() \vendor\phpunit\phpunit\src\Framework\TestResult.php:407
    1.8690   10231984  16. Codeception\PHPUnit\Listener->fire() \vendor\codeception\phpunit-wrapper\src\Listener.php:119
    1.8691   10231984  17. Symfony\Component\EventDispatcher\EventDispatcher->dispatch() \vendor\codeception\phpunit-wrapper\src\Listener.php:133
    1.8691   10232360  18. Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() \vendor\symfony\event-dispatcher\EventDispatcher.php:44
    1.8691   10232360  19. Codeception\Subscriber\Module->after() \vendor\symfony\event-dispatcher\EventDispatcher.php:212
    1.8691   10232360  20. Codeception\Module\Yii2->_after() \vendor\codeception\base\src\Codeception\Subscriber\Module.php:66




FATAL ERROR. TESTS NOT FINISHED.
Uncaught Error: Call to a member function resetApplication() on null in \vendor\codeception\base\src\Codeception\Module\Yii2.php:354
Stack trace:
#0 \vendor\codeception\base\src\Codeception\Subscriber\Module.php(66): Codeception\Module\Yii2->_after(Object(Codeception\Test\Cest))
#1 \vendor\symfony\event-dispatcher\EventDispatcher.php(212): Codeception\Subscriber\Module->after(Object(Codeception\Event\TestEvent), 'test.after', Object(Symfony\Component\Eve
ntDispatcher\EventDispatcher))
#2 \vendor\symfony\event-dispatcher\EventDispatcher.php(44): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'test.after', Object(Codeception\Event\TestEvent
))
#3 \vendor\codeception\phpunit-wrapper\src\Listener.php(133): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('test.after', Object(Codeception\Event\TestEven
in \vendor\codeception\base\src\Codeception\Module\Yii2.php:354

Details

  • Codeception version: 2.5.0
  • PHP Version: 7.2.0
  • Operating System: Windows 10
  • Installation type: Composer
  • List of installed packages (composer show)
$ composer show
2amigos/yii2-ckeditor-widget          2.1.0              CKEditor widget for Yii2.
behat/gherkin                         v4.5.1             Gherkin DSL parser for PHP 5.3
borales/yii2-phone-input              0.1.2              Yii2 International telephone numbers - Asset Bundle, Behavior, Validator, Widget
bower-asset/bootstrap                 v3.3.7
bower-asset/inputmask                 3.3.11
bower-asset/intl-tel-input            v12.4.0
bower-asset/jquery                    3.2.1
bower-asset/jquery-ui                 1.12.1
bower-asset/punycode                  v1.3.2
bower-asset/typeahead.js              v0.11.1
bower-asset/yii2-pjax                 2.0.7.1
bupy7/yii2-pages                      1.4.0              A static pages module implements CRUD using Imperavi Redactor.
cebe/markdown                         1.1.2              A super fast, highly extensible markdown parser for PHP
ckeditor/ckeditor                     4.7.3              JavaScript WYSIWYG web text editor.
codeception/base                      2.5.1              BDD-style testing framework
codeception/phpunit-wrapper           7.3.2              PHPUnit classes used by Codeception
codeception/specify                   0.4.6              BDD code blocks for PHPUnit and Codeception
codeception/stub                      2.0.4              Flexible Stub wrapper for PHPUnit's Mock Builder
codeception/verify                    0.3.3              BDD assertion library for PHPUnit
doctrine/instantiator                 1.1.0              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.6.0              A PHP client for Selenium WebDriver
fzaninotto/faker                      v1.8.0             Faker is a PHP library that generates fake data for you.
giggsey/libphonenumber-for-php        8.9.16             PHP Port of Google's libphonenumber
giggsey/locale                        1.6                Locale functions required by libphonenumber-for-php
guzzlehttp/psr7                       1.4.2              PSR-7 message implementation that also provides common utility methods
kartik-v/bootstrap-fileinput          v4.5.1             An enhanced HTML 5 file input for Bootstrap 3.x with features for file preview for many file types, multiple selection, ajax uploads, and more.
kartik-v/bootstrap-star-rating        v4.0.5             A simple yet powerful JQuery star rating plugin for Bootstrap.
kartik-v/bootstrap-tabs-x             v1.3.2             Extended Bootstrap Tabs with ability to align tabs in multiple ways, add borders, rotated titles, and more.
kartik-v/dependent-dropdown           v1.4.8             A multi level dependent dropdown JQuery plugin that allows nested dependencies.
kartik-v/yii2-date-range              v1.6.9             An advanced Yii 2 date range picker input for based on bootstrap-daterangepicker plugin.
kartik-v/yii2-dialog                  v1.0.4             An asset bundle for bootstrap3-dialog for Yii 2.0 framework.
kartik-v/yii2-dynagrid                dev-master 60bdcb8 Turbo charge the Yii 2 GridView with personalized columns, page size, and themes.
kartik-v/yii2-grid                    v3.2.8             Yii 2 GridView on steroids. Various enhancements and utilities for the Yii 2.0 GridView widget.
kartik-v/yii2-krajee-base             v1.9.9             Base library and foundation components for all Yii2 Krajee extensions.
kartik-v/yii2-sortable                v1.2.1             Create sortable lists and grids using HTML5 drag and drop API for Yii 2.0.
kartik-v/yii2-tabs-x                  v1.2.7             An extended bootstrap 3.0 tabs widget with ability to align tabs in multiple ways, add borders, rotated titles, and more.
kartik-v/yii2-widget-activeform       v1.5.7             Enhanced Yii2 active-form and active-field with full bootstrap styling support (sub repo split from yii2-widgets).
kartik-v/yii2-widget-affix            v1.0.0             A scrollspy and affixed enhanced navigation to highlight page sections (sub repo split from yii2-widgets)
kartik-v/yii2-widget-alert            v1.1.1             A widget to generate alert based notifications using bootstrap-alert plugin (sub repo split from yii2-widgets)
kartik-v/yii2-widget-colorinput       v1.0.5             An enhanced Yii 2 widget encapsulating the HTML 5 color input (sub repo split from yii2-widgets)
kartik-v/yii2-widget-datepicker       v1.4.6             Enhanced Yii2 wrapper for the bootstrap datepicker plugin (sub repo split from yii2-widgets).
kartik-v/yii2-widget-datetimepicker   v1.4.7             Enhanced Yii2 wrapper for the bootstrap datetimepicker plugin (sub repo split from yii2-widgets)
kartik-v/yii2-widget-depdrop          dev-master dce295c Widget that enables setting up dependent dropdowns with nested dependencies (sub repo split from yii2-widgets)
kartik-v/yii2-widget-fileinput        v1.0.8             An enhanced FileInput widget for Bootstrap 3.x & 4.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)
kartik-v/yii2-widget-growl            v1.1.1             A widget to generate growl based notifications using bootstrap-growl plugin (sub repo split from yii2-widgets)
kartik-v/yii2-widget-rangeinput       v1.0.2             An enhanced Yii 2 widget encapsulating the HTML 5 range input (sub repo split from yii2-widgets)
kartik-v/yii2-widget-rating           v1.0.4             A Yii2 widget for the simple yet powerful bootstrap-star-rating plugin with fractional rating support (sub repo split from yii2-widgets)
kartik-v/yii2-widget-select2          v2.1.3             Enhanced Yii2 wrapper for the Select2 jQuery plugin (sub repo split from yii2-widgets).
kartik-v/yii2-widget-sidenav          v1.0.0             An enhanced side navigation menu styled for bootstrap (sub repo split from yii2-widgets)
kartik-v/yii2-widget-spinner          v1.0.0             A widget to render animated CSS3 loading spinners with VML fallback for IE (sub repo split from yii2-widgets)
kartik-v/yii2-widget-switchinput      v1.3.1             A Yii2 wrapper widget for the Bootstrap Switch plugin to use checkboxes & radios as toggle switchinputes (sub repo split from yii2-widgets)
kartik-v/yii2-widget-timepicker       v1.0.3             Enhanced Yii2 wrapper for the bootstrap timepicker plugin (sub repo split from yii2-widgets)
kartik-v/yii2-widget-touchspin        v1.2.3             A Yii2 wrapper widget for the Bootstrap Switch plugin to use checkboxes & radios as toggle touchspines (sub repo split from yii2-widgets)
kartik-v/yii2-widget-typeahead        v1.0.2             Enhanced Yii2 wrapper for the Twitter Typeahead plugin (sub repo split from yii2-widgets).
kartik-v/yii2-widgets                 dev-master 8c10883 Collection of useful widgets for Yii Framework 2.0 extending functionalities for Bootstrap
myclabs/deep-copy                     1.8.1              Create deep copies (clones) of your objects
phar-io/manifest                      1.0.3              Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                       2.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 a DocBlock.
phpdocumentor/type-resolver           0.4.0
phpspec/php-diff                      v1.1.0             A comprehensive library for generating differences between two hashable objects (strings or arrays).
phpspec/prophecy                      1.8.0              Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage             6.1.4              Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator             2.0.2              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.1              Wrapper around PHP's tokenizer extension.
phpunit/phpunit                       7.3.5              The PHP Unit Testing framework.
psr/http-message                      1.0.1              Common interface for HTTP messages
richardfan1126/yii2-sortable-gridview v0.0.6             Sortable GridView for Yii2
sebastian/code-unit-reverse-lookup    1.0.1              Looks up which function or method a line of code belongs to
sebastian/comparator                  3.0.2              Provides the functionality to compare PHP values for equality
sebastian/diff                        3.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
swiftmailer/swiftmailer               v5.4.12            Swiftmailer, free feature-rich PHP mailer
symfony/browser-kit                   v4.1.7             Symfony BrowserKit Component
symfony/console                       v4.1.7             Symfony Console Component
symfony/css-selector                  v4.1.7             Symfony CssSelector Component
symfony/dom-crawler                   v4.1.7             Symfony DomCrawler Component
symfony/event-dispatcher              v4.1.7             Symfony EventDispatcher Component
symfony/finder                        v4.1.7             Symfony Finder Component
symfony/polyfill-ctype                v1.10.0            Symfony polyfill for ctype functions
symfony/polyfill-mbstring             v1.10.0            Symfony polyfill for the Mbstring extension
symfony/process                       v4.1.7             Symfony Process Component
symfony/yaml                          v4.1.7             Symfony Yaml Component
theseer/tokenizer                     1.1.0              A small library for converting tokenized PHP source code into XML and potentially other formats
vova07/yii2-imperavi-widget           2.0.6              The imperavi redactor widget for Yii 2 framework.
webmozart/assert                      1.3.0              Assertions to validate method input/output with nice error messages.
yii2tech/file-storage                 1.1.4              File storage abstraction layer for Yii2
yiisoft/yii2                          2.0.15.1           Yii PHP Framework Version 2
yiisoft/yii2-authclient               2.1.7              External authentication via OAuth and OpenID for the Yii framework
yiisoft/yii2-bootstrap                2.0.8              The Twitter Bootstrap extension for the Yii framework
yiisoft/yii2-composer                 2.0.7              The composer plugin for Yii extension installer
yiisoft/yii2-debug                    2.0.14             The debugger extension for the Yii framework
yiisoft/yii2-faker                    2.0.4              Fixture generator. The Faker integration for the Yii framework.
yiisoft/yii2-gii                      2.0.7              The Gii extension for the Yii framework
yiisoft/yii2-httpclient               2.0.7              HTTP client extension for the Yii framework
yiisoft/yii2-jui                      2.0.7              The Jquery UI extension for the Yii framework
yiisoft/yii2-queue                    2.1.0              Yii2 Queue Extension which supported DB, Redis, RabbitMQ, Beanstalk, SQS and Gearman
yiisoft/yii2-redis                    2.0.9              Redis Cache, Session and ActiveRecord for the Yii framework
yiisoft/yii2-swiftmailer              2.0.7              The SwiftMailer integration for the Yii framework
  • Suite configuration:
class_name: AcceptanceTester
modules:
    enabled:
        - WebDriver:
            url: http://127.0.0.1:8080/
            browser: chrome
        - Yii2:
            part: orm
            entryScript: index-test.php
            cleanup: true
WebDriver

All 11 comments

This issue has been resolved in the latest version. In the future please make sure to update before creating a ticket.

@SamMousa but 2.5 is the last version... Is not it?

No, 2.5.1 is

@SamMousa After upgrading to version 2.5.1, the problem did not resolve.

I also tried to replace in composer.json "codeception/base": "^2.2.3" by "codeception/base": "@dev" and run composer update. After that, the error has changed. Now writes:

Class Codeception\Module\WebDriver contains 3 abstract methods and must therefore be declared abstract or implement the remaining methods (Codeception\Lib\Interfaces\Web::seeInSource, Codeception\Lib\In terfaces\Web::dontSeeInSource, Codeception\Lib\Interfaces\Web::grabPageSource)

codeception/codeception and codeception/base shouldn't be installed at the same time,
pick one.

@Naktibalda But there is no codeception/codeception in the project. There is a globally installed codeception. Well, I deleted the codeception/base in the project and returned the previous error.

But after I replaced codeception/base with codeception/codeception in the project, the error again changed. Now writes: [ConnectionException] Can't connect to Webdriver at http://127.0.0.1:4444/wd/hub. Please make sure that Selenium Server or PhantomJS is running.

Do I understand correctly that I need to install selenium or phantomjs separately? I just never wrote acceptance tests. And what is better: selenium or phantomjs?

PhatomJS project is dead, please look at other options at https://codeception.com/docs/modules/WebDriver#Local-Testing

@Naktibalda I downloaded and launched chromedriver as stated in the instructions, but when I ran the test I received a new error: Facebook\WebDriver\Exception\WebDriverException] JSON decoding of remote response failed. Error code: 4 The response: 'unhandled request'. At the same time, the test clearly does not enter (I debugged using xdebug).

This is my test if necessary:

class HomeCest
{
    public function _before(AcceptanceTester $I) {
        echo "\nbefore\n";
    }

    public function _after(AcceptanceTester $I) {
        echo "\nafter\n";
    }

    public function _fixtures() {
        echo "\nfixtures\n";
        return [];
    }

    public function ensureThatHomePageWorks(AcceptanceTester $I)
    {
        $I->amOnPage(Url::to(['public/index']));
    }
}

By the way, the old error also remained:

$ codecept --debug run acceptance HomeCest

==== Redirecting to Composer-installed version in vendor/codeception ====
Codeception PHP Testing Framework v2.5.1
Powered by PHPUnit 7.3.5 by Sebastian Bergmann and contributors.
Running with seed:


Acceptance Tests (1) --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Modules: WebDriver, Yii2
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HomeCest: Ensure that home page works
Signature: HomeCest:ensureThatHomePageWorks
Test: tests\acceptance\HomeCest.php:ensureThatHomePageWorks
Scenario --
  WebDriver::debugWebDriverLogs method has been called when webDriver is not set
  WebDriver::_saveScreenshot method has been called when webDriver is not set
  WebDriver::_savePageSource method has been called when webDriver is not set
  Screenshot and page source were saved into '\tests/_output\' dir
 ERROR 

  Suite done, restoring $_SERVER to original
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Time: 1.47 seconds, Memory: 12.00MB

There was 1 error:

---------
1) HomeCest: Ensure that home page works
 Test  tests\acceptance\HomeCest.php:ensureThatHomePageWorks

  [Facebook\WebDriver\Exception\WebDriverException] JSON decoding of remote response failed.
Error code: 4
The response: 'unhandled request'


#1  \vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php:298
#2  \vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:126
#3  \vendor\symfony\event-dispatcher\EventDispatcher.php:212
#4  \vendor\symfony\event-dispatcher\EventDispatcher.php:44

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.


Pure selenium earned! Thanks for the help!

Was this page helpful?
0 / 5 - 0 ratings