public function modifyTable()
 {
     $parentTable = $this->getParentTable();
     if (count($parentTable->getPrimaryKey()) > 1) {
         throw new RuntimeException('Equal nest works only with a single primary key for the parent table');
     }
     $parentTablePrimaryKey = $parentTable->getPrimaryKey();
     if (!$this->getTable()->hasColumn($this->getReferenceColumn1Name())) {
         $this->getTable()->addColumn(array('name' => $this->getReferenceColumn1Name(), 'primaryKey' => 'true', 'type' => $parentTablePrimaryKey[0]->getType()));
         $fk = new ForeignKey();
         $fk->setName($this->getReferenceColumn1Name());
         $fk->setForeignTableCommonName($this->getParentTable()->getCommonName());
         $fk->setOnDelete(ForeignKey::CASCADE);
         $fk->setOnUpdate(null);
         $fk->addReference($this->getReferenceColumn1Name(), $parentTablePrimaryKey[0]->getName());
         $this->getTable()->addForeignKey($fk);
     }
     if (!$this->getTable()->hasColumn($this->getReferenceColumn2Name())) {
         $this->getTable()->addColumn(array('name' => $this->getReferenceColumn2Name(), 'primaryKey' => 'true', 'type' => $parentTablePrimaryKey[0]->getType()));
         $fk = new ForeignKey();
         $fk->setName($this->getReferenceColumn2Name());
         $fk->setForeignTableCommonName($this->getParentTable()->getCommonName());
         $fk->setOnDelete(ForeignKey::CASCADE);
         $fk->setOnUpdate(null);
         $fk->addReference($this->getReferenceColumn2Name(), $parentTablePrimaryKey[0]->getName());
         $this->getTable()->addForeignKey($fk);
     }
     if (!$parentTable->hasBehavior('equal_nest_parent')) {
         $parentBehavior = new EqualNestParentBehavior();
         $parentBehavior->setName('equal_nest_parent');
         $parentBehavior->addParameter(array('name' => 'middle_table', 'value' => $this->getTable()->getName()));
         $parentTable->addBehavior($parentBehavior);
     }
     $this->parentBehavior = $parentTable->getBehavior('equal_nest_parent');
 }
 public function testColumnIsFKAndPK()
 {
     $column = new Column();
     $column->setName('id');
     $column->setPrimaryKey(true);
     $column->setAutoIncrement(true);
     $column->setType('integer');
     $table = new Table();
     $table->setCommonName('table_one');
     $table->addColumn($column);
     $db = new Database();
     $db->setName('MultipleTables');
     $db->addTable($table);
     $column = new Column();
     $column->setName('id');
     $column->setPrimaryKey(true);
     $column->setAutoIncrement(true);
     $column->setType('integer');
     $c2 = new Column();
     $c2->setPrimaryKey(true);
     $c2->setName('foreign_id');
     $c2->setType('integer');
     $table = new Table();
     $table->setCommonName('table_two');
     $table->addColumn($column);
     $table->addColumn($c2);
     $fk = new ForeignKey();
     $fk->setName('FK_1');
     $fk->addReference('foreign_id', 'id');
     $fk->setForeignTableCommonName('table_one');
     $table->addForeignKey($fk);
     $db->addTable($table);
     $expected = implode("\n", array('digraph G {', 'nodetable_one [label="{<table>table_one|<cols>id (integer) [PK]\\l}", shape=record];', 'nodetable_two [label="{<table>table_two|<cols>id (integer) [PK]\\lforeign_id (integer) [FK] [PK]\\l}", shape=record];', 'nodetable_two:cols -> nodetable_one:table [label="foreign_id=id"];', '}', ''));
     $this->assertEquals($expected, PropelDotGenerator::create($db));
 }