2009-01-14 00:56:43 +03:00
|
|
|
<?php
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
namespace Doctrine\Tests\ORM\Hydration;
|
|
|
|
|
|
|
|
use Doctrine\Tests\Mocks\HydratorMockStatement;
|
|
|
|
|
2009-01-24 19:56:44 +03:00
|
|
|
require_once __DIR__ . '/../../TestInit.php';
|
2009-01-14 00:56:43 +03:00
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
class ObjectHydratorTest extends HydrationTest
|
2009-01-14 00:56:43 +03:00
|
|
|
{
|
|
|
|
/**
|
2009-01-22 22:38:10 +03:00
|
|
|
* Select u.id, u.name from \Doctrine\Tests\Models\CMS\CmsUser u
|
2009-01-14 00:56:43 +03:00
|
|
|
*/
|
|
|
|
public function testNewHydrationSimpleEntityQuery()
|
|
|
|
{
|
|
|
|
// Faked query components
|
|
|
|
$queryComponents = array(
|
|
|
|
'u' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => null,
|
|
|
|
'relation' => null,
|
|
|
|
'map' => null
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Faked table alias map
|
|
|
|
$tableAliasMap = array(
|
|
|
|
'u' => 'u'
|
|
|
|
);
|
|
|
|
|
|
|
|
// Faked result set
|
|
|
|
$resultSet = array(
|
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__name' => 'romanb'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '2',
|
|
|
|
'u__name' => 'jwage'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
$stmt = new HydratorMockStatement($resultSet);
|
|
|
|
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
$result = $hydrator->hydrateAll($stmt, $this->_createParserResult(
|
2009-01-15 16:30:44 +03:00
|
|
|
$queryComponents, $tableAliasMap));
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
$this->assertEquals(2, count($result));
|
2009-01-22 22:38:10 +03:00
|
|
|
$this->assertTrue($result[0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
|
|
|
|
$this->assertTrue($result[1] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
|
2009-01-14 00:56:43 +03:00
|
|
|
$this->assertEquals(1, $result[0]->id);
|
|
|
|
$this->assertEquals('romanb', $result[0]->name);
|
|
|
|
$this->assertEquals(2, $result[1]->id);
|
|
|
|
$this->assertEquals('jwage', $result[1]->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* select u.id, u.status, p.phonenumber, upper(u.name) nameUpper from User u
|
|
|
|
* join u.phonenumbers p
|
|
|
|
* =
|
|
|
|
* select u.id, u.status, p.phonenumber, upper(u.name) as u__0 from USERS u
|
|
|
|
* INNER JOIN PHONENUMBERS p ON u.id = p.user_id
|
|
|
|
*/
|
|
|
|
public function testNewHydrationMixedQueryFetchJoin()
|
|
|
|
{
|
|
|
|
// Faked query components
|
|
|
|
$queryComponents = array(
|
|
|
|
'u' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => null,
|
|
|
|
'relation' => null,
|
2009-04-03 15:06:58 +04:00
|
|
|
'map' => null
|
2009-01-14 00:56:43 +03:00
|
|
|
),
|
|
|
|
'p' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => 'u',
|
2009-01-22 22:38:10 +03:00
|
|
|
'relation' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('phonenumbers'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'map' => null
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Faked table alias map
|
|
|
|
$tableAliasMap = array(
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn' => 'dctrn',
|
2009-01-14 00:56:43 +03:00
|
|
|
'u' => 'u',
|
|
|
|
'p' => 'p'
|
|
|
|
);
|
|
|
|
|
|
|
|
// Faked result set
|
|
|
|
$resultSet = array(
|
|
|
|
//row1
|
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'ROMANB',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '42',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'ROMANB',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '43',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '2',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'JWAGE',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '91'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
$stmt = new HydratorMockStatement($resultSet);
|
|
|
|
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
$result = $hydrator->hydrateAll($stmt, $this->_createParserResult(
|
2009-01-15 16:30:44 +03:00
|
|
|
$queryComponents, $tableAliasMap, true));
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
$this->assertEquals(2, count($result));
|
|
|
|
$this->assertTrue(is_array($result));
|
|
|
|
$this->assertTrue(is_array($result[0]));
|
|
|
|
$this->assertTrue(is_array($result[1]));
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
$this->assertTrue($result[0][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
|
2009-02-02 14:55:50 +03:00
|
|
|
$this->assertTrue($result[0][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
|
2009-01-22 22:38:10 +03:00
|
|
|
$this->assertTrue($result[0][0]->phonenumbers[0] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber);
|
|
|
|
$this->assertTrue($result[0][0]->phonenumbers[1] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber);
|
|
|
|
$this->assertTrue($result[1][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
|
2009-02-02 14:55:50 +03:00
|
|
|
$this->assertTrue($result[1][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
// first user => 2 phonenumbers
|
|
|
|
$this->assertEquals(2, count($result[0][0]->phonenumbers));
|
|
|
|
$this->assertEquals('ROMANB', $result[0]['nameUpper']);
|
|
|
|
// second user => 1 phonenumber
|
|
|
|
$this->assertEquals(1, count($result[1][0]->phonenumbers));
|
|
|
|
$this->assertEquals('JWAGE', $result[1]['nameUpper']);
|
|
|
|
|
|
|
|
$this->assertEquals(42, $result[0][0]->phonenumbers[0]->phonenumber);
|
|
|
|
$this->assertEquals(43, $result[0][0]->phonenumbers[1]->phonenumber);
|
|
|
|
$this->assertEquals(91, $result[1][0]->phonenumbers[0]->phonenumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* select u.id, u.status, count(p.phonenumber) numPhones from User u
|
|
|
|
* join u.phonenumbers p group by u.status, u.id
|
|
|
|
* =
|
|
|
|
* select u.id, u.status, count(p.phonenumber) as p__0 from USERS u
|
|
|
|
* INNER JOIN PHONENUMBERS p ON u.id = p.user_id group by u.id, u.status
|
|
|
|
*/
|
|
|
|
public function testNewHydrationMixedQueryNormalJoin()
|
|
|
|
{
|
|
|
|
// Faked query components
|
|
|
|
$queryComponents = array(
|
|
|
|
'u' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => null,
|
|
|
|
'relation' => null,
|
|
|
|
'map' => null
|
|
|
|
),
|
|
|
|
'p' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => 'u',
|
2009-01-22 22:38:10 +03:00
|
|
|
'relation' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('phonenumbers'),
|
2009-04-03 15:06:58 +04:00
|
|
|
'map' => null
|
2009-01-14 00:56:43 +03:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Faked table alias map
|
|
|
|
$tableAliasMap = array(
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn' => 'dctrn',
|
2009-01-14 00:56:43 +03:00
|
|
|
'u' => 'u',
|
|
|
|
'p' => 'p'
|
|
|
|
);
|
|
|
|
|
|
|
|
// Faked result set
|
|
|
|
$resultSet = array(
|
|
|
|
//row1
|
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__numPhones' => '2',
|
2009-01-14 00:56:43 +03:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '2',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__numPhones' => '1',
|
2009-01-14 00:56:43 +03:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
$stmt = new HydratorMockStatement($resultSet);
|
|
|
|
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
$result = $hydrator->hydrateAll($stmt, $this->_createParserResult(
|
2009-01-15 16:30:44 +03:00
|
|
|
$queryComponents, $tableAliasMap, true));
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
$this->assertEquals(2, count($result));
|
|
|
|
$this->assertTrue(is_array($result));
|
|
|
|
$this->assertTrue(is_array($result[0]));
|
|
|
|
$this->assertTrue(is_array($result[1]));
|
|
|
|
// first user => 2 phonenumbers
|
|
|
|
$this->assertEquals(2, $result[0]['numPhones']);
|
|
|
|
// second user => 1 phonenumber
|
|
|
|
$this->assertEquals(1, $result[1]['numPhones']);
|
2009-01-22 22:38:10 +03:00
|
|
|
$this->assertTrue($result[0][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
|
|
|
|
$this->assertTrue($result[1][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
|
2009-01-14 00:56:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* select u.id, u.status, upper(u.name) nameUpper from User u index by u.id
|
|
|
|
* join u.phonenumbers p indexby p.phonenumber
|
|
|
|
* =
|
|
|
|
* select u.id, u.status, upper(u.name) as p__0 from USERS u
|
|
|
|
* INNER JOIN PHONENUMBERS p ON u.id = p.user_id
|
|
|
|
*/
|
|
|
|
public function testNewHydrationMixedQueryFetchJoinCustomIndex()
|
|
|
|
{
|
|
|
|
// Faked query components
|
|
|
|
$queryComponents = array(
|
|
|
|
'u' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => null,
|
|
|
|
'relation' => null,
|
|
|
|
'map' => 'id'
|
|
|
|
),
|
|
|
|
'p' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => 'u',
|
2009-01-22 22:38:10 +03:00
|
|
|
'relation' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('phonenumbers'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'map' => 'phonenumber'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Faked table alias map
|
|
|
|
$tableAliasMap = array(
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn' => 'dctrn',
|
2009-01-14 00:56:43 +03:00
|
|
|
'u' => 'u',
|
|
|
|
'p' => 'p'
|
|
|
|
);
|
|
|
|
|
|
|
|
// Faked result set
|
|
|
|
$resultSet = array(
|
|
|
|
//row1
|
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'ROMANB',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '42',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'ROMANB',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '43',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '2',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'JWAGE',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '91'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
$stmt = new HydratorMockStatement($resultSet);
|
|
|
|
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
$result = $hydrator->hydrateAll($stmt, $this->_createParserResult(
|
2009-01-15 16:30:44 +03:00
|
|
|
$queryComponents, $tableAliasMap, true));
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
$this->assertEquals(2, count($result));
|
|
|
|
$this->assertTrue(is_array($result));
|
|
|
|
$this->assertTrue(is_array($result[0]));
|
|
|
|
$this->assertTrue(is_array($result[1]));
|
|
|
|
|
|
|
|
// test the scalar values
|
|
|
|
$this->assertEquals('ROMANB', $result[0]['nameUpper']);
|
|
|
|
$this->assertEquals('JWAGE', $result[1]['nameUpper']);
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
$this->assertTrue($result[0]['1'] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
|
|
|
|
$this->assertTrue($result[1]['2'] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
|
2009-02-02 14:55:50 +03:00
|
|
|
$this->assertTrue($result[0]['1']->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
|
2009-01-14 00:56:43 +03:00
|
|
|
// first user => 2 phonenumbers. notice the custom indexing by user id
|
|
|
|
$this->assertEquals(2, count($result[0]['1']->phonenumbers));
|
|
|
|
// second user => 1 phonenumber. notice the custom indexing by user id
|
|
|
|
$this->assertEquals(1, count($result[1]['2']->phonenumbers));
|
|
|
|
// test the custom indexing of the phonenumbers
|
|
|
|
$this->assertTrue(isset($result[0]['1']->phonenumbers['42']));
|
|
|
|
$this->assertTrue(isset($result[0]['1']->phonenumbers['43']));
|
|
|
|
$this->assertTrue(isset($result[1]['2']->phonenumbers['91']));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* select u.id, u.status, p.phonenumber, upper(u.name) nameUpper, a.id, a.topic
|
|
|
|
* from User u
|
|
|
|
* join u.phonenumbers p
|
|
|
|
* join u.articles a
|
|
|
|
* =
|
|
|
|
* select u.id, u.status, p.phonenumber, upper(u.name) as u__0, a.id, a.topic
|
|
|
|
* from USERS u
|
|
|
|
* inner join PHONENUMBERS p ON u.id = p.user_id
|
|
|
|
* inner join ARTICLES a ON u.id = a.user_id
|
|
|
|
*/
|
|
|
|
public function testNewHydrationMixedQueryMultipleFetchJoin()
|
|
|
|
{
|
|
|
|
// Faked query components
|
|
|
|
$queryComponents = array(
|
|
|
|
'u' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => null,
|
|
|
|
'relation' => null,
|
2009-04-03 15:06:58 +04:00
|
|
|
'map' => null
|
2009-01-14 00:56:43 +03:00
|
|
|
),
|
|
|
|
'p' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => 'u',
|
2009-01-22 22:38:10 +03:00
|
|
|
'relation' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('phonenumbers'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'map' => null
|
|
|
|
),
|
|
|
|
'a' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsArticle'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => 'u',
|
2009-01-22 22:38:10 +03:00
|
|
|
'relation' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('articles'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'map' => null
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
// Faked table alias map
|
|
|
|
$tableAliasMap = array(
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn' => 'dctrn',
|
2009-01-14 00:56:43 +03:00
|
|
|
'u' => 'u',
|
|
|
|
'p' => 'p',
|
|
|
|
'a' => 'a'
|
|
|
|
);
|
|
|
|
|
|
|
|
// Faked result set
|
|
|
|
$resultSet = array(
|
|
|
|
//row1
|
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'ROMANB',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '42',
|
|
|
|
'a__id' => '1',
|
|
|
|
'a__topic' => 'Getting things done!'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'ROMANB',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '43',
|
|
|
|
'a__id' => '1',
|
|
|
|
'a__topic' => 'Getting things done!'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'ROMANB',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '42',
|
|
|
|
'a__id' => '2',
|
|
|
|
'a__topic' => 'ZendCon'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'ROMANB',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '43',
|
|
|
|
'a__id' => '2',
|
|
|
|
'a__topic' => 'ZendCon'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '2',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'JWAGE',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '91',
|
|
|
|
'a__id' => '3',
|
|
|
|
'a__topic' => 'LINQ'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '2',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'JWAGE',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '91',
|
|
|
|
'a__id' => '4',
|
|
|
|
'a__topic' => 'PHP6'
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
$stmt = new HydratorMockStatement($resultSet);
|
|
|
|
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
$result = $hydrator->hydrateAll($stmt, $this->_createParserResult(
|
2009-01-15 16:30:44 +03:00
|
|
|
$queryComponents, $tableAliasMap, true));
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
$this->assertEquals(2, count($result));
|
|
|
|
$this->assertTrue(is_array($result));
|
|
|
|
$this->assertTrue(is_array($result[0]));
|
|
|
|
$this->assertTrue(is_array($result[1]));
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
$this->assertTrue($result[0][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
|
2009-02-02 14:55:50 +03:00
|
|
|
$this->assertTrue($result[0][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
|
2009-01-22 22:38:10 +03:00
|
|
|
$this->assertTrue($result[0][0]->phonenumbers[0] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber);
|
|
|
|
$this->assertTrue($result[0][0]->phonenumbers[1] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber);
|
2009-02-02 14:55:50 +03:00
|
|
|
$this->assertTrue($result[0][0]->articles instanceof \Doctrine\ORM\PersistentCollection);
|
2009-01-22 22:38:10 +03:00
|
|
|
$this->assertTrue($result[0][0]->articles[0] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
|
|
|
|
$this->assertTrue($result[0][0]->articles[1] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
|
|
|
|
$this->assertTrue($result[1][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
|
2009-02-02 14:55:50 +03:00
|
|
|
$this->assertTrue($result[1][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
|
2009-01-22 22:38:10 +03:00
|
|
|
$this->assertTrue($result[1][0]->phonenumbers[0] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber);
|
|
|
|
$this->assertTrue($result[1][0]->articles[0] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
|
|
|
|
$this->assertTrue($result[1][0]->articles[1] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
|
2009-01-14 00:56:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* select u.id, u.status, p.phonenumber, upper(u.name) nameUpper, a.id, a.topic,
|
|
|
|
* c.id, c.topic
|
|
|
|
* from User u
|
|
|
|
* join u.phonenumbers p
|
|
|
|
* join u.articles a
|
|
|
|
* left join a.comments c
|
|
|
|
* =
|
|
|
|
* select u.id, u.status, p.phonenumber, upper(u.name) as u__0, a.id, a.topic,
|
|
|
|
* c.id, c.topic
|
|
|
|
* from USERS u
|
|
|
|
* inner join PHONENUMBERS p ON u.id = p.user_id
|
|
|
|
* inner join ARTICLES a ON u.id = a.user_id
|
|
|
|
* left outer join COMMENTS c ON a.id = c.article_id
|
|
|
|
*/
|
|
|
|
public function testNewHydrationMixedQueryMultipleDeepMixedFetchJoin()
|
|
|
|
{
|
|
|
|
// Faked query components
|
|
|
|
$queryComponents = array(
|
|
|
|
'u' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => null,
|
|
|
|
'relation' => null,
|
2009-04-03 15:06:58 +04:00
|
|
|
'map' => null
|
2009-01-14 00:56:43 +03:00
|
|
|
),
|
|
|
|
'p' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsPhonenumber'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => 'u',
|
2009-01-22 22:38:10 +03:00
|
|
|
'relation' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('phonenumbers'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'map' => null
|
|
|
|
),
|
|
|
|
'a' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsArticle'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => 'u',
|
2009-01-22 22:38:10 +03:00
|
|
|
'relation' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('articles'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'map' => null
|
|
|
|
),
|
|
|
|
'c' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsComment'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => 'a',
|
2009-01-22 22:38:10 +03:00
|
|
|
'relation' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsArticle')->getAssociationMapping('comments'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'map' => null
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
// Faked table alias map
|
|
|
|
$tableAliasMap = array(
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn' => 'dctrn',
|
2009-01-14 00:56:43 +03:00
|
|
|
'u' => 'u',
|
|
|
|
'p' => 'p',
|
|
|
|
'a' => 'a',
|
|
|
|
'c' => 'c'
|
|
|
|
);
|
|
|
|
|
|
|
|
// Faked result set
|
|
|
|
$resultSet = array(
|
|
|
|
//row1
|
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'ROMANB',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '42',
|
|
|
|
'a__id' => '1',
|
|
|
|
'a__topic' => 'Getting things done!',
|
|
|
|
'c__id' => '1',
|
|
|
|
'c__topic' => 'First!'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'ROMANB',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '43',
|
|
|
|
'a__id' => '1',
|
|
|
|
'a__topic' => 'Getting things done!',
|
|
|
|
'c__id' => '1',
|
|
|
|
'c__topic' => 'First!'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'ROMANB',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '42',
|
|
|
|
'a__id' => '2',
|
|
|
|
'a__topic' => 'ZendCon',
|
|
|
|
'c__id' => null,
|
|
|
|
'c__topic' => null
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'ROMANB',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '43',
|
|
|
|
'a__id' => '2',
|
|
|
|
'a__topic' => 'ZendCon',
|
|
|
|
'c__id' => null,
|
|
|
|
'c__topic' => null
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '2',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'JWAGE',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '91',
|
|
|
|
'a__id' => '3',
|
|
|
|
'a__topic' => 'LINQ',
|
|
|
|
'c__id' => null,
|
|
|
|
'c__topic' => null
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '2',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'JWAGE',
|
2009-01-14 00:56:43 +03:00
|
|
|
'p__phonenumber' => '91',
|
|
|
|
'a__id' => '4',
|
|
|
|
'a__topic' => 'PHP6',
|
|
|
|
'c__id' => null,
|
|
|
|
'c__topic' => null
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
$stmt = new HydratorMockStatement($resultSet);
|
|
|
|
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
$result = $hydrator->hydrateAll($stmt, $this->_createParserResult(
|
2009-01-15 16:30:44 +03:00
|
|
|
$queryComponents, $tableAliasMap, true));
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
$this->assertEquals(2, count($result));
|
|
|
|
$this->assertTrue(is_array($result));
|
|
|
|
$this->assertTrue(is_array($result[0]));
|
|
|
|
$this->assertTrue(is_array($result[1]));
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
$this->assertTrue($result[0][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
|
|
|
|
$this->assertTrue($result[1][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
|
2009-01-14 00:56:43 +03:00
|
|
|
// phonenumbers
|
2009-02-02 14:55:50 +03:00
|
|
|
$this->assertTrue($result[0][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
|
2009-01-22 22:38:10 +03:00
|
|
|
$this->assertTrue($result[0][0]->phonenumbers[0] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber);
|
|
|
|
$this->assertTrue($result[0][0]->phonenumbers[1] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber);
|
2009-02-02 14:55:50 +03:00
|
|
|
$this->assertTrue($result[1][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
|
2009-01-22 22:38:10 +03:00
|
|
|
$this->assertTrue($result[1][0]->phonenumbers[0] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber);
|
2009-01-14 00:56:43 +03:00
|
|
|
// articles
|
2009-02-02 14:55:50 +03:00
|
|
|
$this->assertTrue($result[0][0]->articles instanceof \Doctrine\ORM\PersistentCollection);
|
2009-01-22 22:38:10 +03:00
|
|
|
$this->assertTrue($result[0][0]->articles[0] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
|
|
|
|
$this->assertTrue($result[0][0]->articles[1] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
|
|
|
|
$this->assertTrue($result[1][0]->articles[0] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
|
|
|
|
$this->assertTrue($result[1][0]->articles[1] instanceof \Doctrine\Tests\Models\CMS\CmsArticle);
|
2009-01-14 00:56:43 +03:00
|
|
|
// article comments
|
2009-02-02 14:55:50 +03:00
|
|
|
$this->assertTrue($result[0][0]->articles[0]->comments instanceof \Doctrine\ORM\PersistentCollection);
|
2009-01-22 22:38:10 +03:00
|
|
|
$this->assertTrue($result[0][0]->articles[0]->comments[0] instanceof \Doctrine\Tests\Models\CMS\CmsComment);
|
2009-01-14 00:56:43 +03:00
|
|
|
// empty comment collections
|
2009-02-02 14:55:50 +03:00
|
|
|
$this->assertTrue($result[0][0]->articles[1]->comments instanceof \Doctrine\ORM\PersistentCollection);
|
2009-01-14 00:56:43 +03:00
|
|
|
$this->assertEquals(0, count($result[0][0]->articles[1]->comments));
|
2009-02-02 14:55:50 +03:00
|
|
|
$this->assertTrue($result[1][0]->articles[0]->comments instanceof \Doctrine\ORM\PersistentCollection);
|
2009-01-14 00:56:43 +03:00
|
|
|
$this->assertEquals(0, count($result[1][0]->articles[0]->comments));
|
2009-02-02 14:55:50 +03:00
|
|
|
$this->assertTrue($result[1][0]->articles[1]->comments instanceof \Doctrine\ORM\PersistentCollection);
|
2009-01-14 00:56:43 +03:00
|
|
|
$this->assertEquals(0, count($result[1][0]->articles[1]->comments));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests that the hydrator does not rely on a particular order of the rows
|
|
|
|
* in the result set.
|
|
|
|
*
|
|
|
|
* DQL:
|
|
|
|
* select c.id, c.position, c.name, b.id, b.position
|
2009-01-22 22:38:10 +03:00
|
|
|
* from \Doctrine\Tests\Models\Forum\ForumCategory c inner join c.boards b
|
2009-01-14 00:56:43 +03:00
|
|
|
* order by c.position asc, b.position asc
|
|
|
|
*
|
|
|
|
* Checks whether the boards are correctly assigned to the categories.
|
|
|
|
*
|
|
|
|
* The 'evil' result set that confuses the object population is displayed below.
|
|
|
|
*
|
|
|
|
* c.id | c.position | c.name | boardPos | b.id | b.category_id (just for clarity)
|
|
|
|
* 1 | 0 | First | 0 | 1 | 1
|
|
|
|
* 2 | 0 | Second | 0 | 2 | 2 <--
|
|
|
|
* 1 | 0 | First | 1 | 3 | 1
|
|
|
|
* 1 | 0 | First | 2 | 4 | 1
|
|
|
|
*/
|
|
|
|
public function testNewHydrationEntityQueryCustomResultSetOrder()
|
|
|
|
{
|
|
|
|
// Faked query components
|
|
|
|
$queryComponents = array(
|
|
|
|
'c' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\Forum\ForumCategory'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => null,
|
|
|
|
'relation' => null,
|
|
|
|
'map' => null
|
|
|
|
),
|
|
|
|
'b' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\Forum\ForumBoard'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => 'c',
|
2009-01-22 22:38:10 +03:00
|
|
|
'relation' => $this->_em->getClassMetadata('Doctrine\Tests\Models\Forum\ForumCategory')->getAssociationMapping('boards'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'map' => null
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
// Faked table alias map
|
|
|
|
$tableAliasMap = array(
|
|
|
|
'c' => 'c',
|
|
|
|
'b' => 'b'
|
|
|
|
);
|
|
|
|
|
|
|
|
// Faked result set
|
|
|
|
$resultSet = array(
|
|
|
|
array(
|
|
|
|
'c__id' => '1',
|
|
|
|
'c__position' => '0',
|
|
|
|
'c__name' => 'First',
|
|
|
|
'b__id' => '1',
|
|
|
|
'b__position' => '0',
|
|
|
|
//'b__category_id' => '1'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'c__id' => '2',
|
|
|
|
'c__position' => '0',
|
|
|
|
'c__name' => 'Second',
|
|
|
|
'b__id' => '2',
|
|
|
|
'b__position' => '0',
|
|
|
|
//'b__category_id' => '2'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'c__id' => '1',
|
|
|
|
'c__position' => '0',
|
|
|
|
'c__name' => 'First',
|
|
|
|
'b__id' => '3',
|
|
|
|
'b__position' => '1',
|
|
|
|
//'b__category_id' => '1'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'c__id' => '1',
|
|
|
|
'c__position' => '0',
|
|
|
|
'c__name' => 'First',
|
|
|
|
'b__id' => '4',
|
|
|
|
'b__position' => '2',
|
|
|
|
//'b__category_id' => '1'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
$stmt = new HydratorMockStatement($resultSet);
|
|
|
|
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
$result = $hydrator->hydrateAll($stmt, $this->_createParserResult(
|
2009-01-15 16:30:44 +03:00
|
|
|
$queryComponents, $tableAliasMap));
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
$this->assertEquals(2, count($result));
|
2009-01-22 22:38:10 +03:00
|
|
|
$this->assertTrue($result[0] instanceof \Doctrine\Tests\Models\Forum\ForumCategory);
|
|
|
|
$this->assertTrue($result[1] instanceof \Doctrine\Tests\Models\Forum\ForumCategory);
|
2009-01-14 00:56:43 +03:00
|
|
|
$this->assertEquals(1, $result[0]->getId());
|
|
|
|
$this->assertEquals(2, $result[1]->getId());
|
|
|
|
$this->assertTrue(isset($result[0]->boards));
|
|
|
|
$this->assertEquals(3, count($result[0]->boards));
|
|
|
|
$this->assertTrue(isset($result[1]->boards));
|
|
|
|
$this->assertEquals(1, count($result[1]->boards));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-02-18 10:59:11 +03:00
|
|
|
public function testResultIteration()
|
|
|
|
{
|
2009-01-14 00:56:43 +03:00
|
|
|
// Faked query components
|
|
|
|
$queryComponents = array(
|
|
|
|
'u' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'),
|
2009-01-14 00:56:43 +03:00
|
|
|
'parent' => null,
|
|
|
|
'relation' => null,
|
|
|
|
'map' => null
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Faked table alias map
|
|
|
|
$tableAliasMap = array(
|
|
|
|
'u' => 'u'
|
|
|
|
);
|
|
|
|
|
|
|
|
// Faked result set
|
|
|
|
$resultSet = array(
|
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__name' => 'romanb'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'u__id' => '2',
|
|
|
|
'u__name' => 'jwage'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
$stmt = new HydratorMockStatement($resultSet);
|
|
|
|
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
$iterableResult = $hydrator->iterate($stmt, $this->_createParserResult(
|
2009-01-15 16:30:44 +03:00
|
|
|
$queryComponents, $tableAliasMap));
|
2009-01-14 00:56:43 +03:00
|
|
|
|
|
|
|
$rowNum = 0;
|
|
|
|
while (($row = $iterableResult->next()) !== false) {
|
|
|
|
$this->assertEquals(1, count($row));
|
2009-01-22 22:38:10 +03:00
|
|
|
$this->assertTrue($row[0] instanceof \Doctrine\Tests\Models\CMS\CmsUser);
|
2009-01-14 00:56:43 +03:00
|
|
|
if ($rowNum == 0) {
|
|
|
|
$this->assertEquals(1, $row[0]->id);
|
|
|
|
$this->assertEquals('romanb', $row[0]->name);
|
|
|
|
} else if ($rowNum == 1) {
|
|
|
|
$this->assertEquals(2, $row[0]->id);
|
|
|
|
$this->assertEquals('jwage', $row[0]->name);
|
|
|
|
}
|
|
|
|
++$rowNum;
|
|
|
|
}
|
|
|
|
}
|
2009-01-15 16:30:44 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* select u.id, u.status, p.phonenumber, upper(u.name) nameUpper from User u
|
|
|
|
* join u.phonenumbers p
|
|
|
|
* =
|
|
|
|
* select u.id, u.status, p.phonenumber, upper(u.name) as u__0 from USERS u
|
|
|
|
* INNER JOIN PHONENUMBERS p ON u.id = p.user_id
|
|
|
|
*
|
|
|
|
* @dataProvider hydrationModeProvider
|
|
|
|
*/
|
2009-02-18 10:59:11 +03:00
|
|
|
public function testNewHydrationMixedQueryFetchJoinPerformance()
|
2009-01-15 16:30:44 +03:00
|
|
|
{
|
|
|
|
// Faked query components
|
|
|
|
$queryComponents = array(
|
|
|
|
'u' => array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('\Doctrine\Tests\Models\CMS\CmsUser'),
|
2009-01-15 16:30:44 +03:00
|
|
|
'parent' => null,
|
|
|
|
'relation' => null,
|
2009-04-03 15:06:58 +04:00
|
|
|
'map' => null
|
2009-02-18 10:59:11 +03:00
|
|
|
),
|
2009-01-15 16:30:44 +03:00
|
|
|
'p' => array(
|
2009-02-18 10:59:11 +03:00
|
|
|
'metadata' => $this->_em->getClassMetadata('\Doctrine\Tests\Models\CMS\CmsPhonenumber'),
|
2009-01-15 16:30:44 +03:00
|
|
|
'parent' => 'u',
|
2009-01-22 22:38:10 +03:00
|
|
|
'relation' => $this->_em->getClassMetadata('\Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('phonenumbers'),
|
2009-01-15 16:30:44 +03:00
|
|
|
'map' => null
|
2009-02-18 10:59:11 +03:00
|
|
|
)
|
|
|
|
);
|
2009-01-15 16:30:44 +03:00
|
|
|
|
|
|
|
// Faked table alias map
|
|
|
|
$tableAliasMap = array(
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn' => 'dctrn',
|
2009-01-15 16:30:44 +03:00
|
|
|
'u' => 'u',
|
|
|
|
'p' => 'p'
|
2009-02-18 10:59:11 +03:00
|
|
|
);
|
2009-01-15 16:30:44 +03:00
|
|
|
|
|
|
|
// Faked result set
|
|
|
|
$resultSet = array(
|
|
|
|
//row1
|
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'ROMANB',
|
2009-01-15 16:30:44 +03:00
|
|
|
'p__phonenumber' => '42',
|
2009-02-18 10:59:11 +03:00
|
|
|
),
|
2009-01-15 16:30:44 +03:00
|
|
|
array(
|
|
|
|
'u__id' => '1',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'ROMANB',
|
2009-01-15 16:30:44 +03:00
|
|
|
'p__phonenumber' => '43',
|
2009-02-18 10:59:11 +03:00
|
|
|
),
|
2009-01-15 16:30:44 +03:00
|
|
|
array(
|
|
|
|
'u__id' => '2',
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'JWAGE',
|
2009-01-15 16:30:44 +03:00
|
|
|
'p__phonenumber' => '91'
|
2009-02-18 10:59:11 +03:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
for ($i = 4; $i < 300; $i++) {
|
2009-01-15 16:30:44 +03:00
|
|
|
$resultSet[] = array(
|
|
|
|
'u__id' => $i,
|
|
|
|
'u__status' => 'developer',
|
2009-04-03 15:06:58 +04:00
|
|
|
'dctrn__nameUpper' => 'JWAGE' . $i,
|
2009-01-15 16:30:44 +03:00
|
|
|
'p__phonenumber' => '91'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-02-18 10:59:11 +03:00
|
|
|
$stmt = new HydratorMockStatement($resultSet);
|
|
|
|
$hydrator = new \Doctrine\ORM\Internal\Hydration\ObjectHydrator($this->_em);
|
2009-01-15 16:30:44 +03:00
|
|
|
|
|
|
|
$result = $hydrator->hydrateAll($stmt, $this->_createParserResult(
|
|
|
|
$queryComponents, $tableAliasMap, true));
|
2009-02-18 10:59:11 +03:00
|
|
|
}
|
|
|
|
}
|