示例#1
0
 /**
  * setUp
  * @see PHPUnit_Framework_TestCase::setUp()
  */
 protected function setUp()
 {
     Migration::run(Migration::create("migration1", function (Migration $m) {
         $m->table("sample_table", function ($table) {
             $table->id();
             $table->varchar("title", 25);
             $table->text("content");
             $table->timesptamps();
         });
     }));
 }
 function setUp()
 {
     $tableName = $this->tableName;
     Migration::run(Migration::create("sample_table2", function (Migration $m) use($tableName) {
         $m->table($tableName, function ($table) {
             $table->id();
             $table->varchar("title", 25);
             $table->text("content");
             $table->timesptamps();
         });
     }));
 }
示例#3
0
 /**
  * setUp
  * @see PHPUnit_Framework_TestCase::setUp()
  */
 protected function setUp()
 {
     Migration::run(Migration::create("migration1", function (Migration $m) {
         $m->table("sample_table_simple_crud", function (Table $table) {
             $table->id();
             $table->integer("user_id")->notnull();
             $table->varchar("title", 25);
             $table->text("content");
             $table->timesptamps();
         });
     }));
 }
示例#4
0
 function testModifyTable()
 {
     $createTestTable = Migration::create("migration1", function (Migration $m) {
         $m->table("sample_table", function ($table) {
             $table->id();
             $table->varchar("title", 25);
             $table->text("content");
             $table->timesptamps();
         });
     });
     $modifyTable = Migration::create("migration2", function (Migration $m) {
         $m->table("sample_table", function ($table) {
             $table->text("fugafuga");
         });
     });
     //テーブル作成
     Migration::run([$createTestTable, $modifyTable]);
     $columns = $this->getColumns("sample_table");
     $this->assertArrayHasKey("id", $columns);
     $this->assertArrayHasKey("title", $columns);
     $this->assertArrayHasKey("content", $columns);
     $this->assertArrayHasKey("fugafuga", $columns);
     $this->assertArrayHasKey("created_at", $columns);
     $this->assertArrayHasKey("updated_at", $columns);
     //カラムの削除
     $createTestTable = Migration::create("migration1", function (Migration $m) {
         $m->table("drop_column_table", function ($table) {
             $table->id();
             $table->varchar("title", 25);
             $table->text("content");
             $table->timesptamps();
         });
     });
     $deleteColumn = Migration::create("migration3", function (Migration $m) {
         $m->table("sample_table", function (Table $table) {
             $table->dropColumn("fugafuga");
         });
     });
     Migration::run($createTestTable);
     Migration::run($deleteColumn);
     $columns = $this->getColumns("sample_table");
     $this->assertArrayNotHasKey("fugafuga", $columns, "カラムの削除に失敗");
 }