ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
KeyValueStorageTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\Data\Factory as DataFactory;
31use ILIAS\Refinery\Factory as Refinery;
33use PHPUnit\Framework\TestCase;
34
35class KeyValueStorageTest extends TestCase
36{
38 private array $define = [];
39
40 private array|\ArrayAccess $implement;
41
42 private array|\ArrayAccess $contribute;
43
44 private array|\ArrayAccess $internal;
45
46 protected function setUp(): void
47 {
48 $this->define = [];
49 $this->implement = new LazyContainer();
50 $this->contribute = new LazyContainer();
51 $this->internal = new LazyContainer();
52
53 $language = $this->getMockBuilder(\ilLanguage::class)
54 ->disableOriginalConstructor()
55 ->getMock();
56
57 $use = new LazyContainer([
58 SessionRepository::class => $this->createStub(SessionRepository::class),
59 ]);
60 $pull = new LazyContainer([
61 Connection::class => $this->createStub(Connection::class),
62 Refinery::class => new Refinery(new DataFactory(), $language),
63 ]);
64 $unused = new LazyContainer();
65 $seek = new LazyContainer([
66 SubjectProvider::class => [new NamedSubjectProvider()],
67 ]);
68
69 (new \ILIAS\KeyValueStorage())->init(
70 $this->define,
71 $this->implement,
72 $use,
73 $this->contribute,
74 $seek,
75 $unused,
76 $pull,
77 $this->internal
78 );
79 }
80
82 {
83 $this->assertSame(
84 [Services::class, SessionRepository::class],
85 $this->define
86 );
87 }
88
89 public function testTheServicesAreImplemented(): void
90 {
91 $services = $this->implement[Services::class];
92
93 $this->assertInstanceOf(StorageServices::class, $services);
94 $this->assertInstanceOf(Services::class, $services);
95 }
96
98 {
99 $this->assertInstanceOf(
100 DatabaseRepository::class,
101 $this->internal[DatabaseRepository::class]
102 );
103 $this->assertArrayNotHasKey(
104 'ILIAS\KeyValueStorage\Internal\SubjectDatabaseRepository',
105 $this->internal
106 );
107 }
108
110 {
111 $this->assertInstanceOf(SubjectProviders::class, $this->internal[SubjectProviders::class]);
112 }
113
114 public function testTheSetupAgentIsContributed(): void
115 {
116 $agent = $this->contribute[Agent::class];
117
118 $this->assertInstanceOf(\ILIAS\KeyValueStorage\Setup\Agent::class, $agent);
119 }
120}
Builds data types.
Definition: Factory.php:36
Persistent storage in the table owned by this component.
The contributed subject providers, keyed by their name.
Behaves like the containers the component bootstrap hands to init(): a factory closure goes in,...
Wrapper for the Setup to work, as they require a namespace.
Definition: Connection.php:27
Entry point to the namespace-scoped key-value storages of ILIAS.
Definition: Services.php:34
Persistence of the session scope, implemented by the component owning the ILIAS session.
A component that names subjects, contributed via $contribute[\ILIAS\KeyValueStorage\Subject\SubjectPr...
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.