createMock(UserWriteRepository::class); $writeRepository->expects($this->never())->method('setPassword'); $service = new UserPasswordService(new UserPasswordPolicyService(), $writeRepository); $result = $service->resetPassword(10, 'abc', 'abc'); $this->assertFalse($result['ok']); $this->assertNotEmpty($result['errors']); } public function testResetPasswordUpdatesRepositoryOnValidInput(): void { $writeRepository = $this->createMock(UserWriteRepository::class); $writeRepository->expects($this->once()) ->method('setPassword') ->with(11, 'StrongPass1!') ->willReturn(true); $service = new UserPasswordService(new UserPasswordPolicyService(), $writeRepository); $result = $service->resetPassword(11, 'StrongPass1!', 'StrongPass1!'); $this->assertTrue($result['ok']); } }