Running code with XDEBUG option enabled, getting: Fatal error: Call to a member function getCookieJar() on null in ....vendor\codeception\codeception\src\Codeception\Module\REST.php on line 102 #3883

Closed
andsol opened this Issue Dec 30, 2016 · 4 comments

Projects

None yet

3 participants

@andsol
andsol commented Dec 30, 2016

What are you trying to achieve?

What do you get instead?

If its null catch this case

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

FATAL ERROR. TESTS NOT FINISHED.
Call to a member function getCookieJar() on null 
in C:\Web\api\vendor\codeception\codeception\src\Codeception\Module\REST.php:102
PHP Fatal error:  Call to a member function getCookieJar() on null in C:\Web\api\vendor\codeception\codeception\src\Codeception\Module\REST.php on line 102
PHP Stack trace:
PHP   1. {main}() C:\Php\codecept.phar:0
PHP   2. require_once() C:\Php\codecept.phar:7
PHP   3. Codeception\Application->run() phar://C:/Php/codecept.phar/codecept:36
PHP   4. Symfony\Component\Console\Application->run() phar://C:/Php/codecept.phar/src/Codeception/Application.php:103

Details

  • Codeception version: ^2.2
  • PHP Version: 7
  • Operating System: win
  • Installation type: Composer
# Codeception API suite configuration
class_name: ApiTester
modules:
    enabled:
        - Db
        - REST:
#            url: https://api.forextime.com
            depends: PhpBrowser
            part: Json
            xdebug_remote: true
@Naktibalda
Contributor

You found some dead code.

        if ($this->config['xdebug_remote']
            && function_exists('xdebug_is_enabled')
            && ini_get('xdebug.remote_enable')
            && !$this->isFunctional
        ) {
            $cookie = new Cookie('XDEBUG_SESSION', $this->config['xdebug_remote'], null, '/');
            $this->client->getCookieJar()->set($cookie);
        }

This code remained mostly untouched since it was written in 2012 and we have no tests for it.
Probably it was broken since one of minor releases (2.1.0 or 2.2.0).

Skipping this code if $this->client is not set is not a solution, because xdebug won't work if the code didn't run.

The client is null, because REST::_before() method runs before PhpBrowser::_before().
@DavertMik What is the best way to ensure that _before of connection module runs first?

@Naktibalda Naktibalda added the REST label Dec 30, 2016
@Naktibalda
Contributor

It would be easier to move xdebug_remote code and configuration to PhpBrowser.

@Naktibalda
Contributor

Nobody wants to debug their entire test suite, they want to debug a specific request.
I think that startRemoteXdebugSession method would be a useful addition to Phpbrowser.

$I->amOnPage('/form');
$I->startRemoteXdebugSession();
$I->click('button');
$I->stopRemoteXdebugSession();
@Naktibalda Naktibalda assigned Naktibalda and unassigned DavertMik Jan 1, 2017
@Naktibalda
Contributor

I haven't found any documentation or search results about xdebug_remote option of REST module,
however I discovered codeception/remote-debug extension which provides very similar functionality.

@Naktibalda Naktibalda added a commit to Naktibalda/Codeception that referenced this issue Jan 1, 2017
@Naktibalda Naktibalda [REST] Removed broken xdebug_remote functionality
Please use codeception/remote-debug package instead
#3883
e82e3f1
@Naktibalda Naktibalda closed this in #3887 Jan 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment