SqlParser\Tests\Builder\CreateStatementTest::testBuilderTable PHP Method

testBuilderTable() public method

public testBuilderTable ( )
    public function testBuilderTable()
    {
        /* Assertion 1 */
        $stmt = new CreateStatement();
        $stmt->name = new Expression('', 'test', '');
        $stmt->options = new OptionsArray(array('TABLE'));
        $stmt->fields = array(new CreateDefinition('id', new OptionsArray(array('NOT NULL', 'AUTO_INCREMENT')), new DataType('INT', array(11), new OptionsArray(array('UNSIGNED')))), new CreateDefinition('', null, new Key('', array(array('name' => 'id')), 'PRIMARY KEY')));
        $this->assertEquals("CREATE TABLE `test` (\n" . "  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n" . "  PRIMARY KEY (`id`)\n" . ") ", $stmt->build());
        /* Assertion 2 */
        $query = "CREATE TABLE `jos_core_acl_aro` (\n" . "  `id` int(11) NOT NULL,\n" . "  `section_value` varchar(240) NOT NULL DEFAULT '0',\n" . "  `value` varchar(240) NOT NULL DEFAULT '',\n" . "  `order_value` int(11) NOT NULL DEFAULT '0',\n" . "  `name` varchar(255) NOT NULL DEFAULT '',\n" . "  `hidden` int(11) NOT NULL DEFAULT '0',\n" . "  PRIMARY KEY (`id`),\n" . "  UNIQUE KEY `jos_section_value_value_aro` (`section_value`(100),`value`(15)) USING BTREE,\n" . "  KEY `jos_gacl_hidden_aro` (`hidden`)\n" . ") ENGINE=InnoDB DEFAULT CHARSET=latin1";
        $parser = new Parser($query);
        $this->assertEquals($query, $parser->statements[0]->build());
        /* Assertion 3 */
        $query = "CREATE TABLE `table_copy` LIKE `old_table`";
        $parser = new Parser($query);
        $this->assertEquals($query, $parser->statements[0]->build());
        /* Assertion 4 */
        $query = "CREATE TABLE `aa` (\n" . "  `id` int(11) NOT NULL,\n" . "  `rTime` timestamp(3) NOT NULL DEFAULT '0000-00-00 00:00:00.000' ON UPDATE CURRENT_TIMESTAMP(3),\n" . "  PRIMARY KEY (`id`)\n" . ") ENGINE=InnoDB DEFAULT CHARSET=latin1";
        $parser = new Parser($query);
        $this->assertEquals($query, $parser->statements[0]->build());
    }