public function testJoinXmlSchemaWithMultipleDatabaseSchema()
    {
        $expectedSchema = <<<EOF
<?xml version="1.0" encoding="utf-8"?>
<app-data>
  <database name="default" defaultIdMethod="native" schema="foo" defaultPhpNamingMethod="underscore">
    <table name="table1" idMethod="native" phpName="Table1">
      <column name="id" phpName="Id" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
    </table>
    <table name="table2" schema="bar" idMethod="native" phpName="Table2">
      <column name="id" phpName="Id" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
      <column name="table1_id" phpName="Table1Id" type="INTEGER"/>
      <foreign-key foreignTable="table1" foreignSchema="foo" name="table2_fk_6e7121">
        <reference local="table1_id" foreign="id"/>
      </foreign-key>
    </table>
  </database>
</app-data>
EOF;
        $fooReader = new SchemaReader(new PgsqlPlatform());
        $barReader = new SchemaReader(new PgsqlPlatform());
        $fooSchema = $fooReader->parseFile($this->getSchemaFile('fooSchema.xml'));
        $barSchema = $barReader->parseFile($this->getSchemaFile('barSchema.xml'));
        $fooSchema->joinSchemas([$barSchema]);
        $this->assertEquals($expectedSchema, $fooSchema->toString());
    }
 public function setUp()
 {
     // run only once to save execution time
     if (null == self::$database) {
         $schemaReader = new SchemaReader(new DefaultPlatform());
         $appData = $schemaReader->parseFile(realpath(__DIR__ . '/../../../../../Fixtures/bookstore/schema.xml'));
         self::$database = $appData->getDatabase("bookstore");
     }
 }
Beispiel #3
0
    public function testParseFileExternalSchema()
    {
        $schema = $this->reader->parseFile($this->getSchemaFile('outerSchema.xml'));
        $expectedSchema = <<<EOF
<?xml version="1.0" encoding="utf-8"?>
<app-data>
  <database name="foo" defaultIdMethod="native" defaultPhpNamingMethod="underscore">
    <table name="bar1" idMethod="native" phpName="Bar1">
      <column name="id" phpName="Id" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
    </table>
    <table name="bar2" idMethod="native" phpName="Bar2" skipSql="true" forReferenceOnly="true">
      <column name="id" phpName="Id" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
    </table>
  </database>
</app-data>
EOF;
        $this->assertEquals($expectedSchema, $schema->toString());
    }
Beispiel #4
0
    public function testParseFileExternalSchema()
    {
        $path = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'outerSchema.xml');
        $schemaReader = new SchemaReader();
        $schema = $schemaReader->parseFile($path);
        $expectedSchema = <<<EOF
<app-data>
<database name="foo" defaultIdMethod="native" defaultPhpNamingMethod="underscore">
  <table name="bar1" phpName="Bar1" idMethod="native">
    <column name="id" phpName="Id" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
  </table>
  <table name="bar2" phpName="Bar2" idMethod="native" forReferenceOnly="true">
    <column name="id" phpName="Id" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
  </table>
</database>
</app-data>
EOF;
        $this->assertEquals($expectedSchema, $schema->toString());
    }