/** */ public function testTypeToSql() { try { $this->object->typeToSql('unknown', ''); } catch (Phigrate_Exception_Argument $e) { $msg = "Error: I dont know what column type of 'unknown' maps to for MySQL.\nYou provided: unknown\nValid types are: \n\tstring\n\tsmalltext\n\ttext\n\tmediumtext\n\tlongtext\n\tinteger\n\ttinyinteger\n\tsmallinteger\n\tmediuminteger\n\tbiginteger\n\tfloat\n\tdecimal\n\tdatetime\n\ttimestamp\n\ttime\n\tdate\n\ttinybinary\n\tbinary\n\tmediumbinary\n\tlongbinary\n\tboolean\n"; $this->assertEquals($msg, $e->getMessage()); } try { $this->object->typeToSql('decimal', array('scale' => 4)); } catch (Phigrate_Exception_Argument $e) { $msg = 'Error adding decimal column: precision cannot ' . 'be empty if scale is specified'; $this->assertEquals($msg, $e->getMessage()); } $type = $this->object->typeToSql('integer', array('limit' => 12)); $this->assertEquals('int(12)', $type); $type = $this->object->typeToSql('tinyinteger', array('limit' => 2)); $this->assertEquals('tinyint(2)', $type); $type = $this->object->typeToSql('smallinteger', array('limit' => 2)); $this->assertEquals('smallint(2)', $type); $type = $this->object->typeToSql('mediuminteger', array('limit' => 4)); $this->assertEquals('mediumint(4)', $type); $type = $this->object->typeToSql('biginteger', array('limit' => 20)); $this->assertEquals('bigint(20)', $type); $type = $this->object->typeToSql('integer'); $this->assertEquals('int(11)', $type); $type = $this->object->typeToSql('decimal', array('precision' => 2)); $this->assertEquals('decimal(2)', $type); $type = $this->object->typeToSql('decimal', array('precision' => 2, 'scale' => 4)); $this->assertEquals('decimal(2, 4)', $type); }