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

Merge r25224 to 1.12 release branch

git-svn-id: http://framework.zend.com/svn/framework/standard/branches/release-1.12@25225 44c647ce-9c0f-0410-b52a-842ac1e357ba
frosch 13 лет назад
Родитель
Сommit
3e86ec4b6e
2 измененных файлов с 20 добавлено и 1 удалено
  1. 1 1
      library/Zend/Form/Element/File.php
  2. 19 0
      tests/Zend/Form/Element/FileTest.php

+ 1 - 1
library/Zend/Form/Element/File.php

@@ -431,7 +431,7 @@ class Zend_Form_Element_File extends Zend_Form_Element_Xhtml
         } else {
             $adapter->setOptions(array('ignoreNoFile' => false), $this->getName());
             if ($this->autoInsertNotEmptyValidator() && !$this->getValidator('NotEmpty')) {
-                $this->addValidator = array('validator' => 'NotEmpty', 'breakChainOnFailure' => true);
+                $this->addValidator('NotEmpty', true);
             }
         }
 

+ 19 - 0
tests/Zend/Form/Element/FileTest.php

@@ -514,6 +514,25 @@ class Zend_Form_Element_FileTest extends PHPUnit_Framework_TestCase
             $test instanceof \Zend\Form\Element\FileTest\Adapter\Bar
         );
     }
+
+    /**
+     * @group ZF-12210
+     */
+    public function testAutoInsertNotEmptyValidator()
+    {
+        $this->testElementShouldAllowSpecifyingAdapterUsingConcreteInstance();
+        $this->element->setRequired(true);
+
+        // Test before validation
+        $this->assertNull($this->element->getValidator('NotEmpty'));
+
+        // Test after validation
+        $this->element->isValid('foo.jpg');
+
+        $this->assertTrue(
+            $this->element->getValidator('NotEmpty') instanceof Zend_Validate_NotEmpty
+        );
+    }
 }
 
 class Zend_Form_Element_FileTest_MockAdapter extends Zend_File_Transfer_Adapter_Abstract