* * 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\FilesystemAdapter; use Symfony\Component\Cache\Adapter\TraceableAdapter; /** * @group time-sensitive */ class TraceableAdapterTest extends AdapterTestCase { protected $skippedTests = array( 'testPrune' => 'TraceableAdapter just proxies', ); public function createCachePool($defaultLifetime = 0) { return new TraceableAdapter(new FilesystemAdapter('', $defaultLifetime)); } public function testGetItemMissTrace() { $pool = $this->createCachePool(); $pool->getItem('k'); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('getItem', $call->name); $this->assertSame(array('k' => false), $call->result); $this->assertSame(0, $call->hits); $this->assertSame(1, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testGetItemHitTrace() { $pool = $this->createCachePool(); $item = $pool->getItem('k')->set('foo'); $pool->save($item); $pool->getItem('k'); $calls = $pool->getCalls(); $this->assertCount(3, $calls); $call = $calls[2]; $this->assertSame(1, $call->hits); $this->assertSame(0, $call->misses); } public function testGetItemsMissTrace() { $pool = $this->createCachePool(); $arg = array('k0', 'k1'); $items = $pool->getItems($arg); foreach ($items as $item) { } $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('getItems', $call->name); $this->assertSame(array('k0' => false, 'k1' => false), $call->result); $this->assertSame(2, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testHasItemMissTrace() { $pool = $this->createCachePool(); $pool->hasItem('k'); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('hasItem', $call->name); $this->assertSame(array('k' => false), $call->result); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testHasItemHitTrace() { $pool = $this->createCachePool(); $item = $pool->getItem('k')->set('foo'); $pool->save($item); $pool->hasItem('k'); $calls = $pool->getCalls(); $this->assertCount(3, $calls); $call = $calls[2]; $this->assertSame('hasItem', $call->name); $this->assertSame(array('k' => true), $call->result); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testDeleteItemTrace() { $pool = $this->createCachePool(); $pool->deleteItem('k'); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('deleteItem', $call->name); $this->assertSame(array('k' => true), $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testDeleteItemsTrace() { $pool = $this->createCachePool(); $arg = array('k0', 'k1'); $pool->deleteItems($arg); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('deleteItems', $call->name); $this->assertSame(array('keys' => $arg, 'result' => true), $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testSaveTrace() { $pool = $this->createCachePool(); $item = $pool->getItem('k')->set('foo'); $pool->save($item); $calls = $pool->getCalls(); $this->assertCount(2, $calls); $call = $calls[1]; $this->assertSame('save', $call->name); $this->assertSame(array('k' => true), $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testSaveDeferredTrace() { $pool = $this->createCachePool(); $item = $pool->getItem('k')->set('foo'); $pool->saveDeferred($item); $calls = $pool->getCalls(); $this->assertCount(2, $calls); $call = $calls[1]; $this->assertSame('saveDeferred', $call->name); $this->assertSame(array('k' => true), $call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } public function testCommitTrace() { $pool = $this->createCachePool(); $pool->commit(); $calls = $pool->getCalls(); $this->assertCount(1, $calls); $call = $calls[0]; $this->assertSame('commit', $call->name); $this->assertTrue($call->result); $this->assertSame(0, $call->hits); $this->assertSame(0, $call->misses); $this->assertNotEmpty($call->start); $this->assertNotEmpty($call->end); } } __halt_compiler();----SIGNATURE:----ca2YiHhiaWoxcw2j6zIfjpRPdeGHyT5sYWLJtC+5rG2mc3HdqJcDklDQDOhUsZB02zut9mJWo5trMrNN5aHQ8vbuWsurEg1zmvpxEEc2QoxKU/F3ntUtveZJaFMtWaG3fSDeMpDdmu9DMv+jVb+dOsk+ipQ3/B8R/ynkS4xqSBU+U5QZSJbqcGHF9Fdx8agzwKGjV8rCJJpEF81VONjkr0UFGPPcj8mmNg7p888k68138C5ykeDHLTmeVRW9f49MDwAVbW/BUCsYB4oaggoAXYbg6+hbDAkF3i55wFBbB4CTuwMfkMkSpeSz5Ti02OI6jGUvMiqTn9kI5dbiaqyTbgvd3XdyaAi6v7zz4YCjCCSIPNnMDIJ7zjnkHQtd0ZOEtyKjpwsix/6+6YwgQYKu9WU624n/JwA7pQMLuLfopgt4j3ZLnFeIsekKZCWx8Agwnky8ItsvzpN0/Vqm2RPWZrDqCy9K5CJBI0XD19rwSTDr2S2Oe5UxV79WXsFKdDl05nOuutjoSeH5goja18/P3vRAyeca1Um274/NI/P2dtB85KcMpAVFzV7ZBoG7xFyrs/+oJlyQWi7gkStAxFeEdf/+vUTpn/Umzut96UY6ehwPpZ/XJLyeMNxGOB+RXTGc14G+Mj/tmmMUewwAPy/qwb2WYQITw6ea2BHNf2GVh6U=----ATTACHMENT:----MTIzODg1ODkzNTQwMjM2MSA3MTgwMzY4NzU0MTEwMDkzIDkyNzAyMTkzNDEzOTA0MjU=