Skip to content

Commit

Permalink
Fix and clarify backup global and static variables test
Browse files Browse the repository at this point in the history
  • Loading branch information
epdenouden authored and sebastianbergmann committed Dec 24, 2018
1 parent 4e3ed98 commit 3f9ef97
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tests/unit/Framework/TestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class TestCaseTest extends TestCase
{
protected static $testStatic = 0;
protected static $testStatic = 456;

protected $backupGlobalsBlacklist = ['i', 'singleton'];

Expand Down Expand Up @@ -418,6 +418,9 @@ public function testGlobalsBackupPost(): void
public function testStaticAttributesBackupPre(): void
{
$GLOBALS['singleton'] = \Singleton::getInstance();
$GLOBALS['i'] = 'not reset by backup';

$GLOBALS['j'] = 'reset by backup';
self::$testStatic = 123;
}

Expand All @@ -426,8 +429,15 @@ public function testStaticAttributesBackupPre(): void
*/
public function testStaticAttributesBackupPost(): void
{
$this->assertNotSame($GLOBALS['singleton'], \Singleton::getInstance());
$this->assertSame(0, self::$testStatic);
// Snapshots made by @backupGlobals
$this->assertSame(\Singleton::getInstance(), $GLOBALS['singleton']);
$this->assertSame('not reset by backup', $GLOBALS['i']);

// Reset global
$this->assertArrayNotHasKey('j', $GLOBALS);

// Static reset to original state by @backupStaticAttributes
$this->assertSame(456, self::$testStatic);
}

public function testIsInIsolationReturnsFalse(): void
Expand Down

0 comments on commit 3f9ef97

Please sign in to comment.