/** * @test * @dataProvider dataProviderForExceptions */ public function whenAnExceptionOccoursItWillRemoveTheTemporaryCacheKey($exception) { $this->setExpectedException(get_class($exception)); $storage = $this->mockWithPhpUnit(); $storage->expects($this->at(0))->method('setItem')->with($this->delayedKey)->will($this->returnValue(true)); $storage->expects($this->at(1))->method('removeItem')->with($this->delayedKey)->will($this->returnValue(true)); $this->cache->setItem('foo', function () use($exception) { throw $exception; }); }
/** * @test */ public function canSetItemAsClosure() { $this->storage->setItem($this->delayedKey, 'under_construction')->willReturn(true); $this->storage->setItem('foo', 'bar')->willReturn(true); $this->storage->removeItem($this->delayedKey)->willReturn(true); $return = $this->cache->setItem('foo', function () { return 'bar'; }); $this->assertTrue($return); }