@@ -27,9 +27,7 @@ public function testItMakesHydrationCacheProfilesAwareOfTheResultCacheDriver():
2727
2828        $ configurationnew  Configuration ();
2929        $ configurationsetHydrationCache ($ cache
30-         $ entityManager$ this createMock (EntityManagerInterface::class);
31-         $ entityManagermethod ('getConfiguration ' )->willReturn ($ configuration
32-         $ query$ this getMockForAbstractClass (AbstractQuery::class, [$ entityManager
30+         $ query$ this createAbstractQuery ($ configuration
3331        $ cacheProfilenew  QueryCacheProfile ();
3432
3533        $ querysetHydrationCacheProfile ($ cacheProfile
@@ -45,9 +43,7 @@ public function testItMakesHydrationCacheProfilesAwareOfTheResultCache(): void
4543
4644        $ configurationnew  Configuration ();
4745        $ configurationsetHydrationCache ($ cache
48-         $ entityManager$ this createMock (EntityManagerInterface::class);
49-         $ entityManagermethod ('getConfiguration ' )->willReturn ($ configuration
50-         $ query$ this getMockForAbstractClass (AbstractQuery::class, [$ entityManager
46+         $ query$ this createAbstractQuery ($ configuration
5147        $ cacheProfilenew  QueryCacheProfile ();
5248
5349        $ querysetHydrationCacheProfile ($ cacheProfile
@@ -61,9 +57,7 @@ public function testItMakesResultCacheProfilesAwareOfTheResultCache(): void
6157
6258        $ configurationnew  Configuration ();
6359        $ configurationsetResultCache ($ cache
64-         $ entityManager$ this createMock (EntityManagerInterface::class);
65-         $ entityManagermethod ('getConfiguration ' )->willReturn ($ configuration
66-         $ query$ this getMockForAbstractClass (AbstractQuery::class, [$ entityManager
60+         $ query$ this createAbstractQuery ($ configuration
6761        $ cacheProfilenew  QueryCacheProfile ();
6862
6963        $ querysetResultCacheProfile ($ cacheProfile
@@ -74,9 +68,7 @@ public function testItMakesResultCacheProfilesAwareOfTheResultCache(): void
7468    /** @dataProvider provideSettersWithDeprecatedDefault */ 
7569    public  function  testCallingSettersWithoutArgumentsIsDeprecated (string  $ settervoid 
7670    {
77-         $ entityManager$ this createMock (EntityManagerInterface::class);
78-         $ entityManagermethod ('getConfiguration ' )->willReturn (new  Configuration ());
79-         $ query$ this getMockForAbstractClass (AbstractQuery::class, [$ entityManager
71+         $ query$ this createAbstractQuery (new  Configuration ());
8072
8173        $ this expectDeprecationWithIdentifier ('https://github.com/doctrine/orm/pull/9791 ' );
8274        $ query$ setter
@@ -95,10 +87,7 @@ public static function provideSettersWithDeprecatedDefault(): array
9587    public  function  testSettingTheResultCacheIsPossibleWithoutCallingDeprecatedMethods (): void 
9688    {
9789        $ cache$ this createMock (CacheItemPoolInterface::class);
98- 
99-         $ entityManager$ this createMock (EntityManagerInterface::class);
100-         $ entityManagermethod ('getConfiguration ' )->willReturn (new  Configuration ());
101-         $ query$ this getMockForAbstractClass (AbstractQuery::class, [$ entityManager
90+         $ query$ this createAbstractQuery (new  Configuration ());
10291
10392        $ querysetResultCache ($ cache
10493        self ::assertSame ($ cachewrap ($ querygetResultCacheDriver ()));
@@ -107,13 +96,27 @@ public function testSettingTheResultCacheIsPossibleWithoutCallingDeprecatedMetho
10796
10897    public  function  testSettingTheFetchModeToRandomIntegersIsDeprecated (): void 
10998    {
110-         $ query$ this getMockForAbstractClass (
111-             AbstractQuery::class,
112-             [],
113-             '' ,
114-             false  // no need to call the constructor 
115-         );
99+         $ query$ this createAbstractQuery (new  Configuration ());
100+ 
116101        $ this expectDeprecationWithIdentifier ('https://github.com/doctrine/orm/pull/9777 ' );
117102        $ querysetFetchMode (stdClass::class, 'foo ' , 42 );
118103    }
104+ 
105+     private  function  createAbstractQuery (Configuration $ configurationAbstractQuery 
106+     {
107+         $ entityManager$ this createMock (EntityManagerInterface::class);
108+         $ entityManagermethod ('getConfiguration ' )->willReturn ($ configuration
109+ 
110+         return  new  class  ($ entityManagerextends  AbstractQuery {
111+             public  function  getSQL (): string 
112+             {
113+                 return  '' ;
114+             }
115+ 
116+             protected  function  _doExecute (): int 
117+             {
118+                 return  0 ;
119+             }
120+         };
121+     }
119122}
0 commit comments