* * 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:----KjerUBGfboTyhbYFVCz0cmbjnTWGjS6x+rCS0ONGL0LRDPC2rMku1R88d3qHAvtrzTUOMtfP/qk7Pw4P9Gb4rmwpKDTGedK3XBfyljXvvWzlzlP3ieaRd7KRm4u5VQCeHbLUbgRXyM0DlSLyGZqcss3DgB4Muaek6r2ZPFE8AwsIDkFTViDrAJiu6446vdTkaco7QQC+U7lyRp5IR5vv+19xDMXL0XUroN+SCfjI7P31DHzhenEunAlEqpaDc5kU4tWW1W63SDpGq3BZy/Dy3pmB0DLiSCIAidxGh05bptRzs/c121m+Mr5ikso+qPynsdMtJXPAvDMgQksWsEPgVWjglJGVqBV0uThMfJEnEoUEMDaPipIGVs5BndTvBzh7ArJ9OV/kfdanZmrk2WfmYvhHuCgxGAtsrdQcgHgyJ6q08XTjvtVt0FmXHQyHeGq7w1Jn1AXZrtihU6cRTOibrSioIf6BCm4WMwbhNb4WNWxaC2ZvG1kHGmZsmo49BQdheaALaCR8qU+9vQM+eoyQ1S0Jwplx5QqXFADHku+K0H07Kj43493g4q3Qx7zBcYT0uCtpE2jLLibpkrSX1sP5iIOidjCLd/SeEBRltBCFVdFkiczt62HBQSQB2TbY8PFmMZrvg0ie/ZYXsRmXkCSlabNDoe/Jb24X5jRSEuytGW8=----ATTACHMENT:----OTI2MDcwMDAwODkxMDEwNCAzODg4MzI5Njk0MjQzOTAzIDM0OTkzMjAyODc3MDM5MjQ=