Skip to content

Commit

Permalink
fixup! Add test to characterize previous behaviour and avoid regression
Browse files Browse the repository at this point in the history
  • Loading branch information
alquerci committed Apr 16, 2024
1 parent 3cf3894 commit 7f0cf6c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 59 deletions.
59 changes: 0 additions & 59 deletions tests/Ticket/585bTestCase.php

This file was deleted.

36 changes: 36 additions & 0 deletions tests/Ticket/GH134TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 7f0cf6c

Please sign in to comment.