Просмотр исходного кода

[ZF-10793] Zend_View

- Fixed allow set value to class of container.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23544 44c647ce-9c0f-0410-b52a-842ac1e357ba
ramon 15 лет назад
Родитель
Сommit
1d37407483

+ 1 - 1
library/Zend/View/Helper/Placeholder/Registry.php

@@ -85,7 +85,7 @@ class Zend_View_Helper_Placeholder_Registry
     {
         $key = (string) $key;
 
-        $this->_items[$key] = new $this->_containerClass(array());
+        $this->_items[$key] = new $this->_containerClass($value);
         return $this->_items[$key];
     }
 

+ 19 - 0
tests/Zend/View/Helper/Placeholder/RegistryTest.php

@@ -207,10 +207,29 @@ class Zend_View_Helper_Placeholder_RegistryTest extends PHPUnit_Framework_TestCa
         $registered = Zend_Registry::get(Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY);
         $this->assertSame($registry, $registered);
     }
+
+    /**
+     * @group ZF-10793
+     */
+    public function testSetValueCreateContainer()
+    {
+        $this->registry->setContainerClass('Zend_View_Helper_Placeholder_RegistryTest_Container');
+        $data = array(
+            'ZF-10793'
+        );
+        $container = $this->registry->createContainer('foo', $data);
+        $this->assertEquals(array('ZF-10793'), $container->data);
+    }
 }
 
 class Zend_View_Helper_Placeholder_RegistryTest_Container extends Zend_View_Helper_Placeholder_Container_Abstract
 {
+    public $data = array();
+
+    public function __construct($data)
+    {
+        $this->data = $data;
+    }
 }
 
 class Zend_View_Helper_Placeholder_RegistryTest_BogusContainer