Author: Mike Naberezny (mike@maintainable.com)
Author: Derek DeVries (derek@maintainable.com)
Author: Chuck Hagenbuch (chuck@horde.org)
Example #1
0
 public static function setUpBeforeClass()
 {
     self::$callback = array(__CLASS__, 'getDb');
     parent::setUpBeforeClass();
     $migrator = new Horde_Db_Migration_Migrator($GLOBALS['injector']->getInstance('Horde_Db_Adapter'), null, array('migrationsPath' => __DIR__ . '/../../../../../../migration', 'schemaTableName' => 'kronolith_test_schema'));
     $migrator->up();
 }
Example #2
0
 public static function setUpBeforeClass()
 {
     self::$callback = array(__CLASS__, 'getDb');
     parent::setUpBeforeClass();
     $migrator = new Horde_Db_Migration_Migrator($GLOBALS['injector']->getInstance('Horde_Db_Adapter'), null, array('migrationsPath' => __DIR__ . '/../../../../../../migration', 'schemaTableName' => 'kronolith_test_schema'));
     $migrator->up();
     list($share, $other_share) = self::_createDefaultShares();
     self::$driver = Kronolith::getDriver('Sql', $share->getName());
     self::$type = 'Sql';
 }
Example #3
0
 /**
  * Create a connector to an in-memory sqlite DB.
  *
  * @param array $params Additional options.
  * <pre>
  * 'migrations' - (array) An list of migrations that should be run.
  *                Each element must contain the keys 'migrationsPath'
  *                and 'schemaTableName'.
  *                DEFAULT: empty
  * </pre>
  *
  * @return Horde_Db_Adapter_Pdo_Sqlite The DB adapter.
  */
 public function create($params = array())
 {
     if (!extension_loaded('pdo') || !in_array('sqlite', PDO::getAvailableDrivers())) {
         throw new Horde_Test_Exception('No sqlite extension or no sqlite PDO driver');
     }
     if (!class_exists('Horde_Db_Adapter_Pdo_Sqlite')) {
         throw new Horde_Test_Exception('The "Horde_Db_Adapter_Pdo_Sqlite" class is unavailable!');
     }
     $db = new Horde_Db_Adapter_Pdo_Sqlite(array('dbname' => ':memory:', 'charset' => 'utf-8'));
     if (isset($params['migrations'])) {
         if (isset($params['migrations']['migrationsPath'])) {
             $migrations = array($params['migrations']);
         } else {
             $migrations = $params['migrations'];
         }
         foreach ($migrations as $migration) {
             $migrator = new Horde_Db_Migration_Migrator($db, null, $migration);
             $migrator->up();
         }
     }
     return $db;
 }
Example #4
0
 public function testWithMissingVersionNumbers()
 {
     $dir = dirname(__DIR__) . '/fixtures/migrations_with_missing_versions/';
     $migrator = new Horde_Db_Migration_Migrator($this->_conn, null, array('migrationsPath' => $dir));
     $migrator->migrate(500);
     $this->assertEquals(4, $migrator->getCurrentVersion());
     $migrator->migrate(2);
     $this->assertEquals(2, $migrator->getCurrentVersion());
     $e = null;
     try {
         $this->_conn->selectValues("SELECT * FROM reminders");
     } catch (Exception $e) {
     }
     $this->assertInstanceOf('Horde_Db_Exception', $e);
     $columns = $this->_columnNames('users');
     $this->assertTrue(in_array('last_name', $columns));
 }