/** * @dataProvider parseDataProvider */ public function testParse($columnDDL, $expectedColumnPhpName, $expectedColumnDefaultType, $expectedColumnDefaultValue) { $this->con->query("create table foo ( {$columnDDL} );"); $parser = new PgsqlSchemaParser($this->con); $parser->setGeneratorConfig(new QuickGeneratorConfig()); $database = new Database(); $database->setPlatform(new DefaultPlatform()); // make sure our DDL insert produced exactly the SQL we inserted $this->assertEquals(1, $parser->parse($database), 'One table and one view defined should return one as we exclude views'); $tables = $database->getTables(); $this->assertEquals(1, count($tables)); $table = $tables[0]; $columns = $table->getColumns(); $this->assertEquals(1, count($columns)); // check out our rev-eng column info $defaultValue = $columns[0]->getDefaultValue(); $this->assertEquals($expectedColumnPhpName, $columns[0]->getPhpName()); $this->assertEquals($expectedColumnDefaultType, $defaultValue->getType()); $this->assertEquals($expectedColumnDefaultValue, $defaultValue->getValue()); }
/** * @return Database */ function getDatabaseSchema() { ClassLoader::import('DATABASE:propel:'); ClassLoader::import('DATABASE:propel:model'); ClassLoader::import('DATABASE:propel:reverse'); ClassLoader::import('DATABASE:propel:reverse:pgsql'); ClassLoader::import('DATABASE:propel:platform'); $parser = new PgsqlSchemaParser($this); $database = new Database($this->getDBName()); $database->setPlatform(new PgsqlPlatform($this)); $parser->parse($database); $database->doFinalInitialization(); return $database; }