/** */ public function testAddColumn() { try { $this->object->addColumn('', '', ''); $this->fail('addColumn does not accept empty string for table name!'); } catch (Phigrate_Exception_Argument $ex) { $msg = 'Missing table name parameter'; $this->assertEquals($msg, $ex->getMessage()); } try { $this->object->addColumn('users', '', ''); $this->fail('addColumn does not accept empty string for column name!'); } catch (Phigrate_Exception_Argument $ex) { $msg = 'Missing column name parameter'; $this->assertEquals($msg, $ex->getMessage()); } try { $this->object->addColumn('users', 'name', ''); $this->fail('addColumn does not accept empty string for type!'); } catch (Phigrate_Exception_Argument $ex) { $msg = 'Missing type parameter'; $this->assertEquals($msg, $ex->getMessage()); } //create it $this->object->executeDdl('CREATE TABLE `users` (name varchar(20));'); $col = $this->object->columnInfo('users', 'name'); $this->assertEquals('name', $col['field']); //add column $this->object->addColumn('users', 'fav_color', 'string', array('limit' => 32)); $col = $this->object->columnInfo('users', 'fav_color'); $this->assertEquals('fav_color', $col['field']); $this->assertEquals('varchar(32)', $col['type']); //add column $this->object->addColumn('users', 'latitude', 'decimal', array('precision' => 10, 'scale' => 2)); $col = $this->object->columnInfo('users', 'latitude'); $this->assertEquals('latitude', $col['field']); $this->assertEquals('decimal(10,2)', $col['type']); //add column with unsigned parameter $this->object->addColumn('users', 'age', 'integer', array('unsigned' => true)); $col = $this->object->columnInfo('users', 'age'); $this->assertEquals('age', $col['field']); $this->assertEquals('int(11) unsigned', $col['type']); //add column with biginteger datatype $this->object->addColumn('users', 'weight', 'biginteger', array('limit' => 20)); $col = $this->object->columnInfo('users', 'weight'); $this->assertEquals('weight', $col['field']); $this->assertEquals('bigint(20)', $col['type']); }