public function setUp()
    {
        if (!class_exists('ComplexColumnTypeEntity11')) {
            $schema = <<<EOF
<database name="generated_object_complex_type_test_11">
\t<table name="complex_column_type_entity_11">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="tags" type="ARRAY" />
\t\t<column name="value_set" type="ARRAY" />
\t</table>
</database>
EOF;
            PropelQuickBuilder::buildSchema($schema);
            $e0 = new ComplexColumnTypeEntity11();
            $e0->save();
            $e1 = new ComplexColumnTypeEntity11();
            $e1->setTags(array('foo', 'bar', 'baz'));
            $e1->save();
            $e2 = new ComplexColumnTypeEntity11();
            $e2->setTags(array('bar'));
            $e2->save();
            $e3 = new ComplexColumnTypeEntity11();
            $e3->setTags(array('bar23'));
            $e3->save();
        }
    }
    public function setUp()
    {
        $this->c1 = new FooColumnValue2();
        $this->c1->bar = 1234;
        $this->c2 = new FooColumnValue2();
        $this->c2->bar = 5678;
        if (!class_exists('ComplexColumnTypeEntity10')) {
            $schema = <<<EOF
<database name="generated_query_complex_type_test_10">
\t<table name="complex_column_type_entity_10">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="bar" type="OBJECT" />
\t</table>
</database>
EOF;
            PropelQuickBuilder::buildSchema($schema);
            $e0 = new ComplexColumnTypeEntity10();
            $e0->save();
            $e1 = new ComplexColumnTypeEntity10();
            $e1->setBar($this->c1);
            $e1->save();
            $e2 = new ComplexColumnTypeEntity10();
            $e2->setBar($this->c2);
            $e2->save();
            ComplexColumnTypeEntity10Peer::clearInstancePool();
        }
    }
    public function testObjectColumnType()
    {
        $schema = <<<EOF
<database name="generated_object_complex_type_test_1">
\t<table name="complex_column_type_entity_1">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="bar" type="OBJECT" />
\t</table>
</database>
EOF;
        PropelQuickBuilder::buildSchema($schema);
        $e = new ComplexColumnTypeEntity1();
        $this->assertNull($e->getBar(), 'object columns are null by default');
        $c = new FooColumnValue();
        $c->bar = 1234;
        $e->setBar($c);
        $this->assertEquals($c, $e->getBar(), 'object columns can store objects');
        $e->setBar(null);
        $this->assertNull($e->getBar(), 'object columns are nullable');
        $e->setBar($c);
        $e->save();
        ComplexColumnTypeEntity1Peer::clearInstancePool();
        $e = ComplexColumnTypeEntity1Query::create()->findOne();
        $this->assertEquals($c, $e->getBar(), 'object columns are persisted');
    }
    public function setUp()
    {
        if (!class_exists('ArchivableTest10')) {
            $schema = <<<EOF
<database name="archivable_behavior_test_10">

\t<table name="archivable_test_10">
\t\t<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
\t\t<column name="title" type="VARCHAR" size="100" primaryString="true" />
\t\t<column name="age" type="INTEGER" />
\t\t<column name="foo_id" type="INTEGER" />
\t\t<foreign-key foreignTable="archivable_test_20">
\t\t\t<reference local="foo_id" foreign="id" />
\t\t</foreign-key>
\t\t<index>
\t\t\t<index-column name="title" />
\t\t\t<index-column name="age" />
\t\t</index>
\t\t<behavior name="archivable" />
\t</table>

\t<table name="archivable_test_20">
\t\t<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
\t\t<column name="title" type="VARCHAR" size="100" primaryString="true" />
\t\t<behavior name="archivable" />
\t</table>

\t<table name="archivable_test_20_archive">
\t\t<column name="id" required="true" primaryKey="true" type="INTEGER" />
\t\t<column name="title" type="VARCHAR" size="100" primaryString="true" />
\t</table>

\t<table name="archivable_test_30">
\t\t<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
\t\t<column name="title" type="VARCHAR" size="100" primaryString="true" />
\t\t<column name="age" type="INTEGER" />
\t\t<column name="foo_id" type="INTEGER" />
\t\t<behavior name="archivable">
\t\t\t<parameter name="log_archived_at" value="false" />
\t\t\t<parameter name="archive_table" value="my_old_archivable_test_30" />
\t\t\t<parameter name="archive_on_insert" value="true" />
\t\t\t<parameter name="archive_on_update" value="true" />
\t\t\t<parameter name="archive_on_delete" value="false" />
\t\t</behavior>
\t</table>

\t<table name="archivable_test_40">
\t\t<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
\t\t<column name="title" type="VARCHAR" size="100" primaryString="true" />
\t\t<column name="age" type="INTEGER" />
\t\t<behavior name="archivable">
\t\t\t<parameter name="archive_class" value="FooArchive" />
\t\t</behavior>
\t</table>

</database>
EOF;
            PropelQuickBuilder::buildSchema($schema);
        }
    }
    public function setUp()
    {
        if (!class_exists('I18nBehaviorTest1')) {
            $schema = <<<EOF
<database name="i18n_behavior_test_1">
\t<table name="i18n_behavior_test_1">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="foo" type="INTEGER" />
\t\t<column name="bar" type="VARCHAR" size="100" />
\t\t<behavior name="i18n">
\t\t\t<parameter name="i18n_columns" value="bar" />
\t\t</behavior>
\t</table>
\t<table name="i18n_behavior_test_2">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="foo" type="INTEGER" />
\t\t<column name="bar1" type="VARCHAR" size="100" />
\t\t<column name="bar2" type="LONGVARCHAR" lazyLoad="true" />
\t\t<column name="bar3" type="TIMESTAMP" />
\t\t<column name="bar4" type="LONGVARCHAR" description="This is the Bar4 column" />
\t\t<behavior name="i18n">
\t\t\t<parameter name="i18n_columns" value="bar1,bar2,bar3,bar4" />
\t\t\t<parameter name="default_locale" value="fr_FR" />
\t\t\t<parameter name="locale_alias" value="culture" />
\t\t</behavior>
\t</table>

\t<table name="movie">
\t\t<column name="id" type="integer" required="true" primaryKey="true" autoincrement="true" />
\t\t<column name="director" type="varchar" size="255" />
\t\t<column name="title" type="varchar" primaryString="true" />
\t\t<behavior name="i18n">
\t\t\t<parameter name="i18n_columns" value="title" />
\t\t\t<parameter name="locale_alias" value="culture" />
\t\t</behavior>
\t</table>
\t<table name="toy">
\t\t<column name="id" type="integer" required="true" primaryKey="true" autoincrement="true" />
\t\t<column name="ref" type="varchar" size="255" />
\t\t<column name="name" type="varchar" size="255" />
\t\t<behavior name="i18n">
\t\t\t<parameter name="i18n_columns" value="name" />
\t\t\t<parameter name="locale_alias" value="culture" />
\t\t</behavior>
\t\t<column name="movie_id" type="integer" />
\t\t<foreign-key foreignTable="movie">
\t\t\t<reference local="movie_id" foreign="id" />
\t\t</foreign-key>
\t</table>
</database>
EOF;
            PropelQuickBuilder::buildSchema($schema);
        }
    }
    public function setUp()
    {
        if (!class_exists('ComplexColumnTypeEntity103Peer')) {
            $schema = <<<EOF
<database name="generated_object_complex_type_test_103">
\t<table name="complex_column_type_entity_103">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="bar" type="ENUM" valueSet="foo, bar, baz, 1, 4,(, foo bar " />
\t</table>
</database>
EOF;
            PropelQuickBuilder::buildSchema($schema);
        }
    }
    public function setUp()
    {
        if (!class_exists('VersionableBehaviorTest10')) {
            $schema = <<<EOF
<database name="versionable_behavior_test_10">
\t<table name="versionable_behavior_test_10">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="bar" type="INTEGER" />
\t\t<behavior name="versionable" />
\t</table>
</database>>
EOF;
            PropelQuickBuilder::buildSchema($schema);
        }
    }
    public function setUp()
    {
        if (!class_exists('ComplexColumnTypeEntity2')) {
            $schema = <<<EOF
<database name="generated_object_complex_type_test_2">
\t<table name="complex_column_type_entity_2">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="tags" type="ARRAY" />
\t\t<column name="value_set" type="ARRAY" />
\t</table>
</database>
EOF;
            PropelQuickBuilder::buildSchema($schema);
        }
    }
    public function setUp()
    {
        if (!class_exists('LazyLoadActiveRecord2')) {
            $schema = <<<EOF
<database name="lazy_load_active_record_2">
\t<table name="lazy_load_active_record_2">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="foo" type="VARCHAR" size="100" />
\t\t<column name="bar" type="VARCHAR" size="100" lazyLoad="true" />
\t\t<column name="baz" type="VARCHAR" size="100" />
\t</table>
</database>
EOF;
            PropelQuickBuilder::buildSchema($schema);
        }
    }
    public function setUp()
    {
        if (!class_exists('ComplexColumnTypeEntity4')) {
            $schema = <<<EOF
<database name="generated_object_complex_type_test_4">
\t<table name="complex_column_type_entity_4">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="bar" type="BOOLEAN" />
\t\t<column name="true_bar" type="BOOLEAN" defaultValue="true" />
\t\t<column name="false_bar" type="BOOLEAN" defaultValue="false" />
\t</table>
</database>
EOF;
            PropelQuickBuilder::buildSchema($schema);
        }
    }
    public function setUp()
    {
        if (!class_exists('ComplexColumnTypeEntity5')) {
            $schema = <<<EOF
<database name="generated_object_complex_type_test_5">
\t<table name="complex_column_type_entity_5">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="bar1" type="DATE" />
\t\t<column name="bar2" type="TIME"  />
\t\t<column name="bar3" type="TIMESTAMP" />
\t</table>
</database>
EOF;
            PropelQuickBuilder::buildSchema($schema);
        }
    }
    public function testFieldKeys()
    {
        $schema = <<<EOF
<database name="i18n_behavior_test_0">
\t<table name="i18n_behavior_test_03">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="foo1" type="VARCHAR" />
\t\t<column name="foo2" type="VARCHAR" />
\t\t<column name="foo3" type="VARCHAR" />
\t\t<behavior name="i18n">
\t\t\t<parameter name="i18n_columns" value="foo2" />
\t\t</behavior>
\t</table>
</database>
EOF;
        PropelQuickBuilder::buildSchema($schema);
        $this->assertEquals(array(0, 1, 2), I18nBehaviorTest03Peer::getFieldNames(BasePeer::TYPE_NUM));
    }
    public function setUp()
    {
        if (!class_exists('ComplexColumnTypeEntity3')) {
            $schema = <<<EOF
<database name="generated_object_complex_type_test_3">
\t<table name="complex_column_type_entity_3">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="bar" type="ENUM" valueSet="foo, bar, baz, 1, 4,(, foo bar " />
\t\t<column name="bar2" type="ENUM" valueSet="foo, bar" defaultValue="bar" />
\t</table>
</database>
EOF;
            PropelQuickBuilder::buildSchema($schema);
            // ok this is hackish but it makes testing of getter and setter independent of each other
            $publicAccessorCode = <<<EOF
class PublicComplexColumnTypeEntity3 extends ComplexColumnTypeEntity3
{
\tpublic \$bar;
}
EOF;
            eval($publicAccessorCode);
        }
    }
    public function setUp()
    {
        if (!class_exists('ComplexColumnTypeEntity13')) {
            $schema = <<<EOF
<database name="generated_object_complex_type_test_13">
\t<table name="complex_column_type_entity_13">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="bar" type="ENUM" valueSet="foo, bar, baz, 1, 4,(, foo bar " />
\t\t<column name="bar2" type="ENUM" valueSet="foo, bar" defaultValue="bar" />
\t</table>
</database>
EOF;
            PropelQuickBuilder::buildSchema($schema);
            $e0 = new ComplexColumnTypeEntity13();
            $e0->save();
            $e1 = new ComplexColumnTypeEntity13();
            $e1->setBar('baz');
            $e1->save();
            $e2 = new ComplexColumnTypeEntity13();
            $e2->setBar('4');
            $e2->save();
            ComplexColumnTypeEntity13Peer::clearInstancePool();
        }
    }
    public function testTablePrefixSameDatabase()
    {
        $schema = <<<EOF
<database name="testTablePrefixSameDatabase_database" tablePrefix="foo">

\t<table name="testTablePrefixSameDatabase_main">
\t\t<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
\t\t<column name="title" type="VARCHAR" size="100" primaryString="true" />
\t\t<column name="delegate_id" type="INTEGER" />
\t\t<foreign-key foreignTable="testTablePrefixSameDatabase_delegate">
\t\t\t<reference local="delegate_id" foreign="id" />
\t\t</foreign-key>
\t\t<behavior name="delegate">
\t\t\t<parameter name="to" value="testTablePrefixSameDatabase_delegate" />
\t\t</behavior>
\t</table>

\t<table name="testTablePrefixSameDatabase_delegate">
\t\t<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
\t\t<column name="subtitle" type="VARCHAR" size="100" primaryString="true" />
\t</table>

</database>
EOF;
        PropelQuickBuilder::buildSchema($schema);
        $main = new FooTestTablePrefixSameDatabaseMain();
        $main->setSubtitle('bar');
        $delegate = $main->getFooTestTablePrefixSameDatabaseDelegate();
        $this->assertInstanceOf('FooTestTablePrefixSameDatabaseDelegate', $delegate);
        $this->assertTrue($delegate->isNew());
        $this->assertEquals('bar', $delegate->getSubtitle());
        $this->assertEquals('bar', $main->getSubtitle());
    }
    public function setUp()
    {
        if (!class_exists('VersionableBehaviorTest1')) {
            $schema = <<<EOF
<database name="versionable_behavior_test_1">
\t<table name="versionable_behavior_test_1">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="bar" type="INTEGER" />
\t\t<behavior name="versionable" />
\t</table>
\t<table name="versionable_behavior_test_2">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="bar" type="INTEGER" />
\t\t<behavior name="versionable">
\t\t\t<parameter name="version_column" value="foo_ver" />
\t\t</behavior>
\t</table>
\t<table name="versionable_behavior_test_3">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="bar" type="INTEGER" />
\t\t<behavior name="versionable">
\t\t\t<parameter name="version_table" value="foo_ver" />
\t\t</behavior>
\t</table>
\t<table name="versionable_behavior_test_4">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="bar" type="INTEGER" />
\t\t<behavior name="versionable">
\t\t\t<parameter name="log_created_at" value="true" />
\t\t\t<parameter name="log_created_by" value="true" />
\t\t\t<parameter name="log_comment" value="true" />
\t\t</behavior>
\t</table>
\t<table name="versionable_behavior_test_5">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="foo" type="VARCHAR" size="100" />
\t\t<column name="foreign_id" type="INTEGER" />
\t\t<foreign-key foreignTable="versionable_behavior_test_4">
\t\t\t<reference local="foreign_id" foreign="id" />
\t\t</foreign-key>
\t\t<behavior name="versionable" />
\t</table>

</database>
EOF;
            PropelQuickBuilder::buildSchema($schema);
        }
        if (!class_exists('VersionableBehaviorTest6')) {
            $schema2 = <<<EOF
<database name="versionable_behavior_test_2" defaultPhpNamingMethod="nochange">
\t<table name="VersionableBehaviorTest6">
\t\t<column name="Id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="FooBar" type="VARCHAR" size="100" />
\t\t<behavior name="versionable">
\t\t\t<parameter name="log_created_at" value="true" />
\t\t\t<parameter name="log_created_by" value="true" />
\t\t\t<parameter name="log_comment" value="true" />
\t\t</behavior>
\t</table>

\t<table name="VersionableBehaviorTest7">
\t\t<column name="Id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="FooBar" type="VARCHAR" size="100" />

\t\t<column name="Style" type="ENUM" valueSet="novel, essay, poetry" />

\t\t<behavior name="versionable">
\t\t\t<parameter name="log_created_at" value="true" />
\t\t\t<parameter name="log_created_by" value="true" />
\t\t\t<parameter name="log_comment" value="true" />

\t\t\t<parameter name="version_created_by_column" value="VersionCreatedBy" />
\t\t\t<parameter name="version_created_at_column" value="VersionCreatedAt" />
\t\t\t<parameter name="version_comment_column" value="MyComment" />
\t\t</behavior>
\t</table>
EOF;
            PropelQuickBuilder::buildSchema($schema2);
        }
    }