Skip to content

Commit 34114e8

Browse files
committed
WIP exploratory testing of @run[Class]InSeperateProcess annotations
1 parent 543f76a commit 34114e8

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/Framework/TestCase.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,16 +686,19 @@ public function run(TestResult $result = null): TestResult
686686
return $result;
687687
}
688688

689+
print "## check: TestCase->runInSeperateProcess()\n";
689690
if ($this->runInSeparateProcess()) {
690691
$runEntireClass = $this->runClassInSeparateProcess && !$this->runTestInSeparateProcess;
691692

692693
$class = new ReflectionClass($this);
693694

694695
if ($runEntireClass) {
696+
print "## @runClassInSeperateProcess\n";
695697
$template = new Text_Template(
696698
__DIR__ . '/../Util/PHP/Template/TestCaseClass.tpl'
697699
);
698700
} else {
701+
print "## @runInSeperateProcess\n";
699702
$template = new Text_Template(
700703
__DIR__ . '/../Util/PHP/Template/TestCaseMethod.tpl'
701704
);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
/**
12+
* @preserveGlobalState
13+
* @runClassInSeperateProcess
14+
*/
15+
class Issue3258Test extends \PHPUnit\Framework\TestCase
16+
{
17+
protected $internalCounter = 0;
18+
19+
/**
20+
*/
21+
public function testVerifyUntouchedStartStateThenUpdateState()
22+
{
23+
$this->assertSame(0, $this->internalCounter);
24+
$this->assertArrayNotHasKey('Issue3258_test_global', $GLOBALS);
25+
26+
$this->internalCounter++;
27+
$GLOBALS['Issue3258_test_global'] = true;
28+
}
29+
30+
/**
31+
* @depends testVerifyUntouchedStartStateThenUpdateState
32+
*/
33+
public function testStateHasBeenKeptBetweenTests()
34+
{
35+
$this->assertSame(1, $this->internalCounter);
36+
$this->assertSame(true, $GLOBALS['Issue3258_test_global']);
37+
}
38+
}

0 commit comments

Comments
 (0)