Пример #1
0
    public function setUp()
    {
        if (!class_exists('\\Issue656TestObject')) {
            $schema = <<<EOF
<database>
    <table name="issue_656_test_object">
        <column name="ID" type="INTEGER" size="10" sqlType="int(10) unsigned" primaryKey="true" required="true" autoIncrement="true"/>
        <column name="Name" type="VARCHAR" size="45" required="true"/>
    </table>
    <table name="issue_656_test_object_from" isCrossRef="true">
        <column name="From" type="INTEGER" size="10" sqlType="int(10) unsigned" primaryKey="true" required="true"/>
        <column name="To" type="INTEGER" size="10" sqlType="int(10) unsigned" primaryKey="true" required="true"/>
        <foreign-key name="fk_test_object_from" foreignTable="issue_656_test_object">
            <reference local="From" foreign="ID"/>
        </foreign-key>
        <foreign-key name="fk_test_object_to" foreignTable="issue_656_test_object">
            <reference local="To" foreign="ID"/>
        </foreign-key>
    </table>
</database>
EOF;
            $builder = new QuickBuilder();
            $builder->setSchema($schema);
            $builder->buildClasses(null, true);
        }
    }
 /**
  * Builds all classes and migrates the database.
  *
  * @param string $schema xml schema
  */
 public function buildAndMigrate($schema)
 {
     $builder = new QuickBuilder();
     $platform = $this->getPlatform();
     $builder->setPlatform($platform);
     $builder->setParser($this->getParser($this->con));
     $builder->getParser()->setPlatform($platform);
     $builder->setSchema($schema);
     $builder->buildClasses(null, true);
     $builder->updateDB($this->con);
 }
Пример #3
0
    public function setUp()
    {
        if (!class_exists('\\Base\\Issue1033Book')) {
            $schema = <<<EOF
<database>
    <table name="Issue1033Book">
        <column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" description="Book Id" />
        <column name="title" type="VARCHAR" required="true" description="Book Title" primaryString="true" />
    </table>
</database>
EOF;
            $builder = new QuickBuilder();
            $builder->setSchema($schema);
            $builder->buildClasses(null, true);
        }
    }
Пример #4
0
    public function testToArrayKeyTypePreDefined()
    {
        $schema = <<<EOF
<database name="test"  namespace="MyNameSpace">
    <table name="test_key_type_table">
        <column name="id_key_type" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
        <column name="name_key_type" type="VARCHAR" />
    </table>
</database>
EOF;
        $builder = new QuickBuilder();
        $builder->setSchema($schema);
        $builder->getConfig()->setBuildProperty('defaultKeyType', 'studlyPhpName');
        $builder->buildClasses();
        $expectedKeys = array('idKeyType', 'nameKeyType');
        $object = new TestKeyTypeTable();
        $this->assertEquals($expectedKeys, array_keys($object->toArray()), 'toArray() returns an associative array with pre-defined key type in properties.');
    }
    public function testHydrateWithMysqlInvalidDate()
    {
        $schema = <<<EOF
<database name="generated_object_complex_type_test_6">
<table name="complex_column_type_entity_6">
    <column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
    <column name="bar1" type="DATE" />
    <column name="bar2" type="TIME"  />
    <column name="bar3" type="TIMESTAMP" />
</table>
</database>
EOF;
        $builder = new QuickBuilder();
        $builder->setSchema($schema);
        $builder->setPlatform(new MysqlPlatform());
        $builder->buildClasses();
        $r = new \ComplexColumnTypeEntity6();
        $r->hydrate(array(123, '0000-00-00', '00:00:00', '0000-00-00 00:00:00'));
        $this->assertNull($r->getBar1());
        $this->assertEquals('00:00:00', $r->getBar2()->format('H:i:s'));
        $this->assertNull($r->getBar3());
    }
Пример #6
0
 protected function buildClasses($schema)
 {
     $builder = new QuickBuilder();
     $builder->setSchema($schema);
     $builder->buildClasses();
 }
Пример #7
0
 /**
  * @dataProvider tablePrefixDataProvider
  */
 public function testGeneratedClassesWithTablePrefix($schema, $expectSQL, $expectClasses)
 {
     $builder = new QuickBuilder();
     $builder->setSchema($schema);
     $builder->buildClasses();
     foreach ($expectClasses as $expectClass) {
         $this->assertTrue(class_exists($expectClass), sprintf('expect class "%s" is not exists', $expectClass));
     }
 }