2010-06-03 07:25:09 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\ORM\Hydration;
|
|
|
|
|
|
|
|
use PDO, Doctrine\ORM\Internal\Hydration\AbstractHydrator;
|
|
|
|
|
|
|
|
require_once __DIR__ . '/../../TestInit.php';
|
|
|
|
|
|
|
|
class CustomHydratorTest extends HydrationTestCase
|
|
|
|
{
|
2010-06-03 22:11:31 +04:00
|
|
|
public function testCustomHydrator()
|
|
|
|
{
|
|
|
|
$em = $this->_getTestEntityManager();
|
|
|
|
$config = $em->getConfiguration();
|
|
|
|
$config->addCustomHydrationMode('CustomHydrator', 'Doctrine\Tests\ORM\Hydration\CustomHydrator');
|
|
|
|
|
|
|
|
$hydrator = $em->newHydrator('CustomHydrator');
|
2011-07-26 17:22:57 +04:00
|
|
|
$this->assertInstanceOf('Doctrine\Tests\ORM\Hydration\CustomHydrator', $hydrator);
|
2010-06-03 22:11:31 +04:00
|
|
|
$this->assertNull($config->getCustomHydrationMode('does not exist'));
|
|
|
|
}
|
2010-06-03 07:25:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
class CustomHydrator extends AbstractHydrator
|
|
|
|
{
|
2010-06-03 22:11:31 +04:00
|
|
|
protected function _hydrateAll()
|
2010-06-03 07:25:09 +04:00
|
|
|
{
|
2010-06-03 22:11:31 +04:00
|
|
|
return $this->_stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
}
|
2010-06-03 07:25:09 +04:00
|
|
|
}
|