public function testCompareSeveralRenamedSamePrimaryKeys()
 {
     $t1 = new Table();
     $c1 = new Column('col1');
     $c1->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c1->setNotNull(true);
     $c1->setPrimaryKey(true);
     $t1->addColumn($c1);
     $c2 = new Column('col2');
     $c2->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c2->setNotNull(true);
     $c2->setPrimaryKey(true);
     $t1->addColumn($c2);
     $c3 = new Column('col3');
     $c3->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c3->setNotNull(true);
     $c3->setPrimaryKey(true);
     $t1->addColumn($c3);
     $t2 = new Table();
     $c4 = new Column('col4');
     $c4->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c4->setNotNull(true);
     $c4->setPrimaryKey(true);
     $t2->addColumn($c4);
     $c5 = new Column('col5');
     $c5->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c5->setNotNull(true);
     $c5->setPrimaryKey(true);
     $t2->addColumn($c5);
     $c6 = new Column('col3');
     $c6->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c6->setNotNull(true);
     $c6->setPrimaryKey(true);
     $t2->addColumn($c6);
     // col1 and col2 were renamed
     $tc = new PropelTableComparator();
     $tc->setFromTable($t1);
     $tc->setToTable($t2);
     $nbDiffs = $tc->comparePrimaryKeys();
     $tableDiff = $tc->getTableDiff();
     $this->assertEquals(2, $nbDiffs);
     $this->assertEquals(array(array($c1, $c4), array($c2, $c5)), $tableDiff->getRenamedPkColumns());
     $this->assertEquals(array(), $tableDiff->getAddedPkColumns());
     $this->assertEquals(array(), $tableDiff->getRemovedPkColumns());
 }
 public function testCompareSeveralPrimaryKeyDifferences()
 {
     $t1 = new Table();
     $c1 = new Column('col1');
     $c1->getDomain()->copy($this->platform->getDomainForType('VARCHAR'));
     $c1->getDomain()->replaceSize(255);
     $c1->setNotNull(false);
     $t1->addColumn($c1);
     $c2 = new Column('col2');
     $c2->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c2->setNotNull(true);
     $c2->setPrimaryKey(true);
     $t1->addColumn($c2);
     $c3 = new Column('col3');
     $c3->getDomain()->copy($this->platform->getDomainForType('VARCHAR'));
     $c3->getDomain()->replaceSize(255);
     $c3->setPrimaryKey(true);
     $t1->addColumn($c3);
     $t2 = new Table();
     $c4 = new Column('col1');
     $c4->getDomain()->copy($this->platform->getDomainForType('DOUBLE'));
     $c4->getDomain()->replaceScale(2);
     $c4->getDomain()->replaceSize(3);
     $c4->setNotNull(true);
     $c4->getDomain()->setDefaultValue(new ColumnDefaultValue(123, ColumnDefaultValue::TYPE_VALUE));
     $t2->addColumn($c4);
     $c5 = new Column('col22');
     $c5->getDomain()->copy($this->platform->getDomainForType('INTEGER'));
     $c5->setNotNull(true);
     $c5->setPrimaryKey(true);
     $t2->addColumn($c5);
     $c6 = new Column('col4');
     $c6->getDomain()->copy($this->platform->getDomainForType('LONGVARCHAR'));
     $c6->getDomain()->setDefaultValue(new ColumnDefaultValue('123', ColumnDefaultValue::TYPE_VALUE));
     $c6->setPrimaryKey(true);
     $t2->addColumn($c6);
     // col2 was renamed, col3 was removed, col4 was added
     $tc = new PropelTableComparator();
     $tc->setFromTable($t1);
     $tc->setToTable($t2);
     $nbDiffs = $tc->comparePrimaryKeys();
     $tableDiff = $tc->getTableDiff();
     $this->assertEquals(3, $nbDiffs);
     $this->assertEquals(array(array($c2, $c5)), $tableDiff->getRenamedPkColumns());
     $this->assertEquals(array('col4' => $c6), $tableDiff->getAddedPkColumns());
     $this->assertEquals(array('col3' => $c3), $tableDiff->getRemovedPkColumns());
 }
    public function providerForTestGetModifyTablePrimaryKeysDDL()
    {
        $schema1 = <<<EOF
<database name="test">
\t<table name="foo">
\t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
\t\t<column name="bar" type="INTEGER" />
\t\t<column name="baz" type="VARCHAR" size="12" required="true" />
\t</table>
</database>
EOF;
        $schema2 = <<<EOF
<database name="test">
\t<table name="foo">
\t\t<column name="id" primaryKey="true" type="INTEGER" />
\t\t<column name="bar" type="INTEGER" primaryKey="true" />
\t\t<column name="baz" type="VARCHAR" size="12" required="false" />
\t</table>
</database>
EOF;
        $t1 = $this->getDatabaseFromSchema($schema1)->getTable('foo');
        $t2 = $this->getDatabaseFromSchema($schema2)->getTable('foo');
        $tc = new PropelTableComparator();
        $tc->setFromTable($t1);
        $tc->setToTable($t2);
        $tc->comparePrimaryKeys();
        return array(array($tc->getTableDiff()));
    }