Definition at line 30 of file AgentCollectionTest.php.
◆ testArrayToConfigTransformationAllowsUnsetFields()
| ILIAS\Tests\Setup\AgentCollectionTest::testArrayToConfigTransformationAllowsUnsetFields |
( |
| ) |
|
Definition at line 113 of file AgentCollectionTest.php.
References Vendor\Package\$c, and ILIAS\Repository\$refinery.
115 $refinery =
new Refinery($this->createMock(DataFactory::class), $this->createMock(\ilLanguage::class));
117 $c1 = $this->newAgent();
118 $c2 = $this->newAgent();
119 $c3 = $this->newAgent();
121 $conf1 = $this->newConfig();
122 $conf3 = $this->newConfig();
124 foreach ([$c1,$c3] as
$c) {
126 ->method(
"hasConfig")
130 ->method(
"hasConfig")
133 $arr = [
"c1" => [
"c1_data"]];
136 ->expects($this->once())
137 ->method(
"getArrayToConfigTransformation")
139 ->willReturn(
$refinery->custom()->transformation(
function ($v) use ($conf1) {
140 $this->assertEquals($v, [
"c1_data"]);
144 ->expects($this->never())
145 ->method(
"getArrayToConfigTransformation");
147 ->expects($this->once())
148 ->method(
"getArrayToConfigTransformation")
150 ->willReturn(
$refinery->custom()->transformation(
function ($v) use ($conf3) {
151 $this->assertEquals($v, null);
155 $col =
new Setup\AgentCollection(
$refinery, [
"c1" => $c1,
"c2" => $c2,
"c3" => $c3]);
156 $trafo = $col->getArrayToConfigTransformation();
157 $conf = $trafo($arr);
159 $this->assertInstanceOf(Setup\ConfigCollection::class, $conf);
160 $this->assertEquals([
"c1",
"c3"], $conf->getKeys());
161 $this->assertEquals($conf1, $conf->getConfig(
"c1"));
162 $this->assertEquals($conf3, $conf->getConfig(
"c3"));
Refinery Factory $refinery
◆ testGetAgent()
| ILIAS\Tests\Setup\AgentCollectionTest::testGetAgent |
( |
| ) |
|
Definition at line 272 of file AgentCollectionTest.php.
References Vendor\Package\$c, and ILIAS\Repository\$refinery.
274 $refinery = $this->createMock(Refinery::class);
276 $c1 = $this->newAgent();
277 $c2 = $this->newAgent();
278 $c3 = $this->newAgent();
279 $c4 = $this->newAgent();
281 $c =
new Setup\AgentCollection(
283 [
"c1" => $c1,
"c2" => $c2,
"c3" => $c3,
"c4" => $c4]
286 $this->assertSame($c1,
$c->getAgent(
"c1"));
287 $this->assertSame($c2,
$c->getAgent(
"c2"));
288 $this->assertSame($c3,
$c->getAgent(
"c3"));
289 $this->assertSame($c4,
$c->getAgent(
"c4"));
290 $this->assertNull(
$c->getAgent(
"c5"));
Refinery Factory $refinery
◆ testGetAgents()
| ILIAS\Tests\Setup\AgentCollectionTest::testGetAgents |
( |
| ) |
|
Definition at line 494 of file AgentCollectionTest.php.
References ILIAS\Repository\$refinery.
496 $refinery = $this->createMock(Refinery::class);
498 $c1 = $this->newAgent();
499 $c2 = $this->newAgent();
500 $c3 = $this->newAgent();
501 $c4 = $this->newAgent();
503 $agentCollection =
new Setup\AgentCollection(
505 [
"c1" => $c1,
"c2" => $c2,
"c3" => $c3,
"c4" => $c4]
508 $this->assertEquals([
513 ], $agentCollection->getAgents());
Refinery Factory $refinery
◆ testGetArrayToConfigTransformation()
| ILIAS\Tests\Setup\AgentCollectionTest::testGetArrayToConfigTransformation |
( |
| ) |
|
Definition at line 61 of file AgentCollectionTest.php.
References Vendor\Package\$c, and ILIAS\Repository\$refinery.
63 $refinery =
new Refinery($this->createMock(DataFactory::class), $this->createMock(\ilLanguage::class));
65 $c1 = $this->newAgent();
66 $c2 = $this->newAgent();
67 $c3 = $this->newAgent();
69 $conf1 = $this->newConfig();
70 $conf3 = $this->newConfig();
72 foreach ([$c1,$c3] as
$c) {
81 $arr = [
"c1" => [
"c1_data"],
"c3" => [
"c3_data"]];
84 ->expects($this->once())
85 ->method(
"getArrayToConfigTransformation")
87 ->willReturn(
$refinery->custom()->transformation(
function ($v) use ($conf1) {
88 $this->assertEquals($v, [
"c1_data"]);
92 ->expects($this->never())
93 ->method(
"getArrayToConfigTransformation");
95 ->expects($this->once())
96 ->method(
"getArrayToConfigTransformation")
98 ->willReturn(
$refinery->custom()->transformation(
function ($v) use ($conf3) {
99 $this->assertEquals($v, [
"c3_data"]);
103 $col =
new Setup\AgentCollection(
$refinery, [
"c1" => $c1,
"c2" => $c2,
"c3" => $c3]);
104 $trafo = $col->getArrayToConfigTransformation();
105 $conf = $trafo($arr);
107 $this->assertInstanceOf(Setup\ConfigCollection::class, $conf);
108 $this->assertEquals([
"c1",
"c3"], $conf->getKeys());
109 $this->assertEquals($conf1, $conf->getConfig(
"c1"));
110 $this->assertEquals($conf3, $conf->getConfig(
"c3"));
Refinery Factory $refinery
◆ testGetCollectMetricsObjective()
| ILIAS\Tests\Setup\AgentCollectionTest::testGetCollectMetricsObjective |
( |
| ) |
|
Definition at line 240 of file AgentCollectionTest.php.
References ILIAS\Repository\$refinery.
242 $refinery =
new Refinery($this->createMock(DataFactory::class), $this->createMock(\ilLanguage::class));
244 $c1 = $this->newAgent();
245 $c2 = $this->newAgent();
247 $g1 = $this->newObjective();
248 $g2 = $this->newObjective();
250 $conf1 = $this->newConfig();
253 ->expects($this->once())
254 ->method(
"getUpdateObjective")
258 ->expects($this->once())
259 ->method(
"getUpdateObjective")
263 $col =
new Setup\AgentCollection(
$refinery, [
"c1" => $c1,
"c2" => $c2]);
264 $conf =
new Setup\ConfigCollection([
"c1" => $conf1]);
266 $g = $col->getUpdateObjective($conf);
268 $this->assertInstanceOf(Setup\ObjectiveCollection::class, $g);
269 $this->assertEquals([$g1, $g2], $g->getObjectives());
Refinery Factory $refinery
◆ testGetInstallObjective()
| ILIAS\Tests\Setup\AgentCollectionTest::testGetInstallObjective |
( |
| ) |
|
Definition at line 165 of file AgentCollectionTest.php.
References ILIAS\Repository\$refinery.
167 $refinery =
new Refinery($this->createMock(DataFactory::class), $this->createMock(\ilLanguage::class));
169 $c1 = $this->newAgent();
170 $c2 = $this->newAgent();
172 $g1 = $this->newObjective();
173 $g2 = $this->newObjective();
175 $conf1 = $this->newConfig();
178 ->expects($this->once())
179 ->method(
"hasConfig")
182 ->expects($this->once())
183 ->method(
"hasConfig")
187 ->expects($this->once())
188 ->method(
"getInstallObjective")
192 ->expects($this->once())
193 ->method(
"getInstallObjective")
197 $col =
new Setup\AgentCollection(
$refinery, [
"c1" => $c1,
"c2" => $c2]);
198 $conf =
new Setup\ConfigCollection([
"c1" => $conf1]);
200 $g = $col->getInstallObjective($conf);
202 $this->assertInstanceOf(Setup\ObjectiveCollection::class, $g);
203 $this->assertEquals([$g1, $g2], $g->getObjectives());
Refinery Factory $refinery
◆ testGetNamedObjectivePassesCorrectConfig()
| ILIAS\Tests\Setup\AgentCollectionTest::testGetNamedObjectivePassesCorrectConfig |
( |
| ) |
|
Definition at line 466 of file AgentCollectionTest.php.
References ILIAS\Repository\$refinery.
468 $refinery = $this->createMock(Refinery::class);
469 $agent = $this->newAgent();
473 ->method(
"getNamedObjectives")
474 ->will($this->returnCallback(
function ($config) use (&$seen_config) {
475 $seen_config = $config;
479 $collection =
new Setup\AgentCollection(
484 $agent_config = $this->createMock(Setup\Config::class);
485 $config =
new Setup\ConfigCollection(
486 [
"agent" => $agent_config]
489 $result = $collection->getNamedObjectives($config);
491 $this->assertSame($agent_config, $seen_config);
Refinery Factory $refinery
◆ testGetNamedObjectives()
| ILIAS\Tests\Setup\AgentCollectionTest::testGetNamedObjectives |
( |
| ) |
|
Definition at line 426 of file AgentCollectionTest.php.
References ILIAS\Repository\$refinery.
428 $refinery = $this->createMock(Refinery::class);
429 $config =
new Setup\ConfigCollection([]);
431 $aAgent = $this->newAgent();
432 $bAgent = $this->newAgent();
435 "a-1" => $this->newObjectiveConstructor(),
436 "a-2" => $this->newObjectiveConstructor()
440 "b-1" => $this->newObjectiveConstructor(),
441 "b-2" => $this->newObjectiveConstructor(),
445 ->expects($this->once())
446 ->method(
"getNamedObjectives")
447 ->willReturn($aReturn);
449 ->expects($this->once())
450 ->method(
"getNamedObjectives")
451 ->willReturn($bReturn);
453 $testAgentCollection =
new Setup\AgentCollection(
455 [
"aAgent" => $aAgent,
"bAgent" => $bAgent]
458 $result = $testAgentCollection->getNamedObjectives($config);
460 $this->assertSame($aReturn[
"a-1"], $result[
"aAgent.a-1"]);
461 $this->assertSame($aReturn[
"a-2"], $result[
"aAgent.a-2"]);
462 $this->assertSame($bReturn[
"b-1"], $result[
"bAgent.b-1"]);
463 $this->assertSame($bReturn[
"b-2"], $result[
"bAgent.b-2"]);
Refinery Factory $refinery
◆ testGetNamedObjectivesSorting()
| ILIAS\Tests\Setup\AgentCollectionTest::testGetNamedObjectivesSorting |
( |
| ) |
|
Definition at line 353 of file AgentCollectionTest.php.
References ILIAS\Repository\$refinery.
355 $refinery = $this->createMock(Refinery::class);
356 $config =
new Setup\ConfigCollection([]);
358 $aAgent = $this->newAgent();
359 $bAgent = $this->newAgent();
360 $cAgent = $this->newAgent();
361 $dAgent = $this->newAgent();
364 "a-2" => $this->newObjectiveConstructor(),
365 "a-1" => $this->newObjectiveConstructor()
369 "b-1" => $this->newObjectiveConstructor(),
370 "b-3" => $this->newObjectiveConstructor(),
371 "b-2" => $this->newObjectiveConstructor(),
375 "c-2" => $this->newObjectiveConstructor(),
376 "c-1" => $this->newObjectiveConstructor()
380 "d-2" => $this->newObjectiveConstructor(),
381 "d-3" => $this->newObjectiveConstructor(),
382 "d-1" => $this->newObjectiveConstructor()
386 ->expects($this->once())
387 ->method(
"getNamedObjectives")
388 ->willReturn($aReturn);
391 ->expects($this->once())
392 ->method(
"getNamedObjectives")
393 ->willReturn($bReturn);
396 ->expects($this->once())
397 ->method(
"getNamedObjectives")
398 ->willReturn($cReturn);
401 ->expects($this->once())
402 ->method(
"getNamedObjectives")
403 ->willReturn($dReturn);
405 $testAgentCollection =
new Setup\AgentCollection(
407 [
"aAgent" => $aAgent,
"cAgent" => $cAgent,
"bAgent" => $bAgent,
"dAgent" => $dAgent]
411 "aAgent.a-1" => $aReturn[
"a-1"],
412 "aAgent.a-2" => $aReturn[
"a-2"],
413 "bAgent.b-1" => $bReturn[
"b-1"],
414 "bAgent.b-2" => $bReturn[
"b-2"],
415 "bAgent.b-3" => $bReturn[
"b-3"],
416 "cAgent.c-1" => $cReturn[
"c-1"],
417 "cAgent.c-2" => $cReturn[
"c-2"],
418 "dAgent.d-1" => $dReturn[
"d-1"],
419 "dAgent.d-2" => $dReturn[
"d-2"],
420 "dAgent.d-3" => $dReturn[
"d-3"],
423 $this->assertSame($expected, $testAgentCollection->getNamedObjectives($config));
Refinery Factory $refinery
◆ testGetUpdateObjective()
| ILIAS\Tests\Setup\AgentCollectionTest::testGetUpdateObjective |
( |
| ) |
|
Definition at line 206 of file AgentCollectionTest.php.
References ILIAS\Repository\$refinery.
208 $refinery =
new Refinery($this->createMock(DataFactory::class), $this->createMock(\ilLanguage::class));
209 $storage = $this->createMock(Setup\Metrics\Storage::class);
211 $c1 = $this->newAgent();
212 $c2 = $this->newAgent();
214 $g1 = $this->newObjective();
215 $g2 = $this->newObjective();
217 $s1 =
new Setup\Metrics\StorageOnPathWrapper(
"c1", $storage);
218 $s2 =
new Setup\Metrics\StorageOnPathWrapper(
"c2", $storage);
221 ->expects($this->once())
222 ->method(
"getStatusObjective")
226 ->expects($this->once())
227 ->method(
"getStatusObjective")
231 $col =
new Setup\AgentCollection(
$refinery, [
"c1" => $c1,
"c2" => $c2]);
232 $conf =
new Setup\ConfigCollection([
"c1" => $c1]);
234 $g = $col->getStatusObjective($storage);
236 $this->assertInstanceOf(Setup\ObjectiveCollection::class, $g);
237 $this->assertEquals([$g1, $g2], $g->getObjectives());
Refinery Factory $refinery
◆ testHasConfig()
| ILIAS\Tests\Setup\AgentCollectionTest::testHasConfig |
( |
| ) |
|
Definition at line 34 of file AgentCollectionTest.php.
References ILIAS\Repository\$refinery.
36 $refinery =
new Refinery($this->createMock(DataFactory::class), $this->createMock(\ilLanguage::class));
38 $c1 = $this->newAgent();
39 $c2 = $this->newAgent();
40 $c3 = $this->newAgent();
41 $c4 = $this->newAgent();
43 $c1->method(
"hasConfig")->willReturn(
true);
44 $c2->method(
"hasConfig")->willReturn(
true);
45 $c3->method(
"hasConfig")->willReturn(
false);
46 $c4->method(
"hasConfig")->willReturn(
false);
48 $col1 =
new Setup\AgentCollection(
$refinery, [
"c1" => $c1]);
49 $col2 =
new Setup\AgentCollection(
$refinery, [
"c1" => $c1,
"c2" => $c2]);
50 $col3 =
new Setup\AgentCollection(
$refinery, [
"c1" => $c1,
"c3" => $c3]);
51 $col4 =
new Setup\AgentCollection(
$refinery, [
"c3" => $c3]);
52 $col5 =
new Setup\AgentCollection(
$refinery, [
"c3" => $c3,
"c4" => $c4]);
54 $this->assertTrue($col1->hasConfig());
55 $this->assertTrue($col2->hasConfig());
56 $this->assertTrue($col3->hasConfig());
57 $this->assertFalse($col4->hasConfig());
58 $this->assertFalse($col5->hasConfig());
Refinery Factory $refinery
◆ testWithAdditionalAgent()
| ILIAS\Tests\Setup\AgentCollectionTest::testWithAdditionalAgent |
( |
| ) |
|
Definition at line 323 of file AgentCollectionTest.php.
References ILIAS\Repository\$refinery.
325 $refinery = $this->createMock(Refinery::class);
327 $c1 = $this->newAgent();
328 $c2 = $this->newAgent();
329 $c3 = $this->newAgent();
330 $c4 = $this->newAgent();
332 $ca =
new Setup\AgentCollection(
334 [
"c1" => $c1,
"c2" => $c2,
"c3" => $c3]
336 $cb = $ca->withAdditionalAgent(
"c4", $c4);
338 $this->assertNotSame($ca, $cb);
340 $this->assertSame($c1, $ca->getAgent(
"c1"));
341 $this->assertSame($c2, $ca->getAgent(
"c2"));
342 $this->assertSame($c3, $ca->getAgent(
"c3"));
343 $this->assertNull($ca->getAgent(
"c4"));
344 $this->assertNull($ca->getAgent(
"c5"));
346 $this->assertSame($c1, $cb->getAgent(
"c1"));
347 $this->assertSame($c2, $cb->getAgent(
"c2"));
348 $this->assertSame($c3, $cb->getAgent(
"c3"));
349 $this->assertSame($c4, $cb->getAgent(
"c4"));
350 $this->assertNull($cb->getAgent(
"c5"));
Refinery Factory $refinery
◆ testWithRemovedAgent()
| ILIAS\Tests\Setup\AgentCollectionTest::testWithRemovedAgent |
( |
| ) |
|
Definition at line 293 of file AgentCollectionTest.php.
References ILIAS\Repository\$refinery.
295 $refinery = $this->createMock(Refinery::class);
297 $c1 = $this->newAgent();
298 $c2 = $this->newAgent();
299 $c3 = $this->newAgent();
300 $c4 = $this->newAgent();
302 $ca =
new Setup\AgentCollection(
304 [
"c1" => $c1,
"c2" => $c2,
"c3" => $c3,
"c4" => $c4]
306 $cb = $ca->withRemovedAgent(
"c2");
308 $this->assertNotSame($ca, $cb);
310 $this->assertSame($c1, $ca->getAgent(
"c1"));
311 $this->assertSame($c2, $ca->getAgent(
"c2"));
312 $this->assertSame($c3, $ca->getAgent(
"c3"));
313 $this->assertSame($c4, $ca->getAgent(
"c4"));
314 $this->assertNull($ca->getAgent(
"c5"));
316 $this->assertSame($c1, $cb->getAgent(
"c1"));
317 $this->assertNull($cb->getAgent(
"c2"));
318 $this->assertSame($c3, $cb->getAgent(
"c3"));
319 $this->assertSame($c4, $cb->getAgent(
"c4"));
320 $this->assertNull($cb->getAgent(
"c5"));
Refinery Factory $refinery
The documentation for this class was generated from the following file: