Skip to content

Commit

Permalink
fixes return values for findOneBy in various mocks.
Browse files Browse the repository at this point in the history
needs to be either and object or NULL, and nothing else.
  • Loading branch information
stopfstedt committed Feb 28, 2024
1 parent e6f0515 commit aa9e7ec
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/Command/AddDirectoryUserCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function testExecute(): void

$authentication->shouldReceive('setUser')->with($user);

$this->userRepository->shouldReceive('findOneBy')->with(['campusId' => 'abc'])->andReturn(false);
$this->userRepository->shouldReceive('findOneBy')->with(['campusId' => 'abc'])->andReturn(null);
$this->schoolRepository->shouldReceive('findOneBy')->with(['id' => 1])->andReturn($school);
$this->userRepository->shouldReceive('create')->andReturn($user);
$this->userRepository->shouldReceive('update')->with($user);
Expand Down
4 changes: 2 additions & 2 deletions tests/Command/AddUserCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ protected function getReadyForInput(): void

$this->hasher->shouldReceive('hashPassword')->with($sessionUser, 'abc123pass')->andReturn('hashBlurb');

$this->userRepository->shouldReceive('findOneBy')->with(['campusId' => 'abc'])->andReturn(false);
$this->userRepository->shouldReceive('findOneBy')->with(['email' => 'email@example.com'])->andReturn(false);
$this->userRepository->shouldReceive('findOneBy')->with(['campusId' => 'abc'])->andReturn(null);
$this->userRepository->shouldReceive('findOneBy')->with(['email' => 'email@example.com'])->andReturn(null);
$this->schoolRepository->shouldReceive('findOneBy')->with(['id' => 1])->andReturn($school);
$this->userRepository->shouldReceive('create')->andReturn($user);
$this->userRepository->shouldReceive('update')->with($user);
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/InstallFirstUserCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ protected function getReadyForInput(): void
$user->shouldReceive('setAuthentication')->with($authentication);
$this->schoolRepository->shouldReceive('findOneBy')->with(['id' => '1'])->andReturn($school);
$this->schoolRepository->shouldReceive('findBy')->with([], ['title' => 'ASC'])->andReturn([$school]);
$this->userRepository->shouldReceive('findOneBy')->with([])->andReturn([]);
$this->userRepository->shouldReceive('findOneBy')->with([])->andReturn(null);
$this->userRepository->shouldReceive('create')->andReturn($user);
$this->userRepository->shouldReceive('update')->with($user);
$this->authenticationRepository->shouldReceive('create')->andReturn($authentication);
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/SyncAllUsersCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ public function testExecuteWithNoAuthenticationDataChange(): void
$this->userRepository->shouldReceive('update')->with($user, false)->once();

$this->authenticationRepository->shouldReceive('findOneBy')
->with(['username' => 'abc123'])->once()->andReturn(false);
->with(['username' => 'abc123'])->once()->andReturn(null);
$this->authenticationRepository->shouldReceive('create')->andReturn($authentication)->once();
$this->authenticationRepository->shouldReceive('update')->with($authentication, false)->once();
$this->em->shouldReceive('flush')->twice();
Expand Down
2 changes: 1 addition & 1 deletion tests/Service/CourseRolloverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ public function testRolloverFailsOnMissingCourse(): void
$futureDate = new DateTime();
$futureDate->add(DateInterval::createFromDateString('+2 year'));
$year = (int) $futureDate->format('Y');
$this->courseRepository->shouldReceive('findOneBy')->withArgs([['id' => $courseId]])->andReturn(false);
$this->courseRepository->shouldReceive('findOneBy')->withArgs([['id' => $courseId]])->andReturn(null);

$this->expectException(Exception::class);

Expand Down

0 comments on commit aa9e7ec

Please sign in to comment.