Skip to content

Commit 999a75f

Browse files
committed
get rid of mocks
1 parent 2e8d45d commit 999a75f

File tree

2 files changed

+13
-70
lines changed

2 files changed

+13
-70
lines changed

tests/Unit/Doctrine/Orm/RouteProviderTest.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,7 @@ public function testGetRoutesByNames(): void
203203
$this->objectRepositoryMock
204204
->expects($this->at(0))
205205
->method('findOneBy')
206-
->with(['name' => $paths[0]])
207-
->willReturn($this->routeMock)
208-
;
209-
$this->objectRepositoryMock
210-
->expects($this->at(1))
211-
->method('findOneBy')
212-
->with(['name' => $paths[1]])
206+
->withConsecutive([['name' => $paths[0]]], [['name' => $paths[1]]])
213207
->willReturn($this->routeMock)
214208
;
215209

@@ -225,14 +219,8 @@ public function testGetRoutesByNames(): void
225219
$candidatesMock
226220
->expects($this->at(1))
227221
->method('isCandidate')
228-
->with($paths[1])
229-
->willReturn(true)
230-
;
231-
$candidatesMock
232-
->expects($this->at(2))
233-
->method('isCandidate')
234-
->with($paths[2])
235-
->willReturn(false)
222+
->withConsecutive([$paths[1]], [$paths[2]])
223+
->willReturnOnConsecutiveCalls(true, false)
236224
;
237225

238226
$routeProvider = new RouteProvider($this->managerRegistryMock, $candidatesMock, 'Route');

tests/Unit/Doctrine/Phpcr/RouteProviderTest.php

Lines changed: 10 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ public function testGetRouteCollectionForRequest(): void
8787
->willReturn($candidates)
8888
;
8989

90-
$objects = [
90+
$objects = new ArrayCollection([
9191
new Route('/my'),
9292
$this,
93-
];
93+
]);
9494

9595
$this->dmMock
9696
->expects($this->once())
@@ -327,28 +327,9 @@ public function testGetRoutesByNames(): void
327327
;
328328

329329
$this->candidatesMock
330-
->expects($this->at(0))
331-
->method('isCandidate')
332-
->with('/cms/routes/test-route')
333-
->willReturn(true)
334-
;
335-
$this->candidatesMock
336-
->expects($this->at(1))
337-
->method('isCandidate')
338-
->with('/cms/simple/other-route')
339-
->willReturn(true)
340-
;
341-
$this->candidatesMock
342-
->expects($this->at(2))
343330
->method('isCandidate')
344-
->with('/cms/routes/not-a-route')
345-
->willReturn(true)
346-
;
347-
$this->candidatesMock
348-
->expects($this->at(3))
349-
->method('isCandidate')
350-
->with('/outside/prefix')
351-
->willReturn(false)
331+
->withConsecutive(['/cms/routes/test-route'], ['/cms/simple/other-route'], ['/cms/routes/not-a-route'], ['/outside/prefix'])
332+
->willReturnOnConsecutiveCalls(true, true, true, false)
352333
;
353334

354335
$paths[] = '/outside/prefix';
@@ -374,21 +355,8 @@ public function testGetRoutesByNamesNotCandidates(): void
374355
;
375356

376357
$this->candidatesMock
377-
->expects($this->at(0))
378358
->method('isCandidate')
379-
->with('/cms/routes/test-route')
380-
->willReturn(false)
381-
;
382-
$this->candidatesMock
383-
->expects($this->at(1))
384-
->method('isCandidate')
385-
->with('/cms/simple/other-route')
386-
->willReturn(false)
387-
;
388-
$this->candidatesMock
389-
->expects($this->at(2))
390-
->method('isCandidate')
391-
->with('/cms/routes/not-a-route')
359+
->with(['/cms/routes/test-route'], ['/cms/simple/other-route'], ['/cms/routes/not-a-route'])
392360
->willReturn(false)
393361
;
394362

@@ -429,29 +397,15 @@ public function testGetRoutesByNamesUuid(): void
429397
->willReturn($uow)
430398
;
431399
$uow
432-
->expects($this->at(0))
433400
->method('getDocumentId')
434-
->with($route1)
435-
->willReturn('/cms/routes/test-route')
436-
;
437-
$uow
438-
->expects($this->at(1))
439-
->method('getDocumentId')
440-
->with($route2)
441-
->willReturn('/cms/routes/other-route')
401+
->withConsecutive([$route1], [$route2])
402+
->willReturnOnConsecutiveCalls('/cms/routes/test-route', '/cms/routes/other-route')
442403
;
443404

444405
$this->candidatesMock
445-
->expects($this->at(0))
446-
->method('isCandidate')
447-
->with('/cms/routes/test-route')
448-
->willReturn(true)
449-
;
450-
$this->candidatesMock
451-
->expects($this->at(1))
452406
->method('isCandidate')
453-
->with('/cms/routes/other-route')
454-
->willReturn(false)
407+
->withConsecutive(['/cms/routes/test-route'], ['/cms/routes/other-route'])
408+
->willReturnOnConsecutiveCalls(true, false)
455409
;
456410

457411
$routeProvider = new RouteProvider($this->managerRegistryMock, $this->candidatesMock);
@@ -469,6 +423,7 @@ private function doRouteDump($limit): void
469423
->with(Route::class, 'd')
470424
;
471425

426+
472427
$query = $this->createMock(Query::class);
473428
$query
474429
->expects($this->once())

0 commit comments

Comments
 (0)