diff options
author | Christoph Wurst <christoph@owncloud.com> | 2016-06-20 10:41:23 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@owncloud.com> | 2016-06-20 10:41:23 +0200 |
commit | 56199eba376e044f65e9e02844a9d98e524340b4 (patch) | |
tree | de818c6f4b21243cda9e5d8e35a9889165285406 /tests | |
parent | fb36fd495b2b97063a13239f214909011d0b1385 (diff) | |
download | nextcloud-server-56199eba376e044f65e9e02844a9d98e524340b4.tar.gz nextcloud-server-56199eba376e044f65e9e02844a9d98e524340b4.zip |
fix unit test warning/errors
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/User/SessionTest.php | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php index 974b5d3fd88..6b72cf81bc9 100644 --- a/tests/lib/User/SessionTest.php +++ b/tests/lib/User/SessionTest.php @@ -151,7 +151,7 @@ class SessionTest extends \Test\TestCase { $this->tokenProvider->expects($this->once()) ->method('getToken') ->with('bar') - ->will($this->throwException('\OC\Authentication\Exceptions\InvalidTokenException')); + ->will($this->throwException(new \OC\Authentication\Exceptions\InvalidTokenException())); $session->expects($this->exactly(2)) ->method('set') ->with($this->callback(function ($key) { @@ -698,9 +698,15 @@ class SessionTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $session = new Memory(''); - $token = $this->getMock('\OC\Authentication\Token\IToken'); + $token = new \OC\Authentication\Token\DefaultToken(); + $token->setLoginName('fritz'); + $token->setUid('fritz0'); + $token->setLastCheck(100); // Needs check $user = $this->getMock('\OCP\IUser'); - $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config); + $userSession = $this->getMockBuilder('\OC\User\Session') + ->setMethods(['logout']) + ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config]) + ->getMock(); $request = $this->getMock('\OCP\IRequest'); $request->expects($this->once()) @@ -708,15 +714,12 @@ class SessionTest extends \Test\TestCase { ->with('Authorization') ->will($this->returnValue('token xxxxx')); $this->tokenProvider->expects($this->once()) - ->method('validateToken') + ->method('getToken') ->with('xxxxx') ->will($this->returnValue($token)); - $token->expects($this->once()) - ->method('getUID') - ->will($this->returnValue('user123')); $manager->expects($this->once()) ->method('get') - ->with('user123') + ->with('fritz0') ->will($this->returnValue($user)); $user->expects($this->once()) ->method('isEnabled') @@ -762,16 +765,14 @@ class SessionTest extends \Test\TestCase { $user->expects($this->once()) ->method('isEnabled') ->will($this->returnValue(false)); - $this->tokenProvider->expects($this->once()) + $tokenProvider->expects($this->once()) ->method('invalidateToken') - ->with($token); - $session->expects($this->once()) + ->with('APP-PASSWORD'); + $userSession->expects($this->once()) ->method('logout'); - $tokenProvider->expects($this->once()) - ->method('updateToken') - ->with($token); - $this->invokePrivate($userSession, 'validateSession', [$user]); + $userSession->setUser($user); + $this->invokePrivate($userSession, 'validateSession'); } public function testValidateSessionNoPassword() { |