diff options
author | Joas Schilling <coding@schilljs.com> | 2019-08-26 15:22:00 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-09-15 12:04:28 +0200 |
commit | 16d47b5928a4351aec444ad9a7f90a6e8d2a4676 (patch) | |
tree | f28c9118cdcf242e4d4a9f84dc7ce184e02be774 /apps/encryption/tests/RecoveryTest.php | |
parent | 0a874c51af8dd6652c694f0545489af23d53771a (diff) | |
download | nextcloud-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/RecoveryTest.php')
-rw-r--r-- | apps/encryption/tests/RecoveryTest.php | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/apps/encryption/tests/RecoveryTest.php b/apps/encryption/tests/RecoveryTest.php index 0eb9a777ec3..9b737cdb82f 100644 --- a/apps/encryption/tests/RecoveryTest.php +++ b/apps/encryption/tests/RecoveryTest.php @@ -36,8 +36,10 @@ use OCA\Encryption\Recovery; use OCP\Encryption\IFile; use OCP\Encryption\Keys\IStorage; use OCP\IConfig; +use OCP\IUser; use OCP\IUserSession; use OCP\Security\ISecureRandom; +use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; class RecoveryTest extends TestCase { @@ -55,6 +57,10 @@ class RecoveryTest extends TestCase { */ private $userSessionMock; /** + * @var MockObject|IUser + */ + private $user; + /** * @var \OCA\Encryption\KeyManager|\PHPUnit_Framework_MockObject_MockObject */ private $keyManagerMock; @@ -257,32 +263,22 @@ class RecoveryTest extends TestCase { protected function setUp() { parent::setUp(); + $this->user = $this->createMock(IUser::class); + $this->user->expects($this->any()) + ->method('getUID') + ->willReturn('admin'); - $this->userSessionMock = $this->getMockBuilder(IUserSession::class) - ->disableOriginalConstructor() - ->setMethods([ - 'isLoggedIn', - 'getUID', - 'login', - 'logout', - 'setUser', - 'getUser' - ]) - ->getMock(); - - $this->userSessionMock->expects($this->any())->method('getUID')->will($this->returnValue('admin')); - + $this->userSessionMock = $this->createMock(IUserSession::class); + $this->userSessionMock->expects($this->any()) + ->method('getUser') + ->willReturn($this->user); $this->userSessionMock->expects($this->any()) - ->method($this->anything()) - ->will($this->returnSelf()); + ->method('isLoggedIn') + ->willReturn(true); $this->cryptMock = $this->getMockBuilder(Crypt::class)->disableOriginalConstructor()->getMock(); - /** @var \OCP\Security\ISecureRandom $randomMock */ - $randomMock = $this->createMock(ISecureRandom::class); $this->keyManagerMock = $this->getMockBuilder(KeyManager::class)->disableOriginalConstructor()->getMock(); $this->configMock = $this->createMock(IConfig::class); - /** @var \OCP\Encryption\Keys\IStorage $keyStorageMock */ - $keyStorageMock = $this->createMock(IStorage::class); $this->fileMock = $this->createMock(IFile::class); $this->viewMock = $this->createMock(View::class); @@ -296,10 +292,8 @@ class RecoveryTest extends TestCase { $this->instance = new Recovery($this->userSessionMock, $this->cryptMock, - $randomMock, $this->keyManagerMock, $this->configMock, - $keyStorageMock, $this->fileMock, $this->viewMock); } |