Skip to content

Commit

Permalink
get rid of mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Feb 17, 2024
1 parent 2e8d45d commit 999a75f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 70 deletions.
18 changes: 3 additions & 15 deletions tests/Unit/Doctrine/Orm/RouteProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,7 @@ public function testGetRoutesByNames(): void
$this->objectRepositoryMock
->expects($this->at(0))
->method('findOneBy')
->with(['name' => $paths[0]])
->willReturn($this->routeMock)
;
$this->objectRepositoryMock
->expects($this->at(1))
->method('findOneBy')
->with(['name' => $paths[1]])
->withConsecutive([['name' => $paths[0]]], [['name' => $paths[1]]])
->willReturn($this->routeMock)
;

Expand All @@ -225,14 +219,8 @@ public function testGetRoutesByNames(): void
$candidatesMock
->expects($this->at(1))
->method('isCandidate')
->with($paths[1])
->willReturn(true)
;
$candidatesMock
->expects($this->at(2))
->method('isCandidate')
->with($paths[2])
->willReturn(false)
->withConsecutive([$paths[1]], [$paths[2]])
->willReturnOnConsecutiveCalls(true, false)
;

$routeProvider = new RouteProvider($this->managerRegistryMock, $candidatesMock, 'Route');
Expand Down
65 changes: 10 additions & 55 deletions tests/Unit/Doctrine/Phpcr/RouteProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ public function testGetRouteCollectionForRequest(): void
->willReturn($candidates)
;

$objects = [
$objects = new ArrayCollection([
new Route('/my'),
$this,
];
]);

$this->dmMock
->expects($this->once())
Expand Down Expand Up @@ -327,28 +327,9 @@ public function testGetRoutesByNames(): void
;

$this->candidatesMock
->expects($this->at(0))
->method('isCandidate')
->with('/cms/routes/test-route')
->willReturn(true)
;
$this->candidatesMock
->expects($this->at(1))
->method('isCandidate')
->with('/cms/simple/other-route')
->willReturn(true)
;
$this->candidatesMock
->expects($this->at(2))
->method('isCandidate')
->with('/cms/routes/not-a-route')
->willReturn(true)
;
$this->candidatesMock
->expects($this->at(3))
->method('isCandidate')
->with('/outside/prefix')
->willReturn(false)
->withConsecutive(['/cms/routes/test-route'], ['/cms/simple/other-route'], ['/cms/routes/not-a-route'], ['/outside/prefix'])
->willReturnOnConsecutiveCalls(true, true, true, false)
;

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

$this->candidatesMock
->expects($this->at(0))
->method('isCandidate')
->with('/cms/routes/test-route')
->willReturn(false)
;
$this->candidatesMock
->expects($this->at(1))
->method('isCandidate')
->with('/cms/simple/other-route')
->willReturn(false)
;
$this->candidatesMock
->expects($this->at(2))
->method('isCandidate')
->with('/cms/routes/not-a-route')
->with(['/cms/routes/test-route'], ['/cms/simple/other-route'], ['/cms/routes/not-a-route'])
->willReturn(false)
;

Expand Down Expand Up @@ -429,29 +397,15 @@ public function testGetRoutesByNamesUuid(): void
->willReturn($uow)
;
$uow
->expects($this->at(0))
->method('getDocumentId')
->with($route1)
->willReturn('/cms/routes/test-route')
;
$uow
->expects($this->at(1))
->method('getDocumentId')
->with($route2)
->willReturn('/cms/routes/other-route')
->withConsecutive([$route1], [$route2])
->willReturnOnConsecutiveCalls('/cms/routes/test-route', '/cms/routes/other-route')
;

$this->candidatesMock
->expects($this->at(0))
->method('isCandidate')
->with('/cms/routes/test-route')
->willReturn(true)
;
$this->candidatesMock
->expects($this->at(1))
->method('isCandidate')
->with('/cms/routes/other-route')
->willReturn(false)
->withConsecutive(['/cms/routes/test-route'], ['/cms/routes/other-route'])
->willReturnOnConsecutiveCalls(true, false)
;

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


$query = $this->createMock(Query::class);
$query
->expects($this->once())
Expand Down

0 comments on commit 999a75f

Please sign in to comment.