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

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ public function setExpirationSeconds($ttl, $vars = null)
}

if (null === $vars) {
$this->expireKeys(); // first we need to expire global key, since it can already be expired
$data = array('EXPIRE' => $ts);
} elseif (is_array($vars)) {
// Cannot pass "$this" to a lambda
Expand Down Expand Up @@ -518,6 +519,7 @@ public function setExpirationHops($hops, $vars = null)
}

if (null === $vars) {
$this->expireKeys(); // first we need to expire global key, since it can already be expired
$data = array('EXPIRE_HOPS' => array('hops' => $hops, 'ts' => $ts));
} elseif (is_array($vars)) {
// Cannot pass "$this" to a lambda
Expand Down
19 changes: 19 additions & 0 deletions test/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
*/
class ContainerTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Manager
*/
protected $manager;

/**
* @var Container
*/
protected $container;

public function setUp()
{
$this->forceAutoloader();
Expand Down Expand Up @@ -283,6 +293,15 @@ public function testKeyExistsWithExpirationInPastReturnsFalse()
$this->assertTrue(isset($this->container->bar));
}

public function testKeyExistsWithContainerExpirationInPastWithSetExpirationSecondsReturnsFalse()
{
$this->container->foo = 'bar';
$storage = $this->manager->getStorage();
$storage->setMetadata('Default', array('EXPIRE' => $_SERVER['REQUEST_TIME'] - 18600));
$this->container->setExpirationSeconds(1);
$this->assertFalse(isset($this->container->foo));
}

public function testSettingExpiredKeyOverwritesExpiryMetadataForThatKey()
{
$this->container->foo = 'bar';
Expand Down

0 comments on commit 6b3eedb

Please sign in to comment.