Example #1
0
 /**
  * Add a database to the list and sets the AppData property to this
  * AppData
  *
  * @param      db the database to add
  */
 public function addDatabase($db)
 {
     if ($db instanceof Database) {
         $db->setAppData($this);
         if ($db->getPlatform() === null) {
             if ($config = $this->getGeneratorConfig()) {
                 $pf = $config->getConfiguredPlatform(null, $db->getName());
                 $db->setPlatform($pf ? $pf : $this->platform);
             } else {
                 $db->setPlatform($this->platform);
             }
         }
         $this->dbList[] = $db;
         return $db;
     } else {
         // XML attributes array / hash
         $d = new Database();
         $d->setAppData($this);
         $d->loadFromXML($db);
         return $this->addDatabase($d);
         // calls self w/ different param type
     }
 }
Example #2
0
    public function testAppendXmlNamespaceWithAutoPackage()
    {
        $schema = <<<EOF
<?xml version="1.0"?>
<table name="test" namespace="\\testNs"/>
EOF;
        $doc = new DOMDocument('1.0');
        $doc->formatOutput = true;
        $config = new GeneratorConfig();
        $config->setBuildProperties(array('propel.namespace.autoPackage' => 'true'));
        $appData = new AppData();
        $appData->setGeneratorConfig($config);
        $db = new Database('testDb');
        $db->setAppData($appData);
        $table = new Table('test');
        $table->setDatabase($db);
        $table->setNamespace('\\testNs');
        $table->appendXml($doc);
        $xmlstr = trim($doc->saveXML());
        $this->assertSame($schema, $xmlstr);
        $schema = <<<EOF
<?xml version="1.0"?>
<table name="test" namespace="\\testNs" package="testPkg"/>
EOF;
        $doc = new DOMDocument('1.0');
        $doc->formatOutput = true;
        $table->setPackage('testPkg');
        $table->appendXml($doc);
        $xmlstr = trim($doc->saveXML());
        $this->assertSame($schema, $xmlstr);
    }
Example #3
0
 /**
  * Add a database to the list and sets the AppData property to this
  * AppData
  *
  * @param      db the database to add
  */
 public function addDatabase($db)
 {
     if ($db instanceof Database) {
         $db->setAppData($this);
         if ($db->getPlatform() === null) {
             $db->setPlatform($this->platform);
         }
         $this->dbList[] = $db;
         return $db;
     } else {
         // XML attributes array / hash
         $d = new Database();
         $d->setAppData($this);
         if ($d->getPlatform() === null) {
             $d->setPlatform($this->platform);
         }
         $d->loadFromXML($db);
         return $this->addDatabase($d);
         // calls self w/ different param type
     }
 }