/** * test column definition */ public function test_column_definition() { $expected = "`age` varchar(255)"; $this->assertEquals($expected, $this->adapter->column_definition("age", "string")); $expected = "`age` varchar(32)"; $this->assertEquals($expected, $this->adapter->column_definition("age", "string", array('limit' => 32))); $expected = "`age` varchar(32) NOT NULL"; $this->assertEquals($expected, $this->adapter->column_definition("age", "string", array('limit' => 32, 'null' => false))); $expected = "`age` varchar(32) DEFAULT 'abc' NOT NULL"; $this->assertEquals($expected, $this->adapter->column_definition("age", "string", array('limit' => 32, 'default' => 'abc', 'null' => false))); $expected = "`age` varchar(32) DEFAULT 'abc'"; $this->assertEquals($expected, $this->adapter->column_definition("age", "string", array('limit' => 32, 'default' => 'abc'))); $expected = "`age` int(11)"; $this->assertEquals($expected, $this->adapter->column_definition("age", "integer")); $expected = "`active` tinyint(1)"; $this->assertEquals($expected, $this->adapter->column_definition("active", "boolean")); $expected = "`weight` bigint(20)"; $this->assertEquals($expected, $this->adapter->column_definition("weight", "biginteger", array('limit' => 20))); $expected = "`weight` mediumint(4)"; $this->assertEquals($expected, $this->adapter->column_definition("weight", "mediuminteger", array('limit' => 4))); $expected = "`weight` tinyint(1)"; $this->assertEquals($expected, $this->adapter->column_definition("weight", "tinyinteger", array('limit' => 1))); $expected = "`age` int(11) AFTER `height`"; $this->assertEquals($expected, $this->adapter->column_definition("age", "integer", array("after" => "height"))); $expected = "`adapter` enum('mysql','pgsql','ha\\'xor')"; $this->assertEquals($expected, $this->adapter->column_definition("adapter", "enum", array('values' => array('mysql', 'pgsql', "ha'xor")))); $expected = "`age` tinytext"; $this->assertEquals($expected, $this->adapter->column_definition("age", "tinytext")); $expected = "`age` longblob"; $this->assertEquals($expected, $this->adapter->column_definition("age", "longbinary")); }