Skip to content

Commit

Permalink
[DoctrineBundle] Added tests for add custom hydration mode
Browse files Browse the repository at this point in the history
  • Loading branch information
francisbesset committed Apr 3, 2011
1 parent 97729e6 commit d9b3643
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
Expand Up @@ -669,6 +669,21 @@ public function testSetCustomFunctions()
$this->assertDICDefinitionMethodCallOnce($definition, 'addCustomDatetimeFunction', array('test_datetime', 'Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestDatetimeFunction'));
}

public function testAddCustomHydrationMode()
{
$container = $this->getContainer(array('YamlBundle'));

$loader = new DoctrineExtension();
$container->registerExtension($loader);
$this->loadFromFile($container, 'orm_hydration_mode');
$container->getCompilerPassConfig()->setOptimizationPasses(array());
$container->getCompilerPassConfig()->setRemovingPasses(array());
$container->compile();

$definition = $container->getDefinition('doctrine.orm.default_configuration');
$this->assertDICDefinitionMethodCallOnce($definition, 'addCustomHydrationMode', array('test_hydrator', 'Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestHydrator'));
}

protected function getContainer($bundles = 'YamlBundle', $vendor = null)
{
if (!is_array($bundles)) {
Expand Down
@@ -0,0 +1,18 @@
<?xml version="1.0" ?>

<srv:container xmlns="http://symfony.com/schema/dic/doctrine"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:srv="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">

<config>
<dbal />
<orm default-entity-manager="default">
<entity-manager name="default">
<hydrator name="test_hydrator" class="Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestHydrator" />
<mapping name="Yaml" />
</entity-manager>
</orm>
</config>
</srv:container>
@@ -0,0 +1,9 @@
doctrine:
dbal: ~
orm:
entity_managers:
default:
hydrators:
test_hydrator: Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestHydrator
mappings:
Yaml: ~
@@ -0,0 +1,20 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection;

class TestHydrator extends \Doctrine\ORM\Internal\Hydration\AbstractHydrator
{
protected function _hydrateAll();
{
return array();
}
}

0 comments on commit d9b3643

Please sign in to comment.