CustomHydratorTest.php 843 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace Doctrine\Tests\ORM\Hydration;
  3. use PDO, Doctrine\ORM\Internal\Hydration\AbstractHydrator;
  4. require_once __DIR__ . '/../../TestInit.php';
  5. class CustomHydratorTest extends HydrationTestCase
  6. {
  7. public function testCustomHydrator()
  8. {
  9. $em = $this->_getTestEntityManager();
  10. $config = $em->getConfiguration();
  11. $config->addCustomHydrationMode('CustomHydrator', 'Doctrine\Tests\ORM\Hydration\CustomHydrator');
  12. $hydrator = $em->newHydrator('CustomHydrator');
  13. $this->assertInstanceOf('Doctrine\Tests\ORM\Hydration\CustomHydrator', $hydrator);
  14. $this->assertNull($config->getCustomHydrationMode('does not exist'));
  15. }
  16. }
  17. class CustomHydrator extends AbstractHydrator
  18. {
  19. protected function hydrateAllData()
  20. {
  21. return $this->_stmt->fetchAll(PDO::FETCH_ASSOC);
  22. }
  23. }