summaryrefslogtreecommitdiffstats
path: root/apps/encryption/tests/Controller
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2019-08-26 15:22:00 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2019-09-15 12:04:28 +0200
commit16d47b5928a4351aec444ad9a7f90a6e8d2a4676 (patch)
treef28c9118cdcf242e4d4a9f84dc7ce184e02be774 /apps/encryption/tests/Controller
parent0a874c51af8dd6652c694f0545489af23d53771a (diff)
downloadnextcloud-server-16d47b5928a4351aec444ad9a7f90a6e8d2a4676.tar.gz
nextcloud-server-16d47b5928a4351aec444ad9a7f90a6e8d2a4676.zip
Fix wrongly mixed mock objects in encryption tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/encryption/tests/Controller')
-rw-r--r--apps/encryption/tests/Controller/SettingsControllerTest.php29
1 files changed, 12 insertions, 17 deletions
diff --git a/apps/encryption/tests/Controller/SettingsControllerTest.php b/apps/encryption/tests/Controller/SettingsControllerTest.php
index b12652b51c9..b50f7cd0b61 100644
--- a/apps/encryption/tests/Controller/SettingsControllerTest.php
+++ b/apps/encryption/tests/Controller/SettingsControllerTest.php
@@ -34,8 +34,10 @@ use OCP\AppFramework\Http;
use OCP\IL10N;
use OCP\IRequest;
use OCP\ISession;
+use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class SettingsControllerTest extends TestCase {
@@ -63,6 +65,8 @@ class SettingsControllerTest extends TestCase {
/** @var \OCA\Encryption\Session|\PHPUnit_Framework_MockObject_MockObject */
private $sessionMock;
+ /** @var MockObject|IUser */
+ private $user;
/** @var \OCP\ISession|\PHPUnit_Framework_MockObject_MockObject */
private $ocSessionMock;
@@ -94,28 +98,17 @@ class SettingsControllerTest extends TestCase {
$this->cryptMock = $this->getMockBuilder(Crypt::class)
->disableOriginalConstructor()->getMock();
- $this->userSessionMock = $this->getMockBuilder(IUserSession::class)
- ->disableOriginalConstructor()
- ->setMethods([
- 'isLoggedIn',
- 'getUID',
- 'login',
- 'logout',
- 'setUser',
- 'getUser',
- 'canChangePassword',
- ])
- ->getMock();
-
$this->ocSessionMock = $this->getMockBuilder(ISession::class)->disableOriginalConstructor()->getMock();
- $this->userSessionMock->expects($this->any())
+ $this->user = $this->createMock(IUser::class);
+ $this->user->expects($this->any())
->method('getUID')
->willReturn('testUserUid');
+ $this->userSessionMock = $this->createMock(IUserSession::class);
$this->userSessionMock->expects($this->any())
- ->method($this->anything())
- ->will($this->returnSelf());
+ ->method('getUser')
+ ->willReturn($this->user);
$this->sessionMock = $this->getMockBuilder(Session::class)
->disableOriginalConstructor()->getMock();
@@ -146,7 +139,9 @@ class SettingsControllerTest extends TestCase {
$oldPassword = 'old';
$newPassword = 'new';
- $this->userSessionMock->expects($this->once())->method('getUID')->willReturn('uid');
+ $this->user->expects($this->any())
+ ->method('getUID')
+ ->willReturn('uid');
$this->userManagerMock
->expects($this->exactly(2))