Sfoglia il codice sorgente

ZF-8602: better detection of log priority values

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20245 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew 16 anni fa
parent
commit
adefecfd98

+ 2 - 2
library/Zend/Log/Filter/Priority.php

@@ -78,12 +78,12 @@ class Zend_Log_Filter_Priority extends Zend_Log_Filter_Abstract
         ), $config);
 
         // Add support for constants
-        if (is_string($config['priority'])) {
+        if (!is_numeric($config['priority'])) {
             $config['priority'] = constant($config['priority']);
         }
 
         return new self(
-            $config['priority'], 
+            (int) $config['priority'], 
             $config['operator']
         );
     }

+ 18 - 7
tests/Zend/Application/Resource/LogTest.php

@@ -128,13 +128,24 @@ class Zend_Application_Resource_LogTest extends PHPUnit_Framework_TestCase
         $this->assertContains($message, stream_get_contents($stream));
     }
     
-public function testNumericLogStreamFilterParamsPriorityDoesNotFail() {
-        $options = array('stream' =>
-                        array('writerName'   => 'Stream',
-                              'writerParams' => array('stream' => "php://memory",
-                                                      'mode' => 'a'),
-                        'filterName' => 'Priority',
-                        'filterParams' => array('priority' => '4')));
+    /**
+     * @group ZF-8602
+     */
+    public function testNumericLogStreamFilterParamsPriorityDoesNotFail()
+    {
+        $options = array(
+            'stream' => array(
+                'writerName'   => 'Stream',
+                'writerParams' => array(
+                    'stream' => "php://memory",
+                    'mode'   => 'a'
+                ),
+                'filterName' => 'Priority',
+                'filterParams' => array(
+                    'priority' => '4'
+                ),
+            ),
+        );
         $resource = new Zend_Application_Resource_Log($options);
         $resource->setBootstrap($this->bootstrap);
         $resource->init();