From 8aef340dd1405fc74da3f918e77263004aa107f6 Mon Sep 17 00:00:00 2001 From: Alexandre Quercia Date: Tue, 16 Apr 2024 08:21:44 +0200 Subject: [PATCH] fixup! fix: add failing test when aliasing a column of a joined relation --- tests/Ticket/GH134TestCase.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/Ticket/GH134TestCase.php b/tests/Ticket/GH134TestCase.php index aba64651..ac98bdef 100644 --- a/tests/Ticket/GH134TestCase.php +++ b/tests/Ticket/GH134TestCase.php @@ -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() @@ -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(); @@ -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); } }