diff options
Diffstat (limited to 'apps/encryption/tests/SessionTest.php')
-rw-r--r-- | apps/encryption/tests/SessionTest.php | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/apps/encryption/tests/SessionTest.php b/apps/encryption/tests/SessionTest.php index 25c652b36af..5a0a65c77b3 100644 --- a/apps/encryption/tests/SessionTest.php +++ b/apps/encryption/tests/SessionTest.php @@ -41,11 +41,11 @@ class SessionTest extends TestCase { /** @var \OCP\ISession|\PHPUnit_Framework_MockObject_MockObject */ private $sessionMock; - /** - * @expectedException \OCA\Encryption\Exceptions\PrivateKeyMissingException - * @expectedExceptionMessage Private Key missing for user: please try to log-out and log-in again - */ + public function testThatGetPrivateKeyThrowsExceptionWhenNotSet() { + $this->expectException(\OCA\Encryption\Exceptions\PrivateKeyMissingException::class); + $this->expectExceptionMessage('Private Key missing for user: please try to log-out and log-in again'); + $this->instance->getPrivateKey(); } @@ -84,42 +84,44 @@ class SessionTest extends TestCase { } /** - * @expectedException \Exception * @expectExceptionMessage 'Please activate decrypt all mode first' */ public function testGetDecryptAllUidException() { + $this->expectException(\Exception::class); + $this->instance->getDecryptAllUid(); } /** - * @expectedException \Exception * @expectExceptionMessage 'No uid found while in decrypt all mode' */ public function testGetDecryptAllUidException2() { + $this->expectException(\Exception::class); + $this->instance->prepareDecryptAll(null, 'key'); $this->instance->getDecryptAllUid(); } /** - * @expectedException \OCA\Encryption\Exceptions\PrivateKeyMissingException * @expectExceptionMessage 'Please activate decrypt all mode first' */ public function testGetDecryptAllKeyException() { + $this->expectException(\OCA\Encryption\Exceptions\PrivateKeyMissingException::class); + $this->instance->getDecryptAllKey(); } /** - * @expectedException \OCA\Encryption\Exceptions\PrivateKeyMissingException * @expectExceptionMessage 'No key found while in decrypt all mode' */ public function testGetDecryptAllKeyException2() { + $this->expectException(\OCA\Encryption\Exceptions\PrivateKeyMissingException::class); + $this->instance->prepareDecryptAll('user', null); $this->instance->getDecryptAllKey(); } - /** - * - */ + public function testSetAndGetStatusWillSetAndReturn() { // Check if get status will return 0 if it has not been set before $this->assertEquals(0, $this->instance->getStatus()); @@ -186,9 +188,7 @@ class SessionTest extends TestCase { return null; } - /** - * - */ + public function testClearWillRemoveValues() { $this->instance->setPrivateKey('privateKey'); $this->instance->setStatus('initStatus'); @@ -198,9 +198,7 @@ class SessionTest extends TestCase { $this->assertEmpty(self::$tempStorage); } - /** - * - */ + protected function setUp(): void { parent::setUp(); $this->sessionMock = $this->createMock(ISession::class); |