@@ -65,6 +65,7 @@ public function testRegisterDefaultImplementations()
6565 $ this ->assertInstanceOf ('Doctrine\Common\Cache\ArrayCache ' , $ app ['orm.em.config ' ]->getQueryCacheImpl ());
6666 $ this ->assertInstanceOf ('Doctrine\Common\Cache\ArrayCache ' , $ app ['orm.em.config ' ]->getResultCacheImpl ());
6767 $ this ->assertInstanceOf ('Doctrine\Common\Cache\ArrayCache ' , $ app ['orm.em.config ' ]->getMetadataCacheImpl ());
68+ $ this ->assertInstanceOf ('Doctrine\Common\Cache\ArrayCache ' , $ app ['orm.em.config ' ]->getHydrationCacheImpl ());
6869 $ this ->assertInstanceOf ('Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain ' , $ app ['orm.em.config ' ]->getMetadataDriverImpl ());
6970 }
7071
@@ -122,13 +123,29 @@ public function testProxyConfigurationDefined()
122123 $ doctrineOrmServiceProvider = new DoctrineOrmServiceProvider ;
123124 $ doctrineOrmServiceProvider ->register ($ app );
124125
126+ $ entityRepositoryClassName = get_class ($ this ->getMock ('Doctrine\Common\Persistence\ObjectRepository ' ));
127+ $ metadataFactoryName = get_class ($ this ->getMock ('Doctrine\Common\Persistence\Mapping\ClassMetadataFactory ' ));
128+
129+ $ entityListenerResolver = $ this ->getMock ('Doctrine\ORM\Mapping\EntityListenerResolver ' );
130+ $ repositoryFactory = $ this ->getMock ('Doctrine\ORM\Repository\RepositoryFactory ' );
131+
125132 $ app ['orm.proxies_dir ' ] = '/path/to/proxies ' ;
126133 $ app ['orm.proxies_namespace ' ] = 'TestDoctrineOrmProxiesNamespace ' ;
127134 $ app ['orm.auto_generate_proxies ' ] = false ;
135+ $ app ['orm.class_metadata_factory_name ' ] = $ metadataFactoryName ;
136+ $ app ['orm.default_repository_class ' ] = $ entityRepositoryClassName ;
137+ $ app ['orm.entity_listener_resolver ' ] = $ entityListenerResolver ;
138+ $ app ['orm.repository_factory ' ] = $ repositoryFactory ;
139+ $ app ['orm.custom.hydration_modes ' ] = array ('mymode ' => 'Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator ' );
128140
129141 $ this ->assertEquals ('/path/to/proxies ' , $ app ['orm.em.config ' ]->getProxyDir ());
130142 $ this ->assertEquals ('TestDoctrineOrmProxiesNamespace ' , $ app ['orm.em.config ' ]->getProxyNamespace ());
131143 $ this ->assertFalse ($ app ['orm.em.config ' ]->getAutoGenerateProxyClasses ());
144+ $ this ->assertEquals ($ metadataFactoryName , $ app ['orm.em.config ' ]->getClassMetadataFactoryName ());
145+ $ this ->assertEquals ($ entityRepositoryClassName , $ app ['orm.em.config ' ]->getDefaultRepositoryClassName ());
146+ $ this ->assertEquals ($ entityListenerResolver , $ app ['orm.em.config ' ]->getEntityListenerResolver ());
147+ $ this ->assertEquals ($ repositoryFactory , $ app ['orm.em.config ' ]->getRepositoryFactory ());
148+ $ this ->assertEquals ('Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator ' , $ app ['orm.em.config ' ]->getCustomHydrationMode ('mymode ' ));
132149 }
133150
134151 /**
@@ -309,4 +326,41 @@ public function testMappingAlias()
309326
310327 $ this ->assertEquals ($ namespace , $ app ['orm.em.config ' ]->getEntityNameSpace ($ alias ));
311328 }
329+
330+ public function testStrategy ()
331+ {
332+ $ app = $ this ->createMockDefaultApp ();
333+
334+ $ doctrineOrmServiceProvider = new DoctrineOrmServiceProvider ;
335+ $ doctrineOrmServiceProvider ->register ($ app );
336+
337+ $ namingStrategy = $ this ->getMock ('Doctrine\ORM\Mapping\DefaultNamingStrategy ' );
338+ $ quoteStrategy = $ this ->getMock ('Doctrine\ORM\Mapping\DefaultQuoteStrategy ' );
339+
340+ $ app ['orm.strategy.naming ' ] = $ namingStrategy ;
341+ $ app ['orm.strategy.quote ' ] = $ quoteStrategy ;
342+
343+ $ this ->assertEquals ($ namingStrategy , $ app ['orm.em.config ' ]->getNamingStrategy ());
344+ $ this ->assertEquals ($ quoteStrategy , $ app ['orm.em.config ' ]->getQuoteStrategy ());
345+ }
346+
347+ public function testCustomFunctions ()
348+ {
349+ $ app = $ this ->createMockDefaultApp ();
350+
351+ $ doctrineOrmServiceProvider = new DoctrineOrmServiceProvider ;
352+ $ doctrineOrmServiceProvider ->register ($ app );
353+
354+ $ numericFunction = $ this ->getMock ('Doctrine\ORM\Query\AST\Functions\FunctionNode ' , array (), array ('mynum ' ));
355+ $ stringFunction = $ this ->getMock ('Doctrine\ORM\Query\AST\Functions\FunctionNode ' , array (), array ('mynum ' ));
356+ $ datetimeFunction = $ this ->getMock ('Doctrine\ORM\Query\AST\Functions\FunctionNode ' , array (), array ('mynum ' ));
357+
358+ $ app ['orm.custom.functions.string ' ] = array ('mystring ' => $ numericFunction );
359+ $ app ['orm.custom.functions.numeric ' ] = array ('mynumeric ' => $ stringFunction );
360+ $ app ['orm.custom.functions.datetime ' ] = array ('mydatetime ' => $ datetimeFunction );
361+
362+ $ this ->assertEquals ($ numericFunction , $ app ['orm.em.config ' ]->getCustomStringFunction ('mystring ' ));
363+ $ this ->assertEquals ($ numericFunction , $ app ['orm.em.config ' ]->getCustomNumericFunction ('mynumeric ' ));
364+ $ this ->assertEquals ($ numericFunction , $ app ['orm.em.config ' ]->getCustomDatetimeFunction ('mydatetime ' ));
365+ }
312366}
0 commit comments