diff options
Diffstat (limited to 'tests/lib/Session')
-rw-r--r-- | tests/lib/Session/CryptoSessionDataTest.php | 9 | ||||
-rw-r--r-- | tests/lib/Session/CryptoWrappingTest.php | 8 | ||||
-rw-r--r-- | tests/lib/Session/MemoryTest.php | 11 | ||||
-rw-r--r-- | tests/lib/Session/Session.php | 16 |
4 files changed, 26 insertions, 18 deletions
diff --git a/tests/lib/Session/CryptoSessionDataTest.php b/tests/lib/Session/CryptoSessionDataTest.php index 83768ef49aa..a30a3297094 100644 --- a/tests/lib/Session/CryptoSessionDataTest.php +++ b/tests/lib/Session/CryptoSessionDataTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -8,19 +9,21 @@ namespace Test\Session; use OC\Session\CryptoSessionData; +use OC\Session\Memory; +use OCP\ISession; use OCP\Security\ICrypto; class CryptoSessionDataTest extends Session { - /** @var \PHPUnit\Framework\MockObject\MockObject|\OCP\Security\ICrypto */ + /** @var \PHPUnit\Framework\MockObject\MockObject|ICrypto */ protected $crypto; - /** @var \OCP\ISession */ + /** @var ISession */ protected $wrappedSession; protected function setUp(): void { parent::setUp(); - $this->wrappedSession = new \OC\Session\Memory($this->getUniqueID()); + $this->wrappedSession = new Memory(); $this->crypto = $this->createMock(ICrypto::class); $this->crypto->expects($this->any()) ->method('encrypt') diff --git a/tests/lib/Session/CryptoWrappingTest.php b/tests/lib/Session/CryptoWrappingTest.php index 093f2214929..2bc09e0903a 100644 --- a/tests/lib/Session/CryptoWrappingTest.php +++ b/tests/lib/Session/CryptoWrappingTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -9,13 +10,14 @@ namespace Test\Session; use OC\Session\CryptoSessionData; use OCP\ISession; +use OCP\Security\ICrypto; use Test\TestCase; class CryptoWrappingTest extends TestCase { - /** @var \PHPUnit\Framework\MockObject\MockObject|\OCP\Security\ICrypto */ + /** @var \PHPUnit\Framework\MockObject\MockObject|ICrypto */ protected $crypto; - /** @var \PHPUnit\Framework\MockObject\MockObject|\OCP\ISession */ + /** @var \PHPUnit\Framework\MockObject\MockObject|ISession */ protected $wrappedSession; /** @var \OC\Session\CryptoSessionData */ @@ -47,7 +49,7 @@ class CryptoWrappingTest extends TestCase { $this->instance = new CryptoSessionData($this->wrappedSession, $this->crypto, 'PASS'); } - public function testUnwrappingGet() { + public function testUnwrappingGet(): void { $unencryptedValue = 'foobar'; $encryptedValue = $this->crypto->encrypt($unencryptedValue); diff --git a/tests/lib/Session/MemoryTest.php b/tests/lib/Session/MemoryTest.php index ae4a1b64dc0..40977f1f3fb 100644 --- a/tests/lib/Session/MemoryTest.php +++ b/tests/lib/Session/MemoryTest.php @@ -8,15 +8,18 @@ namespace Test\Session; +use OC\Session\Memory; +use OCP\Session\Exceptions\SessionNotAvailableException; + class MemoryTest extends Session { protected function setUp(): void { parent::setUp(); - $this->instance = new \OC\Session\Memory($this->getUniqueID()); + $this->instance = new Memory(); } - - public function testThrowsExceptionOnGetId() { - $this->expectException(\OCP\Session\Exceptions\SessionNotAvailableException::class); + + public function testThrowsExceptionOnGetId(): void { + $this->expectException(SessionNotAvailableException::class); $this->instance->getId(); } diff --git a/tests/lib/Session/Session.php b/tests/lib/Session/Session.php index 63fa4554477..1e2e9370825 100644 --- a/tests/lib/Session/Session.php +++ b/tests/lib/Session/Session.php @@ -19,43 +19,43 @@ abstract class Session extends \Test\TestCase { parent::tearDown(); } - public function testNotExistsEmpty() { + public function testNotExistsEmpty(): void { $this->assertFalse($this->instance->exists('foo')); } - public function testExistsAfterSet() { + public function testExistsAfterSet(): void { $this->instance->set('foo', 1); $this->assertTrue($this->instance->exists('foo')); } - public function testNotExistsAfterRemove() { + public function testNotExistsAfterRemove(): void { $this->instance->set('foo', 1); $this->instance->remove('foo'); $this->assertFalse($this->instance->exists('foo')); } - public function testGetNonExisting() { + public function testGetNonExisting(): void { $this->assertNull($this->instance->get('foo')); } - public function testGetAfterSet() { + public function testGetAfterSet(): void { $this->instance->set('foo', 'bar'); $this->assertEquals('bar', $this->instance->get(('foo'))); } - public function testRemoveNonExisting() { + public function testRemoveNonExisting(): void { $this->assertFalse($this->instance->exists('foo')); $this->instance->remove('foo'); $this->assertFalse($this->instance->exists('foo')); } - public function testNotExistsAfterClear() { + public function testNotExistsAfterClear(): void { $this->instance->set('foo', 1); $this->instance->clear(); $this->assertFalse($this->instance->exists('foo')); } - public function testArrayInterface() { + public function testArrayInterface(): void { $this->assertFalse(isset($this->instance['foo'])); $this->instance['foo'] = 'bar'; $this->assertTrue(isset($this->instance['foo'])); |