Ver Fonte

[ZF-9956] Zend_Log:

- resolved variable $filterName undeclared.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22526 44c647ce-9c0f-0410-b52a-842ac1e357ba
ramon há 15 anos atrás
pai
commit
c34a7cc162
2 ficheiros alterados com 25 adições e 0 exclusões
  1. 3 0
      library/Zend/Log.php
  2. 22 0
      tests/Zend/Log/LogTest.php

+ 3 - 0
library/Zend/Log.php

@@ -180,6 +180,9 @@ class Zend_Log
         $filter = $this->_constructFromConfig('filter', $config, $this->_defaultFilterNamespace);
 
         if (!$filter instanceof Zend_Log_Filter_Interface) {
+             $filterName = is_object($filter)
+                         ? get_class($filter)
+                         : 'The specified filter';
             /** @see Zend_Log_Exception */
             require_once 'Zend/Log/Exception.php';
             throw new Zend_Log_Exception("{$filterName} does not implement Zend_Log_Filter_Interface");

+ 22 - 0
tests/Zend/Log/LogTest.php

@@ -385,6 +385,21 @@ class Zend_Log_LogTest extends PHPUnit_Framework_TestCase
             $this->assertRegExp('#^(Zend_Log_Writer_NotExtendedWriterAbstract|The\sspecified\swriter)#', $e->getMessage());
         }
     }
+
+    /**
+     * @group ZF-9956
+     */
+    public function testExceptionConstructFilterFromConfig()
+    {
+        try {
+            $logger = new Zend_Log();
+            $filter = array('filterName' => 'NotImplementsFilterInterface');
+            $logger->addFilter($filter);
+        } catch (Exception $e) {
+            $this->assertType('Zend_Log_Exception', $e);
+            $this->assertRegExp('#^(Zend_Log_Filter_NotImplementsFilterInterface|The\sspecified\sfilter)#', $e->getMessage());
+        }
+    }
 }
 
 class Zend_Log_Writer_NotExtendedWriterAbstract implements Zend_Log_FactoryInterface
@@ -393,3 +408,10 @@ class Zend_Log_Writer_NotExtendedWriterAbstract implements Zend_Log_FactoryInter
     {
     }
 }
+
+class Zend_Log_Filter_NotImplementsFilterInterface implements Zend_Log_FactoryInterface
+{
+    public static function factory($config)
+    {
+    }
+}