Skip to content

Commit

Permalink
Merge pull request sebastianbergmann#1360 from sun/istestinisolation
Browse files Browse the repository at this point in the history
Allow a test to identify whether it runs in isolation
  • Loading branch information
whatthejeff committed Jul 27, 2014
2 parents b617a1f + 6b308c3 commit 2608a34
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,14 @@ public function setInIsolation($inIsolation)
}
}

/**
* @return boolean
*/
public function isInIsolation()
{
return $this->inIsolation;
}

/**
* @return mixed
* @since Method available since Release 3.4.0
Expand Down
19 changes: 19 additions & 0 deletions tests/Framework/TestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,25 @@ public function testStaticAttributesBackupPost()
$this->assertSame(123, self::$_testStatic);
}

public function testIsInIsolationReturnsFalse()
{
$test = new IsolationTest('testIsInIsolationReturnsFalse');
$result = $test->run();

$this->assertEquals(1, count($result));
$this->assertTrue($result->wasSuccessful());
}

public function testIsInIsolationReturnsTrue()
{
$test = new IsolationTest('testIsInIsolationReturnsTrue');
$test->setRunTestInSeparateProcess(true);
$result = $test->run();

$this->assertEquals(1, count($result));
$this->assertTrue($result->wasSuccessful());
}

public function testExpectOutputStringFooActualFoo()
{
$test = new OutputTestCase('testExpectOutputStringFooActualFoo');
Expand Down
13 changes: 13 additions & 0 deletions tests/_files/IsolationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
class IsolationTest extends PHPUnit_Framework_TestCase
{
public function testIsInIsolationReturnsFalse()
{
$this->assertFalse($this->isInIsolation());
}

public function testIsInIsolationReturnsTrue()
{
$this->assertTrue($this->isInIsolation());
}
}

0 comments on commit 2608a34

Please sign in to comment.