3

To use phpunit_coverage.php I need to set auto_prepend_file and auto_append_file properties in php.ini to specified files prepend.php and append.php. In both scripts cookies are checked to make sure that test is running:

if ( isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) &&

The problem is that this cookie is kept as localhost's cookie, not the webserver's. So when it is checked, it is not set and xdebug doesn't start.

Selenium and webserver are located on different machines, could this be the cause of this error?

Situation is displayed here:

firefox cookies manager

3
  • I found out that problem is when I create cookie with createCookie() method, it is assigned to localhost, so I don't have any access to it after. Commented Mar 6, 2013 at 4:12
  • Did you ever come up with a work around for this? I'm hitting it now. Commented Jul 9, 2015 at 22:49
  • 1
    @KarlZilles Have you tried Jérôme workaround? Unfortunately, this was a long time ago and I don't remember exactly how I've solved this problem. I don't have any access to this code now and I guess it has been changed after I had left that job. The only thing I remember is that I specified host in configuration, and possibly used it to set a cookie explicitly for a given host. Good luck with this! Commented Jul 10, 2015 at 6:14

1 Answer 1

1

Similar issue. I thought at first of a domain problem as the tested web site is on a vhost.

But I found out that calling $this->url('some_url') seemed to silently delete the PHPUNIT_SELENIUM_TEST_ID cookie.

My workaround was overriding the url() method in my test cases, in order to reset the cookie once url() is called.

protected function url($url =null)
{
    try {
        $cookie = $this->cookie()->get('PHPUNIT_SELENIUM_TEST_ID');
    }
    catch (Exception $e) {}

    $result = parent::url($url);

    if (isset($cookie)) {
        $this->cookie()->add('PHPUNIT_SELENIUM_TEST_ID', $cookie)->set();
    }

    return $result;
}

The code coverage files are now correctly created.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.