Issue Type: Bug Created: 2012-03-22T14:54:46.000+0000 Last Updated: 2013-01-22T08:16:58.000+0000 Status: Closed Fix version(s): Reporter: bullfrogblues (gerardroche) Assignee: Frank Brückner (frosch) Tags: - Zend_Form
Related issues: - ZF-12210
Attachments:
Zend_Form_Element_File is leaking configurations into form element markup. An example will better illustrate:
Expected markup:
<pre class="highlight">
Actual markup:
To reproduce the actual markup above:
Form file element must be required
form need to be processed through isValid()
class Bug_Form_FileRequriedComponentMarkupLeak { public function init() { $this->addElement('file', 'uploadElement', array( 'label' => 'Label text', 'required' => true )); // ... } } $form = new Bug_Form_FileRequriedComponentMarkupLeak(); if ($form->isValid($_POST) { echo $form; // e.g. from view script }
Posted by Frank Brückner (frosch) on 2013-01-17T16:10:06.000+0000
I can not reproduce the problem.
Here is an unit test:
<pre class="highlight">
/**
* @group ZF-12116
*/
public function testRenderingAfterSubmit()
{
$this->element->setRequired(true);
$this->element->setDecorators(array('File'));
$this->element->setMaxFileSize(0);
$this->element->isValid('foo.jpg');
$this->assertEquals(
'',
trim($this->element->render(new Zend_View()))
);
}
Result: OK
Posted by bullfrogblues (gerardroche) on 2013-01-21T18:17:45.000+0000
I ran that test and it failed!
<pre class="highlight">
PHPUnit 3.5.15 by Sebastian Bergmann.
FF
Time: 1 second, Memory: 6.75Mb
There were 2 failures:
1) Warning
No tests found in class "IndexControllerTest".
2) formTest::testRenderingAfterSubmit
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-
+
/path/to/bug-ZF-12116/tests/application/forms/formTest.php:20
FAILURES!
Tests: 2, Assertions: 1, Failures: 2.
ZF Version: 1.12.1
Posted by Frank Brückner (frosch) on 2013-01-21T18:27:40.000+0000
Hi Gerard, thanks for your feedback. I ran the test on the current trunk, but I will check this again.
Thanks for your help!
Posted by bullfrogblues (gerardroche) on 2013-01-21T18:31:48.000+0000
No worries, maybe something was fixed in trunk.
Here's how I tested, it might help.
<pre class="highlight">
$ mkdir bug-zf-12116
$ cd bug-zf-12116
$ zf create project .
Creating project at /path/to/bug-zf-12116
Note: This command created a web project, for more information setting up your VHOST, please see docs/README
Testing Note: PHPUnit was not found in your include_path, therefore no testing actions will be created.
$ phpunit -c tests/phpunit.xml
PHPUnit 3.5.15 by Sebastian Bergmann.
F
Time: 0 seconds, Memory: 4.25Mb
There was 1 failure:
1) Warning
No tests found in class "IndexControllerTest".
FAILURES!
Tests: 1, Assertions: 0, Failures: 1.
$ mkdir tests/application/forms
$ vi tests/application/forms/fileElementTest.php
<?php
class fileElementTest extends PHPUnit_Framework_TestCase
{
public function testRenderingAfterSubmit()
{
$element = new Zend_Form_Element_File('foo');
$element->setRequired(true);
$element->setDecorators(array('File'));
$element->setMaxFileSize(0);
$element->isValid('foo.jpg');
$this->assertEquals(
'',
trim($element->render(new Zend_View()))
);
}
}
$ phpunit -c tests/phpunit.xml
PHPUnit 3.5.15 by Sebastian Bergmann.
FF
Time: 0 seconds, Memory: 6.75Mb
There were 2 failures:
1) Warning
No tests found in class "IndexControllerTest".
2) fileElementTest::testRenderingAfterSubmit
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-
+
/path/to/bug-zf-12116/tests/application/forms/fileElementTest.php:17
FAILURES!
Tests: 2, Assertions: 1, Failures: 2.
Posted by Frank Brückner (frosch) on 2013-01-22T08:16:58.000+0000
Yes, it was fixed with: ZF-12210