예제 #1
0
 public function testMigration()
 {
     copy('tests/migrations/12345678901234_import.php', vfsStream::url('home/yentu/migrations/12345678901234_import.php'));
     $migrate = new \yentu\commands\Migrate();
     $migrate->run(array('no-foreign-keys' => true));
     $this->assertEquals(file_get_contents("tests/streams/migrate_options_output_1.txt"), file_get_contents(vfsStream::url('home/output.txt')));
     foreach ($this->fkeys as $fkey) {
         $this->assertForeignKeyDoesntExist($fkey);
     }
     file_put_contents(vfsStream::url("home/output.txt"), '');
     $migrate->run(array('only-foreign-keys' => true));
     $this->assertEquals(file_get_contents("tests/streams/migrate_options_output_2.txt"), file_get_contents(vfsStream::url('home/output.txt')));
     foreach ($this->fkeys as $fkey) {
         $this->assertForeignKeyExists($fkey);
     }
 }
예제 #2
0
 public function testNameChange()
 {
     copy('tests/migrations/12345678901234_some_table.php', vfsStream::url('home/yentu/migrations/12345678901234_some_table.php'));
     $migrate = new \yentu\commands\Migrate();
     $migrate->run(array());
     $this->assertTableExists('some_table');
     copy('tests/migrations/12345678901235_other_table.php', vfsStream::url('home/yentu/migrations/12345678901235_other_table.php'));
     $migrate = new \yentu\commands\Migrate();
     $migrate->run(array());
     $this->assertTableExists('some_other_table');
     $this->assertTableDoesntExist('some_table');
 }
예제 #3
0
 public function testSchemaMigration()
 {
     $this->skipSchemaTests();
     copy('tests/migrations/12345678901234_schema.php', vfsStream::url('home/yentu/migrations/12345678901234_schema.php'));
     $migrate = new \yentu\commands\Migrate();
     $migrate->run(array());
     $this->assertSchemaExists('schema');
     foreach ($this->tables as $table) {
         if ($table == 'yentu_history') {
             return;
         }
         $schema = array_search($table, array('cities', 'locations', 'countries', 'regions', 'countries_view')) === false ? 'schema' : 'geo';
         $this->assertTableExists(array('table' => $table, 'schema' => $schema));
     }
 }