public function testChangeColumnWithDefault() { $table = new \Phinx\Db\Table('t', array(), $this->adapter); $table->addColumn('column1', 'string')->save(); $newColumn1 = new \Phinx\Db\Table\Column(); $newColumn1->setName('column1')->setType('string')->setNull(true); $newColumn1->setDefault('Test'); $table->changeColumn('column1', $newColumn1); $columns = $this->adapter->getColumns('t'); foreach ($columns as $column) { if ($column->getName() === 'column1') { $this->assertTrue($column->isNull()); $this->assertRegExp('/Test/', $column->getDefault()); } } }
public function testChangeColumnDefaultToNull() { $table = new \Phinx\Db\Table('t', array(), $this->adapter); $table->addColumn('column1', 'string', array('default' => 'test'))->save(); $newColumn1 = new \Phinx\Db\Table\Column(); $newColumn1->setDefault(null)->setType('string'); $table->changeColumn('column1', $newColumn1); $rows = $this->adapter->fetchAll('SHOW COLUMNS FROM t'); $this->assertNull($rows[1]['Default']); }