|
|
@@ -29,6 +29,7 @@ require_once 'Zend/Form/Decorator/File.php';
|
|
|
|
|
|
require_once 'Zend/Form/Element/File.php';
|
|
|
require_once 'Zend/View.php';
|
|
|
+require_once 'Zend/View/Helper/FormElement.php';
|
|
|
|
|
|
/**
|
|
|
* Test class for Zend_Form_Decorator_Errors
|
|
|
@@ -169,6 +170,26 @@ class Zend_Form_Decorator_FileTest extends PHPUnit_Framework_TestCase
|
|
|
$file = $this->decorator->render('content');
|
|
|
$this->assertRegexp('#<input[^>]*>.*?(content)#s', $file, $file);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @group ZF-10519
|
|
|
+ */
|
|
|
+ public function testCanChangeViewHelper()
|
|
|
+ {
|
|
|
+ $element = new Zend_Form_Element_File('foo');
|
|
|
+ $element->setView($this->getView());
|
|
|
+
|
|
|
+ // Get output using default view helper
|
|
|
+ $defaultOutput = $element->render();
|
|
|
+
|
|
|
+ // Get output using mock view helper
|
|
|
+ $element->helper = "formFileMock";
|
|
|
+ $mockOutput = $element->render();
|
|
|
+
|
|
|
+ // Ensure the view helper was changed
|
|
|
+ $this->assertRegexp('/FormFileMock/s', $mockOutput);
|
|
|
+ $this->assertNotEquals($defaultOutput, $mockOutput);
|
|
|
+ }
|
|
|
|
|
|
private function _convertIniToInteger($setting)
|
|
|
{
|
|
|
@@ -194,6 +215,14 @@ class Zend_Form_Decorator_FileTest extends PHPUnit_Framework_TestCase
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+class Zend_View_Helper_FormFileMock extends Zend_View_Helper_FormElement
|
|
|
+{
|
|
|
+ public function formFileMock($name, $attribs=NULL)
|
|
|
+ {
|
|
|
+ return "FormFileMock";
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// Call Zend_Form_Decorator_FileTest::main() if this source file is executed directly.
|
|
|
if (PHPUnit_MAIN_METHOD == "Zend_Form_Decorator_FileTest::main") {
|
|
|
Zend_Form_Decorator_FileTest::main();
|