Browse Source

[ZF-11837] Zend_Locale
Fixed emit of E_NOTICE from Zend_Locale_Format::checkDateFormat when locale option not specified


git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24518 44c647ce-9c0f-0410-b52a-842ac1e357ba

adamlundrigan 14 years ago
parent
commit
e412478dc8
2 changed files with 13 additions and 1 deletions
  1. 1 1
      library/Zend/Locale/Format.php
  2. 12 0
      tests/Zend/Locale/FormatTest.php

+ 1 - 1
library/Zend/Locale/Format.php

@@ -1137,7 +1137,7 @@ class Zend_Locale_Format
 
         if (empty($options['date_format'])) {
             $options['format_type'] = 'iso';
-            $options['date_format'] = self::getDateFormat($options['locale']);
+            $options['date_format'] = self::getDateFormat(isset($options['locale']) ? $options['locale'] : null);
         }
         $options = self::_checkOptions($options) + self::$_options;
 

+ 12 - 0
tests/Zend/Locale/FormatTest.php

@@ -1093,4 +1093,16 @@ class Zend_Locale_FormatTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('4,00', Zend_Locale_Format::toNumber(3.999, $options));
         $this->assertEquals('4,00', Zend_Locale_Format::toNumber(4, $options));
     }
+    
+    /**
+     * @group ZF-11837
+     */
+    public function testCheckDateFormatDoesNotEmitNoticeWhenNoOptionsAreNotProvided()
+    {
+        try {
+            Zend_Locale_Format::checkDateFormat('2011/10/21', array());
+        } catch ( PHPUnit_Framework_Error_Notice $ex ) {
+            $this->fail('Zend_Locale_Format::checkDateFormat emitted unexpected E_NOTICE');
+        }
+    }
 }