From 7f0cf6c70ccc340b645c7670d250061c266c864f Mon Sep 17 00:00:00 2001 From: Alexandre Quercia Date: Tue, 16 Apr 2024 21:40:54 +0200 Subject: [PATCH] fixup! Add test to characterize previous behaviour and avoid regression --- tests/Ticket/585bTestCase.php | 59 ---------------------------------- tests/Ticket/GH134TestCase.php | 36 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 59 deletions(-) delete mode 100644 tests/Ticket/585bTestCase.php diff --git a/tests/Ticket/585bTestCase.php b/tests/Ticket/585bTestCase.php deleted file mode 100644 index 56a37a7f..00000000 --- a/tests/Ticket/585bTestCase.php +++ /dev/null @@ -1,59 +0,0 @@ -. - */ - -class Doctrine_Ticket_585b_TestCase extends Doctrine_UnitTestCase -{ - private function doTestAliasWithSameNameAsIdentifiers($hydrateType, $checkArrayIndex) - { - $query = Doctrine_Query::create() - ->select('99 as id, u.id as aliasId') - ->from('User u') - ; - - $results = $query->execute(array(), $hydrateType); - - $this->assertEqual(99, $results[0][$checkArrayIndex]); - } - - public function test_hydrateScalar_aliasWithSameNameAsIdentifiers_thenResultsHasAllRecords() - { - $hydrateType = Doctrine_Core::HYDRATE_SCALAR; - $checkArrayIndex = 'u_id'; - - $this->doTestAliasWithSameNameAsIdentifiers($hydrateType, $checkArrayIndex); - } - - public function test_hydrateArrayShallow_aliasWithSameNameAsIdentifiers_thenResultsHasAllRecords() - { - $hydrateType = Doctrine_Core::HYDRATE_ARRAY_SHALLOW; - $checkArrayIndex = 'id'; - - $this->doTestAliasWithSameNameAsIdentifiers($hydrateType, $checkArrayIndex); - } - - public function test_hydrateArray_aliasWithSameNameAsIdentifiers_thenResultsHasAllRecords() - { - $hydrateType = Doctrine_Core::HYDRATE_ARRAY; - $checkArrayIndex = 'id'; - - $this->doTestAliasWithSameNameAsIdentifiers($hydrateType, $checkArrayIndex); - } -} diff --git a/tests/Ticket/GH134TestCase.php b/tests/Ticket/GH134TestCase.php index 3fde0ef0..21eff8f7 100644 --- a/tests/Ticket/GH134TestCase.php +++ b/tests/Ticket/GH134TestCase.php @@ -74,4 +74,40 @@ public function test_hydrateScalar_identifierOfRelations() $this->assertEqual($expected, $results[0]); $this->assertEqual(count($this->users), count($results)); } + + private function doTestAliasWithSameNameAsIdentifiers($hydrateType, $checkArrayIndex) + { + $query = Doctrine_Query::create() + ->select('99 as id, u.id as aliasId') + ->from('User u') + ; + + $results = $query->execute(array(), $hydrateType); + + $this->assertEqual(99, $results[0][$checkArrayIndex]); + } + + public function test_hydrateScalar_aliasWithSameNameAsIdentifiers_willKeepOverwriteIdentifierByAlias() + { + $hydrateType = Doctrine_Core::HYDRATE_SCALAR; + $checkArrayIndex = 'u_id'; + + $this->doTestAliasWithSameNameAsIdentifiers($hydrateType, $checkArrayIndex); + } + + public function test_hydrateArrayShallow_aliasWithSameNameAsIdentifiers_willKeepOverwriteIdentifierByAlias() + { + $hydrateType = Doctrine_Core::HYDRATE_ARRAY_SHALLOW; + $checkArrayIndex = 'id'; + + $this->doTestAliasWithSameNameAsIdentifiers($hydrateType, $checkArrayIndex); + } + + public function test_hydrateArray_aliasWithSameNameAsIdentifiers_willKeepOverwriteIdentifierByAlias() + { + $hydrateType = Doctrine_Core::HYDRATE_ARRAY; + $checkArrayIndex = 'id'; + + $this->doTestAliasWithSameNameAsIdentifiers($hydrateType, $checkArrayIndex); + } }