@@ -77,40 +77,42 @@ private function getMockQueryBuilder(): IQueryBuilder&MockObject {
7777
7878	public  function  testRunWithoutOrphans (): void  {
7979		$ argument$ this getArgument ();
80- 		$ qb $ this getMockQueryBuilder ();
80+ 		$ selectQb $ this getMockQueryBuilder ();
8181		$ result$ this createMock (IResult::class);
8282
8383		$ this connection ->expects (self ::once ())
8484			->method ('getQueryBuilder ' )
85- 			->willReturn ($ qb 
86- 		$ qb expects (self ::once ())
85+ 			->willReturn ($ selectQb 
86+ 		$ selectQb expects (self ::once ())
8787			->method ('executeQuery ' )
8888			->willReturn ($ result
8989		$ resultexpects (self ::once ())
9090			->method ('fetchAll ' )
9191			->willReturn ([]);
9292		$ resultexpects (self ::once ())
9393			->method ('closeCursor ' );
94- 		$ qbexpects (self ::never ())
95- 			->method ('delete ' );
96- 		$ qbexpects (self ::never ())
97- 			->method ('executeStatement ' );
9894		$ this jobList ->expects (self ::never ())
9995			->method ('add ' );
10096
10197		self ::invokePrivate ($ this job , 'run ' , [$ argument
10298	}
10399
104100	public  function  testRunWithPartialBatch (): void  {
105- 		$ batch0 ;
106101		$ argument$ this getArgument ();
107- 		$ qb$ this getMockQueryBuilder ();
102+ 		$ selectQb$ this getMockQueryBuilder ();
103+ 		$ deleteQb$ this getMockQueryBuilder ();
108104		$ result$ this createMock (IResult::class);
109105
110- 		$ this connection ->expects (self ::once ())
106+ 		$ qbInvocationCountself ::exactly (2 );
107+ 		$ this connection ->expects ($ qbInvocationCount
111108			->method ('getQueryBuilder ' )
112- 			->willReturn ($ qb
113- 		$ qbexpects (self ::once ())
109+ 			->willReturnCallback (function  () use  ($ qbInvocationCount$ selectQb$ deleteQb
110+ 				return  match  ($ qbInvocationCountgetInvocationCount ()) {
111+ 					1  => $ selectQb
112+ 					2  => $ deleteQb
113+ 				};
114+ 			});
115+ 		$ selectQbexpects (self ::once ())
114116			->method ('executeQuery ' )
115117			->willReturn ($ result
116118		$ resultexpects (self ::once ())
@@ -121,10 +123,10 @@ public function testRunWithPartialBatch(): void {
121123			]);
122124		$ resultexpects (self ::once ())
123125			->method ('closeCursor ' );
124- 		$ qb expects (self ::once ())
126+ 		$ deleteQb expects (self ::once ())
125127			->method ('delete ' )
126128			->willReturnSelf ();
127- 		$ qb expects (self ::once ())
129+ 		$ deleteQb expects (self ::once ())
128130			->method ('executeStatement ' );
129131		$ this jobList ->expects (self ::never ())
130132			->method ('add ' );
@@ -133,26 +135,32 @@ public function testRunWithPartialBatch(): void {
133135	}
134136
135137	public  function  testRunWithFullBatch (): void  {
136- 		$ batch0 ;
137138		$ argument$ this getArgument ();
138- 		$ qb$ this getMockQueryBuilder ();
139+ 		$ selectQb$ this getMockQueryBuilder ();
140+ 		$ deleteQb$ this getMockQueryBuilder ();
139141		$ result$ this createMock (IResult::class);
140142
141- 		$ this connection ->expects (self ::once ())
143+ 		$ qbInvocationCountself ::exactly (2 );
144+ 		$ this connection ->expects ($ qbInvocationCount
142145			->method ('getQueryBuilder ' )
143- 			->willReturn ($ qb
144- 		$ qbexpects (self ::once ())
146+ 			->willReturnCallback (function  () use  ($ qbInvocationCount$ selectQb$ deleteQb
147+ 				return  match  ($ qbInvocationCountgetInvocationCount ()) {
148+ 					1  => $ selectQb
149+ 					2  => $ deleteQb
150+ 				};
151+ 			});
152+ 		$ selectQbexpects (self ::once ())
145153			->method ('executeQuery ' )
146154			->willReturn ($ result
147155		$ resultexpects (self ::once ())
148156			->method ('fetchAll ' )
149157			->willReturn (array_map (static  fn  ($ i'id '  => 42  + $ irange (0 , 999 )));
150158		$ resultexpects (self ::once ())
151159			->method ('closeCursor ' );
152- 		$ qb expects (self ::once ())
160+ 		$ deleteQb expects (self ::once ())
153161			->method ('delete ' )
154162			->willReturnSelf ();
155- 		$ qb expects (self ::once ())
163+ 		$ deleteQb expects (self ::once ())
156164			->method ('executeStatement ' );
157165		$ this jobList ->expects (self ::once ())
158166			->method ('add ' )
0 commit comments