Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Do not backup $_SERVER in tests
Browse files Browse the repository at this point in the history
PHPUnit does this automatically.
  • Loading branch information
weierophinney committed Nov 29, 2017
1 parent 557af91 commit 1d97a6a
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions test/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,22 +237,11 @@ public function testSettingExpirationSecondsUsesCurrentTime()
$this->container->setExpirationSeconds(2);
$this->container->foo = 'bar';

// Simulate a second request, backup the request time and overwrite it with current time()
$requestTimeBackup = $_SERVER['REQUEST_TIME'];
$requestTimeFloatBackup = $_SERVER['REQUEST_TIME_FLOAT'] ?? null;

// Simulate a second request: overwrite the request time with current time()
$_SERVER['REQUEST_TIME'] = time();
$_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);

try {
$this->assertEquals('bar', $this->container->foo);
} catch (\Throwable $e) {
// Restore the original values
$_SERVER['REQUEST_TIME'] = $requestTimeBackup;
$_SERVER['REQUEST_TIME_FLOAT'] = $requestTimeFloatBackup;

throw $e;
}
$this->assertEquals('bar', $this->container->foo);
}

public function testPassingUnsetKeyToSetExpirationSecondsDoesNothing()
Expand Down

0 comments on commit 1d97a6a

Please sign in to comment.