|
|
@@ -150,6 +150,55 @@ class Zend_Controller_Action_Helper_CacheTest extends PHPUnit_Framework_TestCase
|
|
|
$this->assertNotEquals('verified', $cache->res);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @group ZF-11885
|
|
|
+ * @dataProvider dataprovider_testEncodedCacheIdsAreUsedConsistently
|
|
|
+ */
|
|
|
+ public function testEncodedCacheIdsAreUsedConsistently($recursive)
|
|
|
+ {
|
|
|
+ $helper = new Zend_Controller_Action_Helper_Cache();
|
|
|
+ $cache = new Mock_Zend_Cache_Page_TestingEncodedCacheId();
|
|
|
+ $helper->setCache('page', $cache);
|
|
|
+ $helper->direct(array('baz'));
|
|
|
+ $helper->preDispatch();
|
|
|
+ $uriKey = bin2hex($this->request->getRequestUri());
|
|
|
+
|
|
|
+ // Ensure that start method encodes key properly
|
|
|
+ $this->assertTrue(isset($cache->items[$uriKey]));
|
|
|
+
|
|
|
+ // Ensure that remove method encodes key properly
|
|
|
+ $helper->removePage($this->request->getRequestUri(), $recursive);
|
|
|
+ $this->assertFalse(isset($cache->items[$uriKey]));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @group ZF-11885
|
|
|
+ * @dataProvider dataprovider_testEncodedCacheIdsAreUsedConsistently
|
|
|
+ */
|
|
|
+ public function testRemovePageAcceptsPreEncodedCacheIds($recursive)
|
|
|
+ {
|
|
|
+ $helper = new Zend_Controller_Action_Helper_Cache();
|
|
|
+ $cache = new Mock_Zend_Cache_Page_TestingEncodedCacheId();
|
|
|
+ $helper->setCache('page', $cache);
|
|
|
+ $helper->direct(array('baz'));
|
|
|
+ $helper->preDispatch();
|
|
|
+ $uriKey = bin2hex($this->request->getRequestUri());
|
|
|
+
|
|
|
+ // Ensure that remove method will accept pre-encoded key
|
|
|
+ $helper->removePage($uriKey, $recursive);
|
|
|
+ $this->assertFalse(isset($cache->items[$uriKey]));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Data provider for testEncodedCacheIdsAreUsedConsistently
|
|
|
+ * @see ZF-11885
|
|
|
+ */
|
|
|
+ public function dataprovider_testEncodedCacheIdsAreUsedConsistently()
|
|
|
+ {
|
|
|
+ return array(array(true),array(false));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**public function testPostDispatchEndsOutputBufferPageCaching()
|
|
|
{
|
|
|
$helper = new Zend_Controller_Action_Helper_Cache;
|
|
|
@@ -178,14 +227,14 @@ class Mock_Zend_Cache_Page_1 extends Zend_Cache_Core
|
|
|
{
|
|
|
public function remove($id)
|
|
|
{
|
|
|
- if ($id == '/foo') {return 'verified';}
|
|
|
+ if ($id == bin2hex('/foo')) {return 'verified';}
|
|
|
}
|
|
|
}
|
|
|
class Mock_Zend_Cache_Page_2 extends Zend_Cache_Backend
|
|
|
{
|
|
|
public function removeRecursively($id)
|
|
|
{
|
|
|
- if ($id == '/foo') {return 'verified';}
|
|
|
+ if ($id == bin2hex('/foo')) {return 'verified';}
|
|
|
}
|
|
|
}
|
|
|
class Mock_Zend_Cache_Page_3 extends Zend_Cache_Core
|
|
|
@@ -221,6 +270,21 @@ class Mock_Zend_Cache_Page_6 extends Zend_Cache_Core
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+class Mock_Zend_Cache_Page_TestingEncodedCacheId extends Zend_Cache_Core
|
|
|
+{
|
|
|
+ public $items;
|
|
|
+
|
|
|
+ public function start($id, array $tags = array())
|
|
|
+ {
|
|
|
+ $this->items[$id] = $tags;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function remove($id)
|
|
|
+ {
|
|
|
+ unset($this->items[$id]);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/**class Mock_Zend_Cache_Page_5 extends Zend_Cache_Core
|
|
|
{
|
|
|
public $res;
|