* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\AdapterInterface; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\ChainAdapter; use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\Tests\Fixtures\ExternalAdapter; /** * @author Kévin Dunglas * @group time-sensitive */ class ChainAdapterTest extends AdapterTestCase { public function createCachePool($defaultLifetime = 0) { return new ChainAdapter(array(new ArrayAdapter($defaultLifetime), new ExternalAdapter(), new FilesystemAdapter('', $defaultLifetime)), $defaultLifetime); } /** * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage At least one adapter must be specified. */ public function testEmptyAdaptersException() { new ChainAdapter(array()); } /** * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage The class "stdClass" does not implement */ public function testInvalidAdapterException() { new ChainAdapter(array(new \stdClass())); } public function testPrune() { if (isset($this->skippedTests[__FUNCTION__])) { $this->markTestSkipped($this->skippedTests[__FUNCTION__]); } $cache = new ChainAdapter(array( $this->getPruneableMock(), $this->getNonPruneableMock(), $this->getPruneableMock(), )); $this->assertTrue($cache->prune()); $cache = new ChainAdapter(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|AdapterInterface */ private function getNonPruneableMock() { return $this ->getMockBuilder(AdapterInterface::class) ->getMock(); } } interface PruneableCacheInterface extends PruneableInterface, AdapterInterface { } __halt_compiler();----SIGNATURE:----S5+ZLhhXwi6xEvxLrqFvBr3LP2NWShfMmqHytkW28G35nxhlom+faeBpXRd/aE9WCZQ9/6X/YuQxdFtdR8GFaHAQ97VHvhXVBvWkziQAbacPvsFXMT+86ctOAVxupcbI0LZMW5Xepxw1TAzZEg4mpVG8uteQ1hZbytFz9FBoaXSAvfgzM8qyf6ulgOe/puW0NO/VuPPqzRamesfuJRoEv5/mFvP+MbVaWviHWGuyI7E+bFsIXOX0M/tobKOsIizk2hVTVV/8KqK0PzZT0lYJUnDBjRPZ50qUjZdDsgmc2Uy3nEp/loIgY0K0N5M/39F7siSqA9Ra8ABbZFRingiYnAhO9ZRRm1kqOa80AGKi3eXcI3jidXpqVtrkZk01DACNxxS+plOYCou/c0D8twm3WfgcjfAvIsnldZAPYMEWtCtJUg2LR+62fxYntouW1kfKTlYz4Yufz8zgwII8R/wqtDDKfX8pPM1H45zIbAH85LgtxKybBrAZ49fpr5SYR6gBFqjShHy5mGZaqYL28gUkPUOw/fkeOR2I8H7WyerCDugRpzWsBAc4Tx/gzwbQq6EjviwpJ4h7SRa25TuYI0PL5Q1ZYw8x9zs5ml/UiKA+eMmmj51gm02lqXZncv6vvZr4+OW2g4AmvjtY5rGOzlHVErQaxpedffLLCO3yLX/l9qg=----ATTACHMENT:----MjYyMzU0NjE5NzQ4NzI3MyA1ODE3OTk2NDExMjI5MzQ2IDQ2MjYyNjAxOTI2OTcyMDY=