Don't require a logger in Horde_Db_Migrator.
authorJan Schneider <jan@horde.org>
Thu, 6 May 2010 09:48:59 +0000 (11:48 +0200)
committerJan Schneider <jan@horde.org>
Thu, 6 May 2010 15:51:09 +0000 (17:51 +0200)
framework/Alarm/test/Horde/Alarm/SqlTest.php
framework/Db/lib/Horde/Db/Migration/Migrator.php

index ca493d5..dfe048c 100644 (file)
@@ -42,8 +42,7 @@ class Horde_Alarm_SqlTest extends PHPUnit_Framework_TestCase
         $class = 'Horde_Db_Adapter_' . $adapter;
         self::$db = new $class($conf['alarm']['test']['horde']);
 
-        $logger = new Horde_Log_Logger(new Horde_Log_Handler_Null());
-        self::$migrator = new Horde_Db_Migration_Migrator(self::$db, $logger, array('migrationsPath' => dirname(dirname(dirname(dirname(__FILE__)))) . '/migrations'));
+        self::$migrator = new Horde_Db_Migration_Migrator(self::$db, null, array('migrationsPath' => dirname(dirname(dirname(dirname(__FILE__)))) . '/migrations'));
         self::$migrator->up();
     }
 
index 6dc1339..3be67fa 100644 (file)
@@ -43,29 +43,32 @@ class Horde_Db_Migration_Migrator
      */
     protected $_schemaTableName = 'schema_info';
 
-
-    /*##########################################################################
-    # Constructor
-    ##########################################################################*/
-
     /**
+     * Constructor.
+     *
      * @param   string  $direction
      * @param   string  $migrationsPath
      * @param   integer $targetVersion
      */
-    public function __construct(Horde_Db_Adapter_Base $connection, Horde_Log_Logger $logger, $options = array())
+    public function __construct(Horde_Db_Adapter_Base $connection,
+                                Horde_Log_Logger $logger = null,
+                                array $options = array())
     {
         if (!$connection->supportsMigrations()) {
             $msg = 'This database does not yet support migrations';
             throw new Horde_Db_Migration_Exception($msg);
         }
 
-        $this->_connection     = $connection;
-        $this->_logger         = $logger;
-        $this->_inflector      = new Horde_Support_Inflector();
+        $this->_connection = $connection;
+        $this->_logger     = $logger ? $logger : new Horde_Support_Stub();
+        $this->_inflector  = new Horde_Support_Inflector();
 
-        if (isset($options['migrationsPath'])) { $this->_migrationsPath = $options['migrationsPath']; }
-        if (isset($options['schemaTableName'])) { $this->_schemaTableName = $options['schemaTableName']; }
+        if (isset($options['migrationsPath'])) {
+            $this->_migrationsPath = $options['migrationsPath'];
+        }
+        if (isset($options['schemaTableName'])) {
+            $this->_schemaTableName = $options['schemaTableName'];
+        }
 
         $this->_initializeSchemaInformation();
     }