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);
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());
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"]);
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"));
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);
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"));
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")
184 $g = $col->getInstallObjective($conf);
186 $this->assertInstanceOf(Setup\ObjectiveCollection::class, $g);
187 $this->assertEquals([$g1, $g2], $g->getObjectives());
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();
205 ->expects($this->once())
206 ->method(
"getStatusObjective")
210 ->expects($this->once())
211 ->method(
"getStatusObjective")
216 $g = $col->getStatusObjective($storage);
218 $this->assertInstanceOf(Setup\ObjectiveCollection::class, $g);
219 $this->assertEquals([$g1, $g2], $g->getObjectives());
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")
248 $g = $col->getUpdateObjective($conf);
250 $this->assertInstanceOf(Setup\ObjectiveCollection::class, $g);
251 $this->assertEquals([$g1, $g2], $g->getObjectives());
256 $refinery = $this->createMock(Refinery::class);
258 $c1 = $this->newAgent();
259 $c2 = $this->newAgent();
260 $c3 = $this->newAgent();
261 $c4 = $this->newAgent();
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"));
277 $refinery = $this->createMock(Refinery::class);
279 $c1 = $this->newAgent();
280 $c2 = $this->newAgent();
281 $c3 = $this->newAgent();
282 $c4 = $this->newAgent();
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"));
307 $refinery = $this->createMock(Refinery::class);
309 $c1 = $this->newAgent();
310 $c2 = $this->newAgent();
311 $c3 = $this->newAgent();
312 $c4 = $this->newAgent();
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"));
337 $refinery = $this->createMock(Refinery::class);
339 $o = $this->newObjective();
340 $c1 = $this->newAgent();
341 $c2 = $this->newAgent();
342 $conf2 = $this->newConfig();
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);
testWithAdditionalAgent()
testGetInstallObjective()
An agent that is just a collection of some other agents.
testGetCollectMetricsObjective()
testArrayToConfigTransformationAllowsUnsetFields()
testGetArrayToConfigTransformation()
foreach($_POST as $key=> $value) $res
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A collection of some configurations.