diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index 0d30afc49ae..f887437721e 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -686,16 +686,19 @@ public function run(TestResult $result = null): TestResult return $result; } + print "## check: TestCase->runInSeperateProcess()\n"; if ($this->runInSeparateProcess()) { $runEntireClass = $this->runClassInSeparateProcess && !$this->runTestInSeparateProcess; $class = new ReflectionClass($this); if ($runEntireClass) { + print "## @runClassInSeperateProcess\n"; $template = new Text_Template( __DIR__ . '/../Util/PHP/Template/TestCaseClass.tpl' ); } else { + print "## @runInSeperateProcess\n"; $template = new Text_Template( __DIR__ . '/../Util/PHP/Template/TestCaseMethod.tpl' ); diff --git a/tests/end-to-end/regression/GitHub/3258/Issue3258Test.php b/tests/end-to-end/regression/GitHub/3258/Issue3258Test.php new file mode 100644 index 00000000000..42d412bb9ca --- /dev/null +++ b/tests/end-to-end/regression/GitHub/3258/Issue3258Test.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * @preserveGlobalState + * @runClassInSeperateProcess + */ +class Issue3258Test extends \PHPUnit\Framework\TestCase +{ + protected $internalCounter = 0; + + /** + */ + public function testVerifyUntouchedStartStateThenUpdateState() + { + $this->assertSame(0, $this->internalCounter); + $this->assertArrayNotHasKey('Issue3258_test_global', $GLOBALS); + + $this->internalCounter++; + $GLOBALS['Issue3258_test_global'] = true; + } + + /** + * @depends testVerifyUntouchedStartStateThenUpdateState + */ + public function testStateHasBeenKeptBetweenTests() + { + $this->assertSame(1, $this->internalCounter); + $this->assertSame(true, $GLOBALS['Issue3258_test_global']); + } +}