Skip to content

Commit

Permalink
Simplify mock returns in LoginTokenManagerTest.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Jan 25, 2024
1 parent e749d9a commit 33277bb
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public function testTokenLoginException()
$userTable = $this->getMockUserTable();
$userTable->expects($this->once())->method('getById')
->with($this->equalTo(0))
->will($this->returnValue($this->getMockUser()));
->willReturn($this->getMockUser());
$tokenTable = $this->getMockLoginTokenTable();
$tokenTable->expects($this->once())->method('matchToken')
->will($this->returnValue($mockToken));
->willReturn($mockToken);
$loginToken = $this->getLoginToken($cookieManager, $tokenTable, $userTable);

// Expect exception due to browscap.ini requirements
Expand All @@ -94,12 +94,12 @@ public function testTokenLoginInvalidToken()
$userTable = $this->getMockUserTable();
$userTable->expects($this->once())->method('getById')
->with($this->equalTo(0))
->will($this->returnValue($this->getMockUser()));
->willReturn($this->getMockUser());
$tokenTable = $this->getMockLoginTokenTable();
$tokenTable->expects($this->once())->method('matchToken')
->will($this->throwException(new LoginTokenException()));
$tokenTable->expects($this->once())->method('getByUserId')
->will($this->returnValue($mockToken));
->willReturn($mockToken);
$loginToken = $this->getLoginToken($cookieManager, $tokenTable, $userTable);
$this->assertNull($loginToken->tokenLogin('123'));
}
Expand All @@ -121,7 +121,7 @@ public function testTokenLoginFail()
$token = $this->getMockLoginToken();
$tokenTable = $this->getMockLoginTokenTable();
$tokenTable->expects($this->once())->method('matchToken')
->will($this->returnValue(false));
->willReturn(false);
$loginToken = $this->getLoginToken($cookieManager, $tokenTable, $userTable);
$this->assertNull($loginToken->tokenLogin('123'));
}
Expand Down Expand Up @@ -153,9 +153,9 @@ protected function getMockUser()
->disableOriginalConstructor()
->getMock();
$user->method('__get')
->will($this->returnValueMap($userData));
->willReturnMap($userData);
$user->method('offsetGet')
->will($this->returnValueMap($userData));
->willReturnMap($userData);
return $user;
}

Expand All @@ -176,9 +176,9 @@ protected function getMockLoginToken()
->disableOriginalConstructor()
->getMock();
$token->method('__get')
->will($this->returnValueMap($tokenData));
->willReturnMap($tokenData);
$token->method('offsetGet')
->will($this->returnValueMap($tokenData));
->willReturnMap($tokenData);
return $token;
}

Expand Down

0 comments on commit 33277bb

Please sign in to comment.