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

[ZF-6953] Zend_Validate_Identical:

- added support for empty token

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@16289 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas 16 лет назад
Родитель
Сommit
942f150894
2 измененных файлов с 11 добавлено и 2 удалено
  1. 2 2
      library/Zend/Validate/Identical.php
  2. 9 0
      tests/Zend/Validate/IdenticalTest.php

+ 2 - 2
library/Zend/Validate/Identical.php

@@ -100,7 +100,7 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract
      * Returns true if and only if a token has been set and the provided value
      * matches that token.
      *
-     * @param  string $value
+     * @param  mixed $value
      * @return boolean
      */
     public function isValid($value)
@@ -108,7 +108,7 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract
         $this->_setValue($value);
         $token = $this->getToken();
 
-        if (empty($token)) {
+        if ($token === null) {
             $this->_error(self::MISSING_TOKEN);
             return false;
         }

+ 9 - 0
tests/Zend/Validate/IdenticalTest.php

@@ -113,6 +113,15 @@ class Zend_Validate_IdenticalTest extends PHPUnit_Framework_TestCase
         $this->assertContains('bar', $messages['notSame']);
         $this->assertContains('does not match', $messages['notSame']);
     }
+
+    /**
+     * @see ZF-6953
+     */
+    public function testValidatingAgainstEmptyToken()
+    {
+        $this->validator->setToken('');
+        $this->assertTrue($this->validator->isValid(''));
+    }
 }
 
 // Call Zend_Validate_IdenticalTest::main() if this source file is executed directly.