[2.0] DDC-407 - Add regression-test to fix that Scalar-Results are 1-based, Add ScalarResult with Scalar Field Hydration Test
This commit is contained in:
parent
46e7724988
commit
9d2c275618
2 changed files with 37 additions and 0 deletions
|
@ -39,6 +39,19 @@ class AdvancedDqlQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||||
$this->assertEquals(600000, $result[1]['avgSalary']);
|
$this->assertEquals(600000, $result[1]['avgSalary']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testUnnamedScalarResultsAreOneBased()
|
||||||
|
{
|
||||||
|
$dql = 'SELECT p.department, AVG(p.salary) '.
|
||||||
|
'FROM Doctrine\Tests\Models\Company\CompanyEmployee p '.
|
||||||
|
'GROUP BY p.department HAVING SUM(p.salary) > 200000 ORDER BY p.department';
|
||||||
|
|
||||||
|
$result = $this->_em->createQuery($dql)->getScalarResult();
|
||||||
|
|
||||||
|
$this->assertEquals(2, count($result));
|
||||||
|
$this->assertEquals(150000, $result[0][1]);
|
||||||
|
$this->assertEquals(600000, $result[1][1]);
|
||||||
|
}
|
||||||
|
|
||||||
public function testOrderByResultVariableCollectionSize()
|
public function testOrderByResultVariableCollectionSize()
|
||||||
{
|
{
|
||||||
$dql = 'SELECT p.name, size(p.friends) AS friends ' .
|
$dql = 'SELECT p.name, size(p.friends) AS friends ' .
|
||||||
|
|
|
@ -44,4 +44,28 @@ class ScalarHydratorTest extends HydrationTestCase
|
||||||
$this->assertEquals('jwage', $result[1]['u_name']);
|
$this->assertEquals('jwage', $result[1]['u_name']);
|
||||||
$this->assertEquals(2, $result[1]['u_id']);
|
$this->assertEquals(2, $result[1]['u_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-407
|
||||||
|
*/
|
||||||
|
public function testHydrateScalarResults()
|
||||||
|
{
|
||||||
|
$rsm = new ResultSetMapping();
|
||||||
|
$rsm->addScalarResult('foo1', 'foo');
|
||||||
|
$rsm->addScalarResult('bar2', 'bar');
|
||||||
|
$rsm->addScalarResult('baz3', 'baz');
|
||||||
|
|
||||||
|
$resultSet = array(
|
||||||
|
array(
|
||||||
|
'foo1' => 'A',
|
||||||
|
'bar2' => 'B',
|
||||||
|
'baz3' => 'C',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$stmt = new HydratorMockStatement($resultSet);
|
||||||
|
$hydrator = new \Doctrine\ORM\Internal\Hydration\ScalarHydrator($this->_em);
|
||||||
|
|
||||||
|
$result = $hydrator->hydrateAll($stmt, $rsm);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue