ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\LegalDocuments\test\ConsumerToolbox\BlocksTest Class Reference
+ Inheritance diagram for ILIAS\LegalDocuments\test\ConsumerToolbox\BlocksTest:
+ Collaboration diagram for ILIAS\LegalDocuments\test\ConsumerToolbox\BlocksTest:

Public Member Functions

 testConstruct ()
 
 testConstructors ()
 
 testGlobalStore ()
 
 testUi ()
 
 testRouting ()
 
 testRetrieveQueryParameter ()
 
 testUserManagementAgreeDateField ()
 
 testWithRequest ()
 
 testWithoutRequest ()
 
 testNotAvailable ()
 

Detailed Description

Definition at line 56 of file BlocksTest.php.

Member Function Documentation

◆ testConstruct()

ILIAS\LegalDocuments\test\ConsumerToolbox\BlocksTest::testConstruct ( )

Definition at line 60 of file BlocksTest.php.

60 : void
61 {
62 $this->assertInstanceOf(Blocks::class, new Blocks('foo', $this->mock(Container::class), $this->mock(Provide::class)));
63 }

◆ testConstructors()

ILIAS\LegalDocuments\test\ConsumerToolbox\BlocksTest::testConstructors ( )

Definition at line 65 of file BlocksTest.php.

65 : void
66 {
67 $instance = new Blocks('foo', $this->mock(Container::class), $this->mock(Provide::class));
68
69 $this->assertInstanceOf(DefaultMappings::class, $instance->defaultMappings());
70 $this->assertInstanceOf(Marshal::class, $instance->marshal());
71 $this->assertInstanceOf(SelectSetting::class, $instance->selectSettingsFrom($this->mock(KeyValueStore::class)));
72 $this->assertInstanceOf(KeyValueStore::class, $instance->readOnlyStore($this->mock(KeyValueStore::class)));
73 $this->assertInstanceOf(KeyValueStore::class, $instance->userStore($this->mock(ilObjUser::class)));
74 $this->assertInstanceOf(KeyValueStore::class, $instance->sessionStore());
75 $this->assertInstanceOf(User::class, $instance->user(
76 $this->mock(Settings::class),
77 $this->mock(UserSettings::class),
78 $this->mock(ilObjUser::class)
79 ));
80 }

◆ testGlobalStore()

ILIAS\LegalDocuments\test\ConsumerToolbox\BlocksTest::testGlobalStore ( )

Definition at line 82 of file BlocksTest.php.

82 : void
83 {
84 $instance = new Blocks(
85 'foo',
86 $this->mockMethod(Container::class, 'settings', [], $this->mock(ilSetting::class)),
87 $this->mock(Provide::class)
88 );
89
90 $this->assertInstanceOf(KeyValueStore::class, $instance->globalStore());
91
92 }

◆ testNotAvailable()

ILIAS\LegalDocuments\test\ConsumerToolbox\BlocksTest::testNotAvailable ( )

Definition at line 217 of file BlocksTest.php.

217 : void
218 {
219 $called = false;
220 $container = $this->mockTree(Container::class, []);
221
222 $instance = new Blocks('foo', $container, $this->mock(Provide::class), null, function () use (&$called): string {
223 $called = true;
224 return 'bar';
225 });
226
227 $result = $instance->notAvailable();
228 $this->assertInstanceOf(PageContent::class, $result);
229 $this->assertTrue($called);
230 }
$container
@noRector
Definition: wac.php:37

References $container, and ILIAS\LegalDocuments\ConsumerToolbox\Blocks\notAvailable().

+ Here is the call graph for this function:

◆ testRetrieveQueryParameter()

ILIAS\LegalDocuments\test\ConsumerToolbox\BlocksTest::testRetrieveQueryParameter ( )

Definition at line 117 of file BlocksTest.php.

117 : void
118 {
119 $selected = new stdClass();
120 $called = false;
121
122 $refinery = $this->mock(Refinery::class);
123 $transformation = $this->mock(Transformation::class);
124
125 $container = $this->mockTree(Container::class, [
126 'refinery' => $refinery,
127 'http' => [
128 'wrapper' => [
129 'query' => $this->mockMethod(ArrayBasedRequestWrapper::class, 'retrieve', ['bar', $transformation], $selected)
130 ],
131 ],
132 ]);
133
134 $instance = new Blocks('foo', $container, $this->mock(Provide::class));
135 $result = $instance->retrieveQueryParameter('bar', function (Refinery $r) use (&$called, $transformation, $refinery): object {
136 $this->assertSame($refinery, $r);
137 $called = true;
138 return $transformation;
139 });
140
141 $this->assertSame($selected, $result);
142 $this->assertTrue($called);
143 }

References $container, and ILIAS\UI\examples\Layout\Page\Standard\$refinery.

◆ testRouting()

ILIAS\LegalDocuments\test\ConsumerToolbox\BlocksTest::testRouting ( )

Definition at line 109 of file BlocksTest.php.

109 : void
110 {
111 $container = $this->mockMethod(Container::class, 'ctrl', [], $this->mock(ilCtrl::class));
112
113 $instance = new Blocks('foo', $container, $this->mock(Provide::class));
114 $this->assertInstanceOf(Routing::class, $instance->routing());
115 }

References $container.

◆ testUi()

ILIAS\LegalDocuments\test\ConsumerToolbox\BlocksTest::testUi ( )

Definition at line 94 of file BlocksTest.php.

94 : void
95 {
96 $container = $this->mock(Container::class);
97 $container->expects(self::once())->method('ui')->willReturn($this->mock(UIServices::class));
98 $container->expects(self::once())->method('language')->willReturn($this->mock(ilLanguage::class));
99
100 $instance = new Blocks(
101 'foo',
103 $this->mock(Provide::class)
104 );
105
106 $this->assertInstanceOf(UI::class, $instance->ui());
107 }

References $container.

◆ testUserManagementAgreeDateField()

ILIAS\LegalDocuments\test\ConsumerToolbox\BlocksTest::testUserManagementAgreeDateField ( )

Definition at line 145 of file BlocksTest.php.

145 : void
146 {
147 $result = $this->mockTree(Result::class, ['value' => 'dummy']);
148 $result->expects(self::once())->method('map')->willReturn($result);
149 $result->expects(self::once())->method('except')->willReturn($result);
150 $user = $this->mock(ilObjUser::class);
151 $date = new DateTimeImmutable();
152 $ldoc_user = $this->mockTree(User::class, [
153 'agreeDate' => ['value' => $date],
154 'acceptedVersion' => $result,
155 ]);
156
157 $language = $this->mock(ilLanguage::class);
158 $consecutive = ['dummy lang', 'ldoc'];
159 $language->expects(self::exactly(2))->method('loadLanguageModule')->with(
160 $this->callback(function ($value) use (&$consecutive) {
161 $this->assertSame(array_shift($consecutive), $value);
162 return true;
163 })
164 );
165
166 $instance = new Blocks(
167 'foo',
168 $this->mockTree(Container::class, ['language' => $language]),
169 $this->mock(Provide::class),
170 function (DateTimeImmutable $d) use ($date) {
171 $this->assertSame($date, $d);
172 return 'formatted date';
173 }
174 );
175 $proc = $instance->userManagementAgreeDateField(function (ilObjUser $u) use ($user, $ldoc_user) {
176 $this->assertSame($user, $u);
177 return $ldoc_user;
178 }, 'foo', 'dummy lang');
179
180 $this->assertSame(['foo' => 'dummy'], $proc($user));
181 }
User class.

References Vendor\Package\$d, and ILIAS\LegalDocuments\ConsumerToolbox\Blocks\userManagementAgreeDateField().

+ Here is the call graph for this function:

◆ testWithoutRequest()

ILIAS\LegalDocuments\test\ConsumerToolbox\BlocksTest::testWithoutRequest ( )

Definition at line 204 of file BlocksTest.php.

204 : void
205 {
206 $container = $this->mockTree(Container::class, [
207 'http' => ['request' => ['getMethod' => 'GET']],
208 ]);
209
210 $form = $this->mock(Form::class);
211
212 $instance = new Blocks('foo', $container, $this->mock(Provide::class));
213 $result = $instance->withRequest($form, $this->fail(...));
214 $this->assertSame($form, $result);
215 }

References $container.

◆ testWithRequest()

ILIAS\LegalDocuments\test\ConsumerToolbox\BlocksTest::testWithRequest ( )

Definition at line 183 of file BlocksTest.php.

183 : void
184 {
185 $data = new stdClass();
186 $called = false;
187
188 $container = $this->mockTree(Container::class, [
189 'http' => ['request' => $this->mockMethod(ServerRequestInterface::class, 'getMethod', [], 'POST')],
190 ]);
191
192 $form = $this->mock(Form::class);
193 $form->expects(self::once())->method('withRequest')->with($container->http()->request())->willReturn($form);
194 $form->expects(self::once())->method('getData')->willReturn($data);
195
196 $instance = new Blocks('foo', $container, $this->mock(Provide::class));
197 $this->assertSame($form, $instance->withRequest($form, function ($x) use ($data, &$called) {
198 $this->assertSame($data, $x);
199 $called = true;
200 }));
201 $this->assertTrue($called);
202 }

References $container, and $data.


The documentation for this class was generated from the following file: