X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdoctrine%2Fcache%2Ftests%2FDoctrine%2FTests%2FCommon%2FCache%2FCacheProviderTest.php;fp=vendor%2Fdoctrine%2Fcache%2Ftests%2FDoctrine%2FTests%2FCommon%2FCache%2FCacheProviderTest.php;h=5e11652cc59bee347af478ceb20df48991be3648;hp=0000000000000000000000000000000000000000;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/CacheProviderTest.php b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/CacheProviderTest.php new file mode 100644 index 000000000..5e11652cc --- /dev/null +++ b/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/CacheProviderTest.php @@ -0,0 +1,103 @@ +getMockForAbstractClass( + 'Doctrine\Common\Cache\CacheProvider', + array(), + '', + true, + true, + true, + array('doFetchMultiple') + ); + + $cache + ->expects($this->once()) + ->method('doFetchMultiple') + ->will($this->returnValue(array( + '[foo][1]' => 'bar', + '[bar][1]' => 'baz', + '[baz][1]' => 'tab', + ))); + + $this->assertEquals( + array('foo' => 'bar', 'bar' => 'baz'), + $cache->fetchMultiple(array('foo', 'bar')) + ); + } + + public function testFailedDeleteAllDoesNotChangeNamespaceVersion() + { + /* @var $cache \Doctrine\Common\Cache\CacheProvider|\PHPUnit_Framework_MockObject_MockObject */ + $cache = $this->getMockForAbstractClass( + 'Doctrine\Common\Cache\CacheProvider', + array(), + '', + true, + true, + true, + array('doFetch', 'doSave', 'doContains') + ); + + $cache + ->expects($this->once()) + ->method('doFetch') + ->with('DoctrineNamespaceCacheKey[]') + ->will($this->returnValue(false)); + + // doSave is only called once from deleteAll as we do not need to persist the default version in getNamespaceVersion() + $cache + ->expects($this->once()) + ->method('doSave') + ->with('DoctrineNamespaceCacheKey[]') + ->will($this->returnValue(false)); + + // After a failed deleteAll() the local namespace version is not increased (still 1). Otherwise all data written afterwards + // would be lost outside the current instance. + $cache + ->expects($this->once()) + ->method('doContains') + ->with('[key][1]') + ->will($this->returnValue(true)); + + $this->assertFalse($cache->deleteAll(), 'deleteAll() returns false when saving the namespace version fails'); + $cache->contains('key'); + } + + public function testSaveMultipleNoFail() + { + /* @var $cache \Doctrine\Common\Cache\CacheProvider|\PHPUnit_Framework_MockObject_MockObject */ + $cache = $this->getMockForAbstractClass( + 'Doctrine\Common\Cache\CacheProvider', + array(), + '', + true, + true, + true, + array('doSave') + ); + + $cache + ->expects($this->at(1)) + ->method('doSave') + ->with('[kerr][1]', 'verr', 0) + ->will($this->returnValue(false)); + + $cache + ->expects($this->at(2)) + ->method('doSave') + ->with('[kok][1]', 'vok', 0) + ->will($this->returnValue(true)); + + $cache->saveMultiple(array( + 'kerr' => 'verr', + 'kok' => 'vok', + )); + } +}