public function testAddRelation() { $this->schema->addTable('somewhere', array('id' => array('type' => 'integer'))); $this->schema->addTable('somewhat', array('id' => array('type' => 'integer'))); $relation = array('owningTable' => 'somewhere', 'owningField' => 'id', 'owningAlias' => 'Somewhat', 'refTable' => 'somewhat', 'refAlias' => 'Somewhere', 'refField' => 'id', 'type' => Relation::ONE_TO_ONE); $this->schema->addTableRelation('somewhere', 'id', $relation); $tableRelations = $this->schema->getTableRelations('somewhere'); $expected = array('owning' => array('somewhere.id'), 'referenced' => array()); $actual = array('owning' => array_keys($tableRelations['owning']), 'referenced' => array_keys($tableRelations['referenced'])); $this->assertEquals($expected, $actual); $tableRelations = $this->schema->getTableRelations('somewhat'); $expected = array('owning' => array(), 'referenced' => array('somewhere.id')); $actual = array('owning' => array_keys($tableRelations['owning']), 'referenced' => array_keys($tableRelations['referenced'])); $this->assertEquals($expected, $actual); }