Ejemplo n.º 1
0
 public function testExecuteWithoutTableSchema()
 {
     $this->_adapter->setTableSchemaExist(false);
     $actual = $this->object->execute(array());
     $regexp = '/^Started: \\d{4}-\\d{2}-\\d{2} \\d{1,2}:\\d{2}(am|pm) \\w{3,4}\\012+' . "\\[db:setup\\]: \n+\t+Creating table: 'schema_migrations'" . '\\012+\\t+Done\\.\\012+Finished: ' . '\\d{4}-\\d{2}-\\d{2} \\d{1,2}:\\d{2}(am|pm) \\w{3,4}\\012+$/';
     $this->assertNotEmpty($actual);
     $this->assertRegExp($regexp, $actual);
 }
Ejemplo n.º 2
0
 public function testExecuteWithOneVersionMoreInTableSchema()
 {
     $this->_adapter->setTableSchemaExist(true);
     $this->_adapter->versions = array(array('version' => '20120109064438'), array('version' => '20120110064438'), array('version' => '20120111064438'), array('version' => '20130112064438'));
     $regexp = '/^Started: \\d{4}-\\d{2}-\\d{2} \\d{1,2}:\\d{2}(am|pm) \\w{3,4}\\012+' . '\\[db:status\\]:\\012+' . '=+ APPLIED =+\\012+' . "\t\\[40m\\[1;32mCreateUsers \\[ 20120109064438 \\]\\[40m\\[1;35m \\([\\w ]{0,50}\\.\\.\\.\\)\\[0m\n+" . "\t\\[40m\\[1;32mAddIndexToUsers \\[ 20120110064438 \\]\\[0m\n+" . "\t\\[40m\\[1;32mCreateAddresses \\[ 20120111064438 \\]\\[40m\\[1;35m \\([\\w ]{0,50}\\)\\[0m\n+" . '=+ NOT APPLIED =+\\012+' . "\t\\[40m\\[1;33mMissingMethodUp \\[ 20120112064438 \\]\\[0m\n+" . '=+ APPLIED WITHOUT MIGRATION FILE =+\\012+' . "\t\\[40m\\[1;31m\\?\\?\\? \\[ 20130112064438 \\]\\[0m\n+" . '\\012+Finished: \\d{4}-\\d{2}-\\d{2} \\d{1,2}:\\d{2}(am|pm) \\w{3,4}\\012+$/';
     $actual = $this->object->execute(array());
     $this->assertNotEmpty($actual);
     $this->assertRegExp($regexp, $actual);
 }
Ejemplo n.º 3
0
 public function testExecute()
 {
     $this->_adapter->setTableSchemaExist(true);
     $this->object->setDirectoryOfMigrations('/tmp');
     $expected = FIXTURES_PATH . '/db/schema.txt';
     $actual = $this->object->execute(array());
     $this->assertFileExists('/tmp/schema.txt');
     $this->assertFileEquals($expected, '/tmp/schema.txt');
 }
Ejemplo n.º 4
0
 public function removeIndex($table, $column)
 {
     if (isset($this->exception)) {
         throw $this->exception;
     }
     parent::removeIndex($table, $column);
 }
Ejemplo n.º 5
0
 /**
  */
 public function testFinish()
 {
     $table = new Phigrate_Adapter_Mysql_TableDefinition($this->_adapter, 'users');
     $table->column('test', 'string', array('auto_increment' => true));
     $table->finish();
     $expected = array("CREATE TABLE `users` (\n`id` int(11) UNSIGNED auto_increment NOT NULL,\n`test` varchar(255) auto_increment NOT NULL,\n PRIMARY KEY (`id`));");
     $queries = $this->_adapter->getConnexion()->getQueries();
     $this->assertSame($expected, $queries);
 }