Commit 9d2c2756 authored by beberlei's avatar beberlei

[2.0] DDC-407 - Add regression-test to fix that Scalar-Results are 1-based,...

[2.0] DDC-407 - Add regression-test to fix that Scalar-Results are 1-based, Add ScalarResult with Scalar Field Hydration Test
parent 46e77249
......@@ -39,6 +39,19 @@ class AdvancedDqlQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$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()
{
$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(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);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment