* * 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 Psr\Cache\CacheItemInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\ProxyAdapter; use Symfony\Component\Cache\CacheItem; /** * @group time-sensitive */ class ProxyAdapterTest extends AdapterTestCase { protected $skippedTests = array( 'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayAdapter is not.', 'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.', 'testPrune' => 'ProxyAdapter just proxies', ); public function createCachePool($defaultLifetime = 0) { return new ProxyAdapter(new ArrayAdapter(), '', $defaultLifetime); } /** * @expectedException \Exception * @expectedExceptionMessage OK bar */ public function testProxyfiedItem() { $item = new CacheItem(); $pool = new ProxyAdapter(new TestingArrayAdapter($item)); $proxyItem = $pool->getItem('foo'); $this->assertNotSame($item, $proxyItem); $pool->save($proxyItem->set('bar')); } } class TestingArrayAdapter extends ArrayAdapter { private $item; public function __construct(CacheItemInterface $item) { $this->item = $item; } public function getItem($key) { return $this->item; } public function save(CacheItemInterface $item) { if ($item === $this->item) { throw new \Exception('OK '.$item->get()); } } } __halt_compiler();----SIGNATURE:----lGa7KjeVj9YjYlY6dNw+6W4kFB1P/Po3hLSDJuNAI0LRcVABOnJ8ua/prRXipmuXEZlMMj55I52Lj9bHWsrxwLU0hEltqLRkBrm3atURG5kiCXDe93fjgCLBM07LkBPnh5xjTSekO3elwBv/KPqTfltRcuG/QrOv6PzjknIfDWxsHSjHFAAw6H045TrzUyLaPSzKizV+W+3ySUc3gORoilMavj1YrfHUIlNC17Mq0FvhvMZFqU9eueFab69TcT/CEJzsAm/1qnRq/6eqSVQvurQ6kSjV2c5dl+SUKQG1OD1AgTkGSvAa5ZTH5LAqKuoQeK1WDmxVn4B5qHHqcXcgZ8Cc8Qx6bNU2l9WNWVJOjhlQ8JXGKdLrtgvzysyyWwPMDEGMBSBYTb0gogVHe9Q3V6nouM0LCYjB/b9wEdY9BoASNPGplNuRGSXZzi/lm0HkCmwVWSusR/awuuLb1vChyA5Wi2mA9W8dZOa/nM4eOUSNE1Os6ux1qHUvbr8rTDiRFqAOp1JrjjxDAQD1sOX4YnIaEC8HOkh+X3bkjjiBYgDQEolLsOK68V650FTEErMSbsDuLZdT8Kj+Eq90EXAqpt03pGJhTmwZ5G6U18O4eZcnirWQxSSaC7Ai/5XEysAckYuBCIbnQN2WKbnP0AhqR+iwHQwevd9Ih7QBB2Dl74E=----ATTACHMENT:----OTk2MjA5MDMwODIxNjIzNCA1MzQwNjUwNDQyNDc4ODIwIDkxODI1OTMxMTcwMjAxOTk=