public function testTable() { $b = new Behavior(); $this->assertNull($b->getTable(), 'Behavior Table is null by default'); $t = new Table(); $t->setCommonName('fooTable'); $b->setTable($t); $this->assertEquals($b->getTable(), $t, 'setTable() sets the name, and getTable() gets it'); }
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)); }
public function testQualifiedName() { $table = new Table(); $table->setSchema("foo"); $table->setCommonName("bar"); $this->assertEquals($table->getName(), "bar"); $this->assertEquals($table->getCommonName(), "bar"); $database = new Database(); $database->addTable($table); $database->setPlatform(new NoSchemaPlatform()); $this->assertEquals($table->getName(), "bar"); $database->setPlatform(new SchemaPlatform()); $this->assertEquals($table->getName(), "foo.bar"); }