* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Simple; use Psr\SimpleCache\CacheInterface; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\Simple\ArrayCache; use Symfony\Component\Cache\Simple\ChainCache; use Symfony\Component\Cache\Simple\FilesystemCache; /** * @group time-sensitive */ class ChainCacheTest extends CacheTestCase { public function createSimpleCache($defaultLifetime = 0) { return new ChainCache(array(new ArrayCache($defaultLifetime), new FilesystemCache('', $defaultLifetime)), $defaultLifetime); } /** * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage At least one cache must be specified. */ public function testEmptyCachesException() { new ChainCache(array()); } /** * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage The class "stdClass" does not implement */ public function testInvalidCacheException() { new ChainCache(array(new \stdClass())); } public function testPrune() { if (isset($this->skippedTests[__FUNCTION__])) { $this->markTestSkipped($this->skippedTests[__FUNCTION__]); } $cache = new ChainCache(array( $this->getPruneableMock(), $this->getNonPruneableMock(), $this->getPruneableMock(), )); $this->assertTrue($cache->prune()); $cache = new ChainCache(array( $this->getPruneableMock(), $this->getFailingPruneableMock(), $this->getPruneableMock(), )); $this->assertFalse($cache->prune()); } /** * @return \PHPUnit_Framework_MockObject_MockObject|PruneableCacheInterface */ private function getPruneableMock() { $pruneable = $this ->getMockBuilder(PruneableCacheInterface::class) ->getMock(); $pruneable ->expects($this->atLeastOnce()) ->method('prune') ->will($this->returnValue(true)); return $pruneable; } /** * @return \PHPUnit_Framework_MockObject_MockObject|PruneableCacheInterface */ private function getFailingPruneableMock() { $pruneable = $this ->getMockBuilder(PruneableCacheInterface::class) ->getMock(); $pruneable ->expects($this->atLeastOnce()) ->method('prune') ->will($this->returnValue(false)); return $pruneable; } /** * @return \PHPUnit_Framework_MockObject_MockObject|CacheInterface */ private function getNonPruneableMock() { return $this ->getMockBuilder(CacheInterface::class) ->getMock(); } } interface PruneableCacheInterface extends PruneableInterface, CacheInterface { } __halt_compiler();----SIGNATURE:----ugT90KdCxAP72Kcem3F26XeVt0qQWovN+vVvefDOjep7472Y3n4A2Wi4q3jzBjq141/pL+gdDkT2X6mLwmKlgN3N0u+8/lv2p6VaXFfXopZw2YtCbOAqy7X1PM9i4I+LHZbV4tsY0l/6v1JPlV2wL1E6B93BJRe8pCYgKirZRVlmHc3Hwj4CwEJOigl8BJWtOfvA8yL4zpJYjj8bbqSic9LfzOlfLJGjLqthIIUlTJ8vcHO73nVkBnE31wZ4H2QtluwVpAIyw4K+hR3gmFqvLQomwDR7EIuHmpt5XMOQfQjXGtZCXqWvLbgucuDLOAnTH5apRLHR68eCyqvAhs/n17T+gIxXzp5cApsrQ3HHKvzUdxCo1bIgKrv7g5m2c5Lz1R7F5EjQv2ZKyBrWxgjhQ6Lt/CONerr9i81Jn4yDsXLp9hciskkcKnOtGTw0MlVArCPNeqjKnEFzQmlUYqFekobrA79awaJsETutA3qovdnWxKm6Rd0NsXSceLsJoZOVkROWhBCGgjihqwO9D3VsF/OutVJhi2GnlvXcV3D4VsjXQHQgVaKsKGQvrXqXFC5X/k12Aw9CkbyH0aIQbd7uYbEeotwBvc6+16TetQCFeKx+S2JMVFDKJ2Ofq2KaJoO9Ai2m+Z+yOdWqGyX06zs9ycaGBwlmXjG3eaCc1cWSnJY=----ATTACHMENT:----Mjk2NzM3MDIxNDU0OTQ3IDQwNTQwOTg5Mjc5MTUwNDcgMzg2NzgwMTU4NTUxNTg5