From ff370bf5e9136056afd3b97ffba0eda9fe000c3d Mon Sep 17 00:00:00 2001 From: webimpress Date: Wed, 28 Aug 2019 21:47:17 +0100 Subject: [PATCH] Add tests with mocking to cover changes from the PR --- .../SimpleCache/SimpleCacheDecoratorTest.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/Psr/SimpleCache/SimpleCacheDecoratorTest.php b/test/Psr/SimpleCache/SimpleCacheDecoratorTest.php index c74cd6c53..f362f3fbc 100644 --- a/test/Psr/SimpleCache/SimpleCacheDecoratorTest.php +++ b/test/Psr/SimpleCache/SimpleCacheDecoratorTest.php @@ -791,4 +791,30 @@ public function testUseTtlFromOptionsWhenNotProvidedOnSetMultiple() self::assertSame(20, $storage->ttl['bar']); self::assertSame(20, $storage->getOptions()->getTtl()); } + + public function testUseTtlFromOptionsOnSetMocking() + { + $this->options->getTtl()->willReturn(40); + $this->options->setTtl(40)->will([$this->options, 'reveal']); + + $this->options->setTtl(null)->shouldNotBeCalled(); + + $this->storage->getOptions()->will([$this->options, 'reveal']); + $this->storage->setItem('foo', 'bar')->willReturn(true); + + self::assertTrue($this->cache->set('foo', 'bar')); + } + + public function testUseTtlFromOptionsOnSetMultipleMocking() + { + $this->options->getTtl()->willReturn(40); + $this->options->setTtl(40)->will([$this->options, 'reveal']); + + $this->options->setTtl(null)->shouldNotBeCalled(); + + $this->storage->getOptions()->will([$this->options, 'reveal']); + $this->storage->setItems(['foo' => 'bar', 'boo' => 'baz'])->willReturn([]); + + self::assertTrue($this->cache->setMultiple(['foo' => 'bar', 'boo' => 'baz'])); + } }