Skip to content

Concrete Inheritance with Versionable Issue #626

Open
jakerella opened this Issue Mar 8, 2013 · 0 comments

1 participant

@jakerella

Hola folks, I'm trying to figure out an issue posted on SO. I have a basic test set up, and the SQL generated looks good, but when I try to build the schema using the PropelQuickBuilder the test bombs without any failure notice.

I put this code in VersionableBehaviorTest.php:

// at the top...
require_once dirname(__FILE__) . '/../../../../../generator/lib/behavior/concrete_inheritance/ConcreteInheritanceBehavior.php';
...
    // at the bottom...
    public function providerForTestVersioningWithConcreteInheritance()
    {
        $schema = <<<EOF
<database name="versionable_behavior_test_1">
    <table name="versionable_behavior_test_2">
        <column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
        <column name="bar" type="INTEGER" />

        <behavior name="versionable" />
    </table>

    <table name="versionable_behavior_test_3">
        <column name="bat" type="INTEGER" />
        <behavior name="concrete_inheritance">
            <parameter name="extends" value="versionable_behavior_test_2" />
        </behavior>
    </table>
</database>
EOF;

        return array(array($schema));
    }

    /**
     * THIS TEST WORKS!
     * @dataProvider providerForTestVersioningWithConcreteInheritance
     */
    public function testVersioningWithConcreteInheritance($schema)
    {
        $builder = new PropelQuickBuilder();
        $builder->setSchema($schema);

        $expected2 = <<<EOF
-----------------------------------------------------------------------
-- versionable_behavior_test_2_version
-----------------------------------------------------------------------

DROP TABLE IF EXISTS [versionable_behavior_test_2_version];

CREATE TABLE [versionable_behavior_test_2_version]
(
    [id] INTEGER NOT NULL,
    [bar] INTEGER,
    [descendant_class] VARCHAR(100),
    [version] INTEGER DEFAULT 0 NOT NULL,
    PRIMARY KEY ([id],[version])
);

-- SQLite does not support foreign keys; this is just for reference
-- FOREIGN KEY ([id]) REFERENCES versionable_behavior_test_2 ([id])
EOF;

        $expected3 = <<<EOF
-----------------------------------------------------------------------
-- versionable_behavior_test_3_version
-----------------------------------------------------------------------

DROP TABLE IF EXISTS [versionable_behavior_test_3_version];

CREATE TABLE [versionable_behavior_test_3_version]
(
    [bat] INTEGER,
    [id] INTEGER NOT NULL,
    [bar] INTEGER,
    [version] INTEGER DEFAULT 0 NOT NULL,
    [id_version] INTEGER DEFAULT 0,
    PRIMARY KEY ([id],[version])
);

-- SQLite does not support foreign keys; this is just for reference
-- FOREIGN KEY ([id]) REFERENCES versionable_behavior_test_3 ([id])
EOF;

        $sql = $builder->getSQL();
        $this->assertContains($expected2, $sql);
        $this->assertContains($expected3, $sql);
    }

    /**
     * THIS TEST CRASHES THE EXECUTION!
     * @dataProvider providerForTestVersioningWithConcreteInheritance
     */
    public function testVersioningWithConcreteInheritanceAndFKBuild($schema)
    {
        // This line crashes the test
        PropelQuickBuilder::buildSchema($schema);
        // we never get here
        $this->assertTrue(true);
    }

Output when I run just this test file:

~$ phpunit test/testsuite/generator/behavior/versionable/VersionableBehaviorTest.php 
PHPUnit 3.7.10 by Sebastian Bergmann.

Configuration read from /var/www/propel1.x/Propel/phpunit.xml.dist

............~$

I have narrowed things down to the application of the Versionable behaviors "objectMethods" getter, but my eyes are too tired to continue, and I haven't been able to figure out anything useful.

Last thing I found was that line 540 of OMBuilder was failing when the args to that method are "objectMethods" and "ObjectBuilderModifier" on the "versionable" behavior iteration of that loop.

Anyone have any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.