public function testValidateReturnsFalseWhenTwoTablesHaveSamePhpName() { $table1 = new Table('foo'); $table2 = new Table('bar'); $table2->setPhpName('Foo'); $database = new Database(); $database->addTable($table1); $database->addTable($table2); $appData = new AppData(); $appData->addDatabase($database); $validator = new SchemaValidator($appData); $this->assertFalse($validator->validate()); $this->assertContains('Table "bar" declares a phpName already used in another table', $validator->getErrors()); }
/** Sets up the Propel model. */ public function setUp() { $appData = new AppData(new MysqlPlatform()); $this->database = new Database(); $appData->addDatabase($this->database); }
/** * Packages the datamodels to one datamodel per package * * This applies only when the the packageObjectModel option is set. We need to * re-package the datamodels to allow the database package attribute to control * which tables go into which SQL file. * * @return array The packaged datamodels */ protected function packageDataModels() { static $packagedDataModels; if (is_null($packagedDataModels)) { $dataModels = $this->getDataModels(); $dataModel = array_shift($dataModels); $packagedDataModels = array(); $platform = $this->getGeneratorConfig()->getConfiguredPlatform(); foreach ($dataModel->getDatabases() as $db) { foreach ($db->getTables() as $table) { $package = $table->getPackage(); if (!isset($packagedDataModels[$package])) { $dbClone = $this->cloneDatabase($db); $dbClone->setPackage($package); $ad = new AppData($platform); $ad->setGeneratorConfig($this->getGeneratorConfig()); $ad->setName($dataModel->getName()); $ad->addDatabase($dbClone); $packagedDataModels[$package] = $ad; } $packagedDataModels[$package]->getDatabase($db->getName())->addTable($table); } } } return $packagedDataModels; }