@@ -112,12 +112,15 @@ protected function getMockCustomEntityManager(array $conn, EventManager $evm = n
112112 */
113113 protected function getMockMappedEntityManager (EventManager $ evm = null )
114114 {
115- $ driver = $ this ->getMock ('Doctrine\DBAL\Driver ' );
115+ $ driver = $ this ->getMockBuilder ('Doctrine\DBAL\Driver ' )-> getMock ( );
116116 $ driver ->expects ($ this ->once ())
117117 ->method ('getDatabasePlatform ' )
118- ->will ($ this ->returnValue ($ this ->getMock ('Doctrine\DBAL\Platforms\MySqlPlatform ' )));
118+ ->will ($ this ->returnValue ($ this ->getMockBuilder ('Doctrine\DBAL\Platforms\MySqlPlatform ' )->getMock ()));
119+
120+ $ conn = $ this ->getMockBuilder ('Doctrine\DBAL\Connection ' )
121+ ->setConstructorArgs (array (), $ driver )
122+ ->getMock ();
119123
120- $ conn = $ this ->getMock ('Doctrine\DBAL\Connection ' , array (), array (array (), $ driver ));
121124 $ conn ->expects ($ this ->once ())
122125 ->method ('getEventManager ' )
123126 ->will ($ this ->returnValue ($ evm ?: $ this ->getEventManager ()));
@@ -139,11 +142,7 @@ protected function startQueryLog()
139142 throw new \RuntimeException ('EntityManager and database platform must be initialized ' );
140143 }
141144 $ this ->queryAnalyzer = new QueryAnalyzer ($ this ->em ->getConnection ()->getDatabasePlatform ());
142- $ this ->em
143- ->getConfiguration ()
144- ->expects ($ this ->any ())
145- ->method ('getSQLLogger ' )
146- ->will ($ this ->returnValue ($ this ->queryAnalyzer ));
145+ $ this ->em ->getConfiguration ()->setSQLLogger ($ this ->queryAnalyzer );
147146 }
148147
149148 /**
@@ -215,84 +214,10 @@ private function getEventManager()
215214 */
216215 protected function getMockAnnotatedConfig ()
217216 {
218- // We need to mock every method except the ones which
219- // handle the filters
220- $ configurationClass = 'Doctrine\ORM\Configuration ' ;
221- $ refl = new \ReflectionClass ($ configurationClass );
222- $ methods = $ refl ->getMethods ();
223-
224- $ mockMethods = array ();
225-
226- foreach ($ methods as $ method ) {
227- if ($ method ->name !== 'addFilter ' && $ method ->name !== 'getFilterClassName ' ) {
228- $ mockMethods [] = $ method ->name ;
229- }
230- }
231-
232- $ config = $ this ->getMock ($ configurationClass , $ mockMethods );
233-
234- $ config
235- ->expects ($ this ->once ())
236- ->method ('getProxyDir ' )
237- ->will ($ this ->returnValue (__DIR__ .'/../../temp ' ))
238- ;
239-
240- $ config
241- ->expects ($ this ->once ())
242- ->method ('getProxyNamespace ' )
243- ->will ($ this ->returnValue ('Proxy ' ))
244- ;
245-
246- $ config
247- ->expects ($ this ->any ())
248- ->method ('getDefaultQueryHints ' )
249- ->will ($ this ->returnValue (array ()))
250- ;
251-
252- $ config
253- ->expects ($ this ->once ())
254- ->method ('getAutoGenerateProxyClasses ' )
255- ->will ($ this ->returnValue (true ))
256- ;
257-
258- $ config
259- ->expects ($ this ->once ())
260- ->method ('getClassMetadataFactoryName ' )
261- ->will ($ this ->returnValue ('Doctrine \\ORM \\Mapping \\ClassMetadataFactory ' ))
262- ;
263-
264- $ mappingDriver = $ this ->getMetadataDriverImplementation ();
265-
266- $ config
267- ->expects ($ this ->any ())
268- ->method ('getMetadataDriverImpl ' )
269- ->will ($ this ->returnValue ($ mappingDriver ))
270- ;
271-
272- $ config
273- ->expects ($ this ->any ())
274- ->method ('getDefaultRepositoryClassName ' )
275- ->will ($ this ->returnValue ('Doctrine \\ORM \\EntityRepository ' ))
276- ;
277-
278- $ config
279- ->expects ($ this ->any ())
280- ->method ('getQuoteStrategy ' )
281- ->will ($ this ->returnValue (new DefaultQuoteStrategy ()))
282- ;
283-
284- $ config
285- ->expects ($ this ->any ())
286- ->method ('getNamingStrategy ' )
287- ->will ($ this ->returnValue (new DefaultNamingStrategy ()))
288- ;
289-
290- $ config
291- ->expects ($ this ->once ())
292- ->method ('getRepositoryFactory ' )
293- ->will ($ this ->returnValue (new DefaultRepositoryFactory ()))
294- ;
295-
217+ $ config = new Configuration ();
218+ $ config ->setProxyDir (__DIR__ .'/../../temp ' );
219+ $ config ->setProxyNamespace ('Proxy ' );
220+ $ config ->setMetadataDriverImpl ($ this ->getMetadataDriverImplementation ());
296221 return $ config ;
297222 }
298223}
0 commit comments