From d3e2cbd140c14bb4fec57f974310e7dad6f28794 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 27 Oct 2019 14:02:40 +1100 Subject: [PATCH] [NFC] Add in debugging to try and resolve E2E Cache intermitant test failures --- .../phpunit/E2E/Cache/ArrayDecoratorTest.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/phpunit/E2E/Cache/ArrayDecoratorTest.php b/tests/phpunit/E2E/Cache/ArrayDecoratorTest.php index 1dec75a00c..ae77d54a28 100644 --- a/tests/phpunit/E2E/Cache/ArrayDecoratorTest.php +++ b/tests/phpunit/E2E/Cache/ArrayDecoratorTest.php @@ -80,4 +80,26 @@ class E2E_Cache_ArrayDecoratorTest extends E2E_Cache_CacheTestCase { $this->assertEquals('dfl-1', $this->a->get('foo', 'dfl-1')); } + public function testSetTtl() { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + } + $result = $this->cache->set('key1', 'value', 1); + $this->assertTrue($result, 'set() must return true if success'); + $this->assertEquals('value', $this->cache->get('key1')); + sleep(2); + $this->assertNull($this->cache->get('key1'), 'Value must expire after ttl.'); + + $this->cache->set('key2', 'value', new \DateInterval('PT1S')); + $key2Value = $this->cache->get('key2'); + if ($key2Value !== 'value') { + // dump out contents of cache. + var_dump($this->cache); + print_r(date('u') . 'Current UNIX timestamp'); + } + $this->assertEquals('value', $key2Value); + sleep(2); + $this->assertNull($this->cache->get('key2'), 'Value must expire after ttl.'); + } + } -- 2.25.1