Definition at line 14 of file AgentCollectionTest.php.
◆ testArrayToConfigTransformationAllowsUnsetFields()
ILIAS\Tests\Setup\AgentCollectionTest::testArrayToConfigTransformationAllowsUnsetFields |
( |
| ) |
|
Definition at line 97 of file AgentCollectionTest.php.
References $c.
99 $refinery =
new Refinery($this->createMock(DataFactory::class), $this->createMock(\ilLanguage::class));
101 $c1 = $this->newAgent();
102 $c2 = $this->newAgent();
103 $c3 = $this->newAgent();
105 $conf1 = $this->newConfig();
106 $conf3 = $this->newConfig();
108 foreach ([$c1,$c3] as
$c) {
110 ->method(
"hasConfig")
114 ->method(
"hasConfig")
117 $arr = [
"c1" => [
"c1_data"]];
120 ->expects($this->once())
121 ->method(
"getArrayToConfigTransformation")
123 ->willReturn($refinery->custom()->transformation(
function ($v) use ($conf1) {
124 $this->assertEquals($v, [
"c1_data"]);
128 ->expects($this->never())
129 ->method(
"getArrayToConfigTransformation");
131 ->expects($this->once())
132 ->method(
"getArrayToConfigTransformation")
134 ->willReturn($refinery->custom()->transformation(
function ($v) use ($conf3) {
135 $this->assertEquals($v, null);
139 $col =
new Setup\AgentCollection($refinery, [
"c1" => $c1,
"c2" => $c2,
"c3" => $c3]);
140 $trafo = $col->getArrayToConfigTransformation();
141 $conf = $trafo($arr);
143 $this->assertInstanceOf(Setup\ConfigCollection::class, $conf);
144 $this->assertEquals([
"c1",
"c3"], $conf->getKeys());
145 $this->assertEquals($conf1, $conf->getConfig(
"c1"));
146 $this->assertEquals($conf3, $conf->getConfig(
"c3"));
◆ testGetAgent()
ILIAS\Tests\Setup\AgentCollectionTest::testGetAgent |
( |
| ) |
|
Definition at line 254 of file AgentCollectionTest.php.
References $c.
256 $refinery = $this->createMock(Refinery::class);
258 $c1 = $this->newAgent();
259 $c2 = $this->newAgent();
260 $c3 = $this->newAgent();
261 $c4 = $this->newAgent();
263 $c =
new Setup\AgentCollection(
265 [
"c1" => $c1,
"c2" => $c2,
"c3" => $c3,
"c4" => $c4]
268 $this->assertSame($c1,
$c->getAgent(
"c1"));
269 $this->assertSame($c2,
$c->getAgent(
"c2"));
270 $this->assertSame($c3,
$c->getAgent(
"c3"));
271 $this->assertSame($c4,
$c->getAgent(
"c4"));
272 $this->assertNull(
$c->getAgent(
"c5"));
◆ testGetArrayToConfigTransformation()
ILIAS\Tests\Setup\AgentCollectionTest::testGetArrayToConfigTransformation |
( |
| ) |
|
Definition at line 45 of file AgentCollectionTest.php.
References $c.
47 $refinery =
new Refinery($this->createMock(DataFactory::class), $this->createMock(\ilLanguage::class));
49 $c1 = $this->newAgent();
50 $c2 = $this->newAgent();
51 $c3 = $this->newAgent();
53 $conf1 = $this->newConfig();
54 $conf3 = $this->newConfig();
56 foreach ([$c1,$c3] as
$c) {
65 $arr = [
"c1" => [
"c1_data"],
"c3" => [
"c3_data"]];
68 ->expects($this->once())
69 ->method(
"getArrayToConfigTransformation")
71 ->willReturn($refinery->custom()->transformation(
function ($v) use ($conf1) {
72 $this->assertEquals($v, [
"c1_data"]);
76 ->expects($this->never())
77 ->method(
"getArrayToConfigTransformation");
79 ->expects($this->once())
80 ->method(
"getArrayToConfigTransformation")
82 ->willReturn($refinery->custom()->transformation(
function ($v) use ($conf3) {
83 $this->assertEquals($v, [
"c3_data"]);
87 $col =
new Setup\AgentCollection($refinery, [
"c1" => $c1,
"c2" => $c2,
"c3" => $c3]);
88 $trafo = $col->getArrayToConfigTransformation();
91 $this->assertInstanceOf(Setup\ConfigCollection::class, $conf);
92 $this->assertEquals([
"c1",
"c3"], $conf->getKeys());
93 $this->assertEquals($conf1, $conf->getConfig(
"c1"));
94 $this->assertEquals($conf3, $conf->getConfig(
"c3"));
◆ testGetCollectMetricsObjective()
ILIAS\Tests\Setup\AgentCollectionTest::testGetCollectMetricsObjective |
( |
| ) |
|
Definition at line 222 of file AgentCollectionTest.php.
224 $refinery =
new Refinery($this->createMock(DataFactory::class), $this->createMock(\ilLanguage::class));
226 $c1 = $this->newAgent();
227 $c2 = $this->newAgent();
229 $g1 = $this->newObjective();
230 $g2 = $this->newObjective();
232 $conf1 = $this->newConfig();
235 ->expects($this->once())
236 ->method(
"getUpdateObjective")
240 ->expects($this->once())
241 ->method(
"getUpdateObjective")
245 $col =
new Setup\AgentCollection($refinery, [
"c1" => $c1,
"c2" => $c2]);
246 $conf =
new Setup\ConfigCollection([
"c1" => $conf1]);
248 $g = $col->getUpdateObjective($conf);
250 $this->assertInstanceOf(Setup\ObjectiveCollection::class, $g);
251 $this->assertEquals([$g1, $g2], $g->getObjectives());
◆ testGetInstallObjective()
ILIAS\Tests\Setup\AgentCollectionTest::testGetInstallObjective |
( |
| ) |
|
Definition at line 149 of file AgentCollectionTest.php.
151 $refinery =
new Refinery($this->createMock(DataFactory::class), $this->createMock(\ilLanguage::class));
153 $c1 = $this->newAgent();
154 $c2 = $this->newAgent();
156 $g1 = $this->newObjective();
157 $g2 = $this->newObjective();
159 $conf1 = $this->newConfig();
162 ->expects($this->once())
163 ->method(
"hasConfig")
166 ->expects($this->once())
167 ->method(
"hasConfig")
171 ->expects($this->once())
172 ->method(
"getInstallObjective")
176 ->expects($this->once())
177 ->method(
"getInstallObjective")
181 $col =
new Setup\AgentCollection($refinery, [
"c1" => $c1,
"c2" => $c2]);
182 $conf =
new Setup\ConfigCollection([
"c1" => $conf1]);
184 $g = $col->getInstallObjective($conf);
186 $this->assertInstanceOf(Setup\ObjectiveCollection::class, $g);
187 $this->assertEquals([$g1, $g2], $g->getObjectives());
◆ testGetNamedObjective()
ILIAS\Tests\Setup\AgentCollectionTest::testGetNamedObjective |
( |
| ) |
|
Definition at line 335 of file AgentCollectionTest.php.
References $c, and $res.
337 $refinery = $this->createMock(Refinery::class);
339 $o = $this->newObjective();
340 $c1 = $this->newAgent();
341 $c2 = $this->newAgent();
342 $conf2 = $this->newConfig();
344 $conf =
new Setup\ConfigCollection(
345 [
"sub" =>
new Setup\ConfigCollection(
350 $c =
new Setup\AgentCollection(
352 [
"sub" =>
new Setup\AgentCollection(
354 [
"c1" => $c1,
"c2" => $c2]
358 $c2->expects($this->once())
359 ->method(
"getNamedObjective")
360 ->with(
"the_objective", $conf2)
363 $res =
$c->getNamedObjective(
"sub.c2.the_objective", $conf);
364 $this->assertSame($o,
$res);
foreach($_POST as $key=> $value) $res
◆ testGetUpdateObjective()
ILIAS\Tests\Setup\AgentCollectionTest::testGetUpdateObjective |
( |
| ) |
|
Definition at line 190 of file AgentCollectionTest.php.
192 $refinery =
new Refinery($this->createMock(DataFactory::class), $this->createMock(\ilLanguage::class));
193 $storage = $this->createMock(Setup\Metrics\Storage::class);
195 $c1 = $this->newAgent();
196 $c2 = $this->newAgent();
198 $g1 = $this->newObjective();
199 $g2 = $this->newObjective();
201 $s1 =
new Setup\Metrics\StorageOnPathWrapper(
"c1", $storage);
202 $s2 =
new Setup\Metrics\StorageOnPathWrapper(
"c2", $storage);
205 ->expects($this->once())
206 ->method(
"getStatusObjective")
210 ->expects($this->once())
211 ->method(
"getStatusObjective")
215 $col =
new Setup\AgentCollection($refinery, [
"c1" => $c1,
"c2" => $c2]);
216 $g = $col->getStatusObjective($storage);
218 $this->assertInstanceOf(Setup\ObjectiveCollection::class, $g);
219 $this->assertEquals([$g1, $g2], $g->getObjectives());
◆ testHasConfig()
ILIAS\Tests\Setup\AgentCollectionTest::testHasConfig |
( |
| ) |
|
Definition at line 18 of file AgentCollectionTest.php.
20 $refinery =
new Refinery($this->createMock(DataFactory::class), $this->createMock(\ilLanguage::class));
22 $c1 = $this->newAgent();
23 $c2 = $this->newAgent();
24 $c3 = $this->newAgent();
25 $c4 = $this->newAgent();
27 $c1->method(
"hasConfig")->willReturn(
true);
28 $c2->method(
"hasConfig")->willReturn(
true);
29 $c3->method(
"hasConfig")->willReturn(
false);
30 $c4->method(
"hasConfig")->willReturn(
false);
32 $col1 =
new Setup\AgentCollection($refinery, [
"c1" => $c1]);
33 $col2 =
new Setup\AgentCollection($refinery, [
"c1" => $c1,
"c2" => $c2]);
34 $col3 =
new Setup\AgentCollection($refinery, [
"c1" => $c1,
"c3" => $c3]);
35 $col4 =
new Setup\AgentCollection($refinery, [
"c3" => $c3]);
36 $col5 =
new Setup\AgentCollection($refinery, [
"c3" => $c3,
"c4" => $c4]);
38 $this->assertTrue($col1->hasConfig());
39 $this->assertTrue($col2->hasConfig());
40 $this->assertTrue($col3->hasConfig());
41 $this->assertFalse($col4->hasConfig());
42 $this->assertFalse($col5->hasConfig());
◆ testWithAdditionalAgent()
ILIAS\Tests\Setup\AgentCollectionTest::testWithAdditionalAgent |
( |
| ) |
|
Definition at line 305 of file AgentCollectionTest.php.
307 $refinery = $this->createMock(Refinery::class);
309 $c1 = $this->newAgent();
310 $c2 = $this->newAgent();
311 $c3 = $this->newAgent();
312 $c4 = $this->newAgent();
314 $ca =
new Setup\AgentCollection(
316 [
"c1" => $c1,
"c2" => $c2,
"c3" => $c3]
318 $cb = $ca->withAdditionalAgent(
"c4", $c4);
320 $this->assertNotSame($ca, $cb);
322 $this->assertSame($c1, $ca->getAgent(
"c1"));
323 $this->assertSame($c2, $ca->getAgent(
"c2"));
324 $this->assertSame($c3, $ca->getAgent(
"c3"));
325 $this->assertNull($ca->getAgent(
"c4"));
326 $this->assertNull($ca->getAgent(
"c5"));
328 $this->assertSame($c1, $cb->getAgent(
"c1"));
329 $this->assertSame($c2, $cb->getAgent(
"c2"));
330 $this->assertSame($c3, $cb->getAgent(
"c3"));
331 $this->assertSame($c4, $cb->getAgent(
"c4"));
332 $this->assertNull($cb->getAgent(
"c5"));
◆ testWithRemovedAgent()
ILIAS\Tests\Setup\AgentCollectionTest::testWithRemovedAgent |
( |
| ) |
|
Definition at line 275 of file AgentCollectionTest.php.
277 $refinery = $this->createMock(Refinery::class);
279 $c1 = $this->newAgent();
280 $c2 = $this->newAgent();
281 $c3 = $this->newAgent();
282 $c4 = $this->newAgent();
284 $ca =
new Setup\AgentCollection(
286 [
"c1" => $c1,
"c2" => $c2,
"c3" => $c3,
"c4" => $c4]
288 $cb = $ca->withRemovedAgent(
"c2");
290 $this->assertNotSame($ca, $cb);
292 $this->assertSame($c1, $ca->getAgent(
"c1"));
293 $this->assertSame($c2, $ca->getAgent(
"c2"));
294 $this->assertSame($c3, $ca->getAgent(
"c3"));
295 $this->assertSame($c4, $ca->getAgent(
"c4"));
296 $this->assertNull($ca->getAgent(
"c5"));
298 $this->assertSame($c1, $cb->getAgent(
"c1"));
299 $this->assertNull($cb->getAgent(
"c2"));
300 $this->assertSame($c3, $cb->getAgent(
"c3"));
301 $this->assertSame($c4, $cb->getAgent(
"c4"));
302 $this->assertNull($cb->getAgent(
"c5"));
The documentation for this class was generated from the following file: