19declare(strict_types=1);
25use PHPUnit\Framework\Attributes\BackupGlobals;
26use PHPUnit\Framework\TestCase;
35 protected function setUp(): void
44 $this->
repository->write($this->
namespace,
'sort',
'"title"');
46 $this->assertSame([
'kvs:my_component.view_state:sort' =>
'"title"'], $_SESSION);
51 $this->
repository->write($this->
namespace,
'sort',
'"title"');
53 $this->assertTrue($this->
repository->has($this->namespace,
'sort'));
54 $this->assertSame(
'"title"', $this->
repository->read($this->namespace,
'sort'));
59 $this->assertFalse($this->
repository->has($this->namespace,
'sort'));
60 $this->assertNull($this->
repository->read($this->namespace,
'sort'));
65 $_SESSION[
'kvs:my_component.view_state:sort'] = [
'not',
'a',
'string'];
67 $this->assertNull($this->
repository->read($this->namespace,
'sort'));
72 $this->
repository->write($this->
namespace,
'a',
'1');
73 $this->
repository->write($this->
namespace,
'b',
'2');
75 $this->
repository->remove($this->
namespace,
'a');
77 $this->assertFalse($this->
repository->has($this->namespace,
'a'));
78 $this->assertTrue($this->
repository->has($this->namespace,
'b'));
85 $this->
repository->write($this->
namespace,
'a',
'1');
88 $_SESSION[
'AccountId'] = 6;
90 $this->
repository->removeAll($this->
namespace);
92 $this->assertFalse($this->
repository->has($this->namespace,
'a'));
93 $this->assertTrue($this->
repository->has($nested,
'a'));
94 $this->assertTrue($this->
repository->has($sibling,
'a'));
95 $this->assertSame(6, $_SESSION[
'AccountId']);
100 $this->
repository->removeAll($this->
namespace);
102 $this->assertSame([], $_SESSION);
107 $_SESSION[
'AccountId'] = 6;
108 $_SESSION[
'_authsession'] = [
'user' =>
'root'];
110 $this->
repository->removeAll($this->
namespace);
112 $this->assertSame([
'AccountId' => 6,
'_authsession' => [
'user' =>
'root']], $_SESSION);
126 $this->
repository->write($this->
namespace,
'sort',
'"title"');
127 $this->
repository->write($this->
namespace,
'limit',
'10');
130 [
'sort' =>
'"title"',
'limit' =>
'10'],
137 $this->
repository->write($this->
namespace,
'a',
'1');
138 $this->
repository->write($this->
namespace,
'ab',
'2');
140 $this->assertSame([
'a' =>
'1',
'ab' =>
'2'], $this->
repository->readAll($this->namespace));
147 $this->
repository->write($this->
namespace,
'a',
'1');
150 $_SESSION[
'AccountId'] = 6;
151 $_SESSION[
'kvs:my_component.view_state:sort'] = [
'not',
'a',
'string'];
153 $this->assertSame([
'a' =>
'1'], $this->
repository->readAll($this->namespace));
154 $this->assertSame(6, $_SESSION[
'AccountId']);
159 $this->assertSame([], $this->
repository->readAll($this->namespace));
Keeps key-value storage in the ILIAS session.
Isolates the keys of one consumer from every other consumer of a storage.
testReadAllLeavesOtherNamespacesAndForeignSessionValuesAlone()
SessionRepository $repository
testRemoveDropsOneEntry()
testRemoveAllOnAnEmptySessionDoesNothing()
testWhatWasWrittenCanBeReadBack()
testReadAllReturnsEveryEntryOfTheNamespace()
testReadAllDoesNotConfuseAKeyWithThePrefixOfAnother()
testANamespaceCannotReachTheEntryOfAnother()
testReadAllOnAnEmptySessionIsEmpty()
testRemoveAllLeavesASessionThatHoldsNoEntriesUntouched()
testAForeignSessionVariableIsNotMistakenForAnEntry()
StorageNamespace $namespace
testAnAbsentEntryReadsAsNull()
testRemoveAllLeavesOtherNamespacesAndTheRestOfTheSessionAlone()
testEachEntryIsASessionVariableOfItsOwn()