Skip to content

Commit

Permalink
Fixed ZF2-66
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioBatSilva committed Nov 20, 2011
1 parent 0a759f4 commit 59ca126
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions library/Zend/Db/Table/AbstractTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ public function setReferences(array $referenceMap)
public function getReference($tableClassname, $ruleKey = null)
{
$thisClass = get_class($this);
$tableClassname = '\\' . ltrim($tableClassname, '\\');
if ($thisClass === 'Zend\Db\Table\Table') {
$thisClass = $this->_definitionConfigName;
}
Expand Down
43 changes: 43 additions & 0 deletions tests/Zend/Db/Table/Table/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,49 @@ public function testTableAndIdentityWithVeryLongName()
$this->assertEquals(1, count($rowset));
$this->_util->dropTable('thisisaveryverylongtablename');
}


/**
* @group ZF2-66
*/
public function testgetReferenceWihoutSlashAtTheBeginning()
{
$refReporter = array(
'columns' => array('reported_by'),
'refTableClass' => '\ZendTest\Db\Table\TestAsset\TableAccounts',
'refColumns' => array('account_id')
);
$refEngineer = array(
'columns' => array('assigned_to'),
'refTableClass' => '\ZendTest\Db\Table\TestAsset\TableAccounts',
'refColumns' => array('account_id')
);
$refMap = array(
'Reporter' => $refReporter,
'Engineer' => $refEngineer
);
$table = $this->_getTable('\ZendTest\Db\Table\TestAsset\TableBugs',array('referenceMap' => $refMap));

$this->assertEquals($refReporter, $table->getReference('ZendTest\Db\Table\TestAsset\TableAccounts'));
$this->assertEquals($refReporter, $table->getReference('ZendTest\Db\Table\TestAsset\TableAccounts', 'Reporter'));
$this->assertEquals($refEngineer, $table->getReference('ZendTest\Db\Table\TestAsset\TableAccounts', 'Engineer'));

$this->assertEquals(
$table->getReference('\ZendTest\Db\Table\TestAsset\TableAccounts'),
$table->getReference('ZendTest\Db\Table\TestAsset\TableAccounts')
);

$this->assertEquals(
$table->getReference('\ZendTest\Db\Table\TestAsset\TableAccounts', 'Reporter'),
$table->getReference('ZendTest\Db\Table\TestAsset\TableAccounts', 'Reporter')
);

$this->assertEquals(
$table->getReference('\ZendTest\Db\Table\TestAsset\TableAccounts', 'Engineer'),
$table->getReference('ZendTest\Db\Table\TestAsset\TableAccounts', 'Engineer')
);
}


protected function _getRowForTableAndIdentityWithVeryLongName()
{
Expand Down

0 comments on commit 59ca126

Please sign in to comment.