New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

This comment has been minimized.

Show comment
Hide comment
@Naktibalda

Naktibalda Dec 30, 2016

Member

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?

Member

Naktibalda commented Dec 30, 2016

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

This comment has been minimized.

Show comment
Hide comment
@Naktibalda

Naktibalda Dec 30, 2016

Member

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

Member

Naktibalda commented Dec 30, 2016

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

@Naktibalda

This comment has been minimized.

Show comment
Hide comment
@Naktibalda

Naktibalda Dec 31, 2016

Member

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();
Member

Naktibalda commented Dec 31, 2016

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

This comment has been minimized.

Show comment
Hide comment
@Naktibalda

Naktibalda Jan 1, 2017

Member

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.

Member

Naktibalda commented Jan 1, 2017

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 added a commit to Naktibalda/Codeception that referenced this issue Jan 1, 2017

[REST] Removed broken xdebug_remote functionality
Please use codeception/remote-debug package instead
#3883

@Naktibalda Naktibalda closed this in #3887 Jan 16, 2017

chris1312 added a commit to chris1312/Codeception that referenced this issue Jun 16, 2017

[REST] Removed broken xdebug_remote functionality
Please use codeception/remote-debug package instead
#3883
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment