Skip to content

Commit

Permalink
fixup! fix: add failing test when aliasing a column of a joined relation
Browse files Browse the repository at this point in the history
  • Loading branch information
alquerci committed Apr 16, 2024
1 parent c61998f commit 8aef340
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/Ticket/GH134TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Doctrine_Ticket_GH134_TestCase extends Doctrine_UnitTestCase
{
private function doTestWithAllColumnsAliased($hydrateType, $expectedKeys)
private function doTestWithAllColumnsAliased($hydrateType, $expectedKeys, $expectedRelationKeys = null)
{
try {
$query = Doctrine_Query::create()
Expand All @@ -17,6 +17,11 @@ private function doTestWithAllColumnsAliased($hydrateType, $expectedKeys)

$this->assertEqual($expectedSql, $query->getSqlQuery());
$this->assertEqual($expectedKeys, array_keys($results[0]));
if (null !== $expectedRelationKeys) {
foreach ($expectedRelationKeys as $relationName => $relationKeys) {
$this->assertEqual($relationKeys, array_keys($results[0][$relationName]));
}
}
$this->assertEqual(count($this->users), count($results));

$this->pass();
Expand Down Expand Up @@ -45,7 +50,10 @@ public function test_hydrateArray_withAllColumnsAliased_thenResultsHasAllRecords
{
$hydrateType = Doctrine_Core::HYDRATE_ARRAY;
$expectedKeys = array('id', 'aliasAddress', 'Email');
$expectedRelationKeys = array(
'Email' => array('id', 'aliasAddress'),
);

$this->doTestWithAllColumnsAliased($hydrateType, $expectedKeys);
$this->doTestWithAllColumnsAliased($hydrateType, $expectedKeys, $expectedRelationKeys);
}
}

0 comments on commit 8aef340

Please sign in to comment.