Ejemplo n.º 1
0
 public function testGetConstraintKeys()
 {
     $refProp = new \ReflectionProperty($this->abstractSourceMock, 'data');
     $refProp->setAccessible(true);
     // internal data
     $data = array('constraint_references' => array('foo_schema' => array(array('constraint_name' => 'bam_constraint', 'update_rule' => 'UP', 'delete_rule' => 'DOWN', 'referenced_table_name' => 'another_table', 'referenced_column_name' => 'another_column'))), 'constraint_keys' => array('foo_schema' => array(array('table_name' => 'bar_table', 'constraint_name' => 'bam_constraint', 'column_name' => 'a', 'ordinal_position' => 1))));
     $refProp->setValue($this->abstractSourceMock, $data);
     $constraints = $this->abstractSourceMock->getConstraintKeys('bam_constraint', 'bar_table', 'foo_schema');
     $this->assertCount(1, $constraints);
     /**
      * @var \Zend\Db\Metadata\Object\ConstraintKeyObject $constraintKeyObj
      */
     $constraintKeyObj = $constraints[0];
     $this->assertInstanceOf('Zend\\Db\\Metadata\\Object\\ConstraintKeyObject', $constraintKeyObj);
     // check value object is mapped correctly
     $this->assertEquals('a', $constraintKeyObj->getColumnName());
     $this->assertEquals(1, $constraintKeyObj->getOrdinalPosition());
     $this->assertEquals('another_table', $constraintKeyObj->getReferencedTableName());
     $this->assertEquals('another_column', $constraintKeyObj->getReferencedColumnName());
     $this->assertEquals('UP', $constraintKeyObj->getForeignKeyUpdateRule());
     $this->assertEquals('DOWN', $constraintKeyObj->getForeignKeyDeleteRule());
 }