Two test cases, the first includes a file with a define() call. The second has a test that is run in a separate process. The define() call will be made twice, which I can't understand.
Happens with PHP 5.4.6, xdebug 2.2.1 and PHPUnit 3.7.18
ATest.php:
<?php
require_once 'Define.php';
class ATest extends PHPUnit_Framework_TestCase
{
public function testA2() {}
}
?>
BTest.php:
<?php
class BTest extends PHPUnit_Framework_TestCase
{
/**
* @runInSeparateProcess
*/
public function testB() {}
}
?>
Define.php:
<?php
define('FOO', 1);
?>
$ phpunit .
PHPUnit 3.7.18 by Sebastian Bergmann.
.E
Time: 0 seconds, Memory: 4.25Mb
There was 1 error:
1) BTest::testB
PHPUnit_Framework_Exception: PHP Notice: Constant FOO already defined in /home/cweiske/Dev/pear/phpunit-defbug/tests/Define.php on line 2
PHP Stack trace:
PHP 1. {main}() -:0
PHP 2. require_once() -:53
PHP 3. require_once() /home/cweiske/Dev/pear/phpunit-defbug/tests/ATest.php:2
PHP 4. define() /home/cweiske/Dev/pear/phpunit-defbug/tests/Define.php:2
Notice: Constant FOO already defined in /home/cweiske/Dev/pear/phpunit-defbug/tests/Define.php on line 2
Call Stack:
0.0005 261336 1. {main}() -:0
0.0022 410920 2. require_once('/home/cweiske/Dev/pear/phpunit-defbug/tests/ATest.#php') -:53
0.0022 412176 3. require_once('/home/cweiske/Dev/pear/phpunit-defbug/tests/Define.php') /home/cweiske/Dev/pear/phpunit-defbug/tests/ATest.php:2
0.0022 412352 4. define() /home/cweiske/Dev/pear/phpunit-defbug/tests/Define.php:2
FAILURES!
Tests: 2, Assertions: 0, Errors: 1.
This is a duplicate of #314. If possible, you can use @preserveGlobalState disabled as a workaround.
Most helpful comment
This is a duplicate of #314. If possible, you can use
@preserveGlobalState disabledas a workaround.