Explorar o código

[ZF-10089] Zend_Log

- fixed stricts

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22513 44c647ce-9c0f-0410-b52a-842ac1e357ba
ramon %!s(int64=15) %!d(string=hai) anos
pai
achega
acb66c2ef7
Modificáronse 2 ficheiros con 23 adicións e 9 borrados
  1. 7 7
      library/Zend/Log/Writer/Db.php
  2. 16 2
      tests/Zend/Log/Writer/DbTest.php

+ 7 - 7
library/Zend/Log/Writer/Db.php

@@ -68,7 +68,7 @@ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract
 
 
     /**
     /**
      * Create a new instance of Zend_Log_Writer_Db
      * Create a new instance of Zend_Log_Writer_Db
-     * 
+     *
      * @param  array|Zend_Config $config
      * @param  array|Zend_Config $config
      * @return Zend_Log_Writer_Db
      * @return Zend_Log_Writer_Db
      * @throws Zend_Log_Exception
      * @throws Zend_Log_Exception
@@ -77,15 +77,15 @@ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract
     {
     {
         $config = self::_parseConfig($config);
         $config = self::_parseConfig($config);
         $config = array_merge(array(
         $config = array_merge(array(
-            'db'        => null, 
-            'table'     => null, 
+            'db'        => null,
+            'table'     => null,
             'columnMap' => null,
             'columnMap' => null,
         ), $config);
         ), $config);
-        
+
         if (isset($config['columnmap'])) {
         if (isset($config['columnmap'])) {
             $config['columnMap'] = $config['columnmap'];
             $config['columnMap'] = $config['columnmap'];
         }
         }
-        
+
         return new self(
         return new self(
             $config['db'],
             $config['db'],
             $config['table'],
             $config['table'],
@@ -96,10 +96,10 @@ class Zend_Log_Writer_Db extends Zend_Log_Writer_Abstract
     /**
     /**
      * Formatting is not possible on this writer
      * Formatting is not possible on this writer
      */
      */
-    public function setFormatter($formatter)
+    public function setFormatter(Zend_Log_Formatter_Interface $formatter)
     {
     {
         require_once 'Zend/Log/Exception.php';
         require_once 'Zend/Log/Exception.php';
-        throw new Zend_Log_Exception(get_class() . ' does not support formatting');
+        throw new Zend_Log_Exception(get_class($this) . ' does not support formatting');
     }
     }
 
 
     /**
     /**

+ 16 - 2
tests/Zend/Log/Writer/DbTest.php

@@ -47,7 +47,8 @@ class Zend_Log_Writer_DbTest extends PHPUnit_Framework_TestCase
     public function testFormattingIsNotSupported()
     public function testFormattingIsNotSupported()
     {
     {
         try {
         try {
-            $this->writer->setFormatter(new stdclass);
+            require_once 'Zend/Log/Formatter/Simple.php';
+            $this->writer->setFormatter(new Zend_Log_Formatter_Simple());
             $this->fail();
             $this->fail();
         } catch (Exception $e) {
         } catch (Exception $e) {
             $this->assertType('Zend_Log_Exception', $e);
             $this->assertType('Zend_Log_Exception', $e);
@@ -109,7 +110,7 @@ class Zend_Log_Writer_DbTest extends PHPUnit_Framework_TestCase
             $this->assertEquals('Database adapter is null', $e->getMessage());
             $this->assertEquals('Database adapter is null', $e->getMessage());
         }
         }
     }
     }
-    
+
     public function testFactory()
     public function testFactory()
     {
     {
         $cfg = array('log' => array('memory' => array(
         $cfg = array('log' => array('memory' => array(
@@ -123,6 +124,19 @@ class Zend_Log_Writer_DbTest extends PHPUnit_Framework_TestCase
         $logger = Zend_Log::factory($cfg['log']);
         $logger = Zend_Log::factory($cfg['log']);
         $this->assertTrue($logger instanceof Zend_Log);
         $this->assertTrue($logger instanceof Zend_Log);
     }
     }
+
+    /**
+     * @group ZF-10089
+     */
+    public function testThrowStrictSetFormatter()
+    {
+        try {
+            $this->writer->setFormatter(new StdClass());
+        } catch (Exception $e) {
+            $this->assertType('PHPUnit_Framework_Error', $e);
+            $this->assertContains('must implement interface', $e->getMessage());
+        }
+    }
 }
 }