public function testGetAddTableDDLEngine() { $schema = <<<EOF <database name="test"> <table name="foo"> <column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" /> </table> </database> EOF; $platform = new MysqlPlatform(); $platform->setTableEngineKeyword('TYPE'); $platform->setDefaultTableEngine('MEMORY'); $xtad = new XmlToAppData($platform); $appData = $xtad->parseString($schema); $table = $appData->getDatabase()->getTable('foo'); $expected = "\nCREATE TABLE `foo`\n(\n `id` INTEGER NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n) TYPE=MEMORY;\n"; $this->assertEquals($expected, $platform->getAddTableDDL($table)); }
public function testAddExtraIndicesForeignKeys() { $include_path = get_include_path(); set_include_path($include_path . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../../../../generator/lib')); $platform = new MysqlPlatform(); $xmlToAppData = new XmlToAppData($platform); $config = new GeneratorConfig(); $config->setBuildProperties(array('propel.behavior.autoaddpkbehavior.class' => 'behavior.AutoAddPkBehavior')); $xmlToAppData->setGeneratorConfig($config); $schema = <<<EOF <database name="test1"> <table name="foo"> <behavior name="autoAddPKBehavior"/> <column name="name" type="VARCHAR"/> <column name="subid" type="INTEGER"/> </table> <table name="bar"> <behavior name="autoAddPKBehavior"/> <column name="name" type="VARCHAR"/> <column name="subid" type="INTEGER"/> <foreign-key foreignTable="foo"> <reference local="id" foreign="id"/> <reference local="subid" foreign="subid"/> </foreign-key> </table> </database> EOF; $expectedRelationSql = "\nCREATE TABLE `bar`\n(\n `name` VARCHAR(255),\n `subid` INTEGER,\n `id` INTEGER NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`),\n INDEX `bar_FI_1` (`id`, `subid`)\n) ENGINE=MyISAM;\n"; $appData = $xmlToAppData->parseString($schema); set_include_path($include_path); $table = $appData->getDatabase('test1')->getTable('bar'); $relationTableSql = $platform->getAddTableDDL($table); $this->assertEquals($expectedRelationSql, $relationTableSql); }