From 16d47b5928a4351aec444ad9a7f90a6e8d2a4676 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 26 Aug 2019 15:22:00 +0200 Subject: Fix wrongly mixed mock objects in encryption tests Signed-off-by: Joas Schilling --- apps/encryption/tests/Hooks/UserHooksTest.php | 28 ++++++++++++--------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'apps/encryption/tests/Hooks') diff --git a/apps/encryption/tests/Hooks/UserHooksTest.php b/apps/encryption/tests/Hooks/UserHooksTest.php index b14a1f6a559..2295b90625d 100644 --- a/apps/encryption/tests/Hooks/UserHooksTest.php +++ b/apps/encryption/tests/Hooks/UserHooksTest.php @@ -41,6 +41,7 @@ use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; use OCP\IUserSession; +use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; /** @@ -79,6 +80,10 @@ class UserHooksTest extends TestCase { * @var \PHPUnit_Framework_MockObject_MockObject */ private $userSessionMock; + /** + * @var MockObject|IUser + */ + private $user; /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -343,24 +348,15 @@ class UserHooksTest extends TestCase { ->disableOriginalConstructor() ->getMock(); - $this->userSessionMock = $this->getMockBuilder(IUserSession::class) - ->disableOriginalConstructor() - ->setMethods([ - 'isLoggedIn', - 'getUID', - 'login', - 'logout', - 'setUser', - 'getUser', - 'canChangePassword' - ]) - ->getMock(); - - $this->userSessionMock->expects($this->any())->method('getUID')->will($this->returnValue('testUser')); + $this->user = $this->createMock(IUser::class); + $this->user->expects($this->any()) + ->method('getUID') + ->willReturn('testUser'); + $this->userSessionMock = $this->createMock(IUserSession::class); $this->userSessionMock->expects($this->any()) - ->method($this->anything()) - ->will($this->returnSelf()); + ->method('getUser') + ->willReturn($this->user); $utilMock = $this->getMockBuilder(Util::class) ->disableOriginalConstructor() -- cgit v1.2.3