فهرست منبع

Merge r25200 to 1.12 release branch

git-svn-id: http://framework.zend.com/svn/framework/standard/branches/release-1.12@25201 44c647ce-9c0f-0410-b52a-842ac1e357ba
frosch 13 سال پیش
والد
کامیت
2f94be36aa
2فایلهای تغییر یافته به همراه27 افزوده شده و 7 حذف شده
  1. 11 0
      library/Zend/Form.php
  2. 16 7
      tests/Zend/Form/FormTest.php

+ 11 - 0
library/Zend/Form.php

@@ -2469,10 +2469,21 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
     /**
      * Are there errors in the form?
      *
+     * @deprecated since 1.11.1 - use hasErrors() instead
      * @return bool
      */
     public function isErrors()
     {
+        return $this->hasErrors();
+    }
+
+    /**
+     * Are there errors in the form?
+     *
+     * @return bool
+     */
+    public function hasErrors()
+    {
         return $this->_errorsExist;
     }
 

+ 16 - 7
tests/Zend/Form/FormTest.php

@@ -2492,9 +2492,18 @@ class Zend_Form_FormTest extends PHPUnit_Framework_TestCase
 
     public function testCanCheckIfErrorsAreRegistered()
     {
-        $this->assertFalse($this->form->isErrors());
+        $this->assertFalse($this->form->hasErrors());
         $this->testCanValidateFullFormContainingOnlyElements();
-        $this->assertTrue($this->form->isErrors());
+        $this->assertTrue($this->form->hasErrors());
+    }
+
+    /**
+     * @group ZF-9914
+     */
+    public function testDeprecatedIsErrorsProxiesToHasErrors()
+    {
+        $this->testCanValidateFullFormContainingOnlyElements();
+        $this->assertEquals($this->form->isErrors(), $this->form->hasErrors());
     }
 
     public function testCanRetrieveErrorCodesFromAllElementsAfterFailedValidation()
@@ -2887,9 +2896,9 @@ class Zend_Form_FormTest extends PHPUnit_Framework_TestCase
     public function testShouldAllowMarkingFormAsInvalid()
     {
         $this->form->addErrorMessage('Invalid values entered');
-        $this->assertFalse($this->form->isErrors());
+        $this->assertFalse($this->form->hasErrors());
         $this->form->markAsError();
-        $this->assertTrue($this->form->isErrors());
+        $this->assertTrue($this->form->hasErrors());
         $messages = $this->form->getMessages();
         $this->assertEquals(1, count($messages));
         $this->assertEquals('Invalid values entered', array_shift($messages));
@@ -2897,11 +2906,11 @@ class Zend_Form_FormTest extends PHPUnit_Framework_TestCase
 
     public function testShouldAllowPushingErrorsOntoErrorStackWithErrorMessages()
     {
-        $this->assertFalse($this->form->isErrors());
+        $this->assertFalse($this->form->hasErrors());
         $this->form->setErrors(array('Error 1', 'Error 2'))
                    ->addError('Error 3')
                    ->addErrors(array('Error 4', 'Error 5'));
-        $this->assertTrue($this->form->isErrors());
+        $this->assertTrue($this->form->hasErrors());
         $messages = $this->form->getMessages();
         $this->assertEquals(5, count($messages));
         foreach (range(1, 5) as $id) {
@@ -4615,7 +4624,7 @@ class Zend_Form_FormTest extends PHPUnit_Framework_TestCase
     public function testExceptionThrownWhenAddElementsIsGivenNullValue()
     {
         $form = new Zend_Form();
-        $form->addElement(NULL);
+        $form->addElement(null);
     }
 
     /**