3 declare(strict_types=1);
33 $environment = $this->createMock(Setup\Environment::class);
36 ->expects($this->once())
37 ->method(
"getPreconditions")
43 $this->assertTrue($iterator->valid());
44 $this->assertSame($objective, $iterator->current());
45 $this->assertSame($hash, $iterator->key());
49 $this->assertFalse($iterator->valid());
56 $environment = $this->createMock(Setup\Environment::class);
61 ->expects($this->once())
62 ->method(
"getPreconditions")
69 $this->assertTrue($iterator->valid());
70 $this->assertSame($objective, $iterator->current());
71 $this->assertSame($hash, $iterator->key());
76 $environment = $this->createMock(Setup\Environment::class);
84 ->method(
"getPreconditions")
86 ->willReturn([$objective11, $objective12]);
89 ->method(
"getPreconditions")
94 ->method(
"getPreconditions")
96 ->willReturn([$objective121]);
99 ->method(
"getPreconditions")
106 $objective11->getHash() => $objective11,
107 $objective121->getHash() => $objective121,
108 $objective12->getHash() => $objective12,
109 $objective1->getHash() => $objective1
112 $this->assertEquals($expected, iterator_to_array($iterator));
117 $environment = $this->createMock(Setup\Environment::class);
123 ->method(
"getPreconditions")
125 ->willReturn([$objective11, $objective11]);
128 ->method(
"getPreconditions")
135 $objective11->getHash() => $objective11,
136 $objective1->getHash() => $objective1
138 $this->assertEquals($expected, iterator_to_array($iterator));
143 $environment = $this->createMock(Setup\Environment::class);
149 ->method(
"getPreconditions")
151 ->willReturn([$objective2]);
154 ->method(
"getPreconditions")
156 ->willReturn([$objective1]);
158 $this->expectException(Setup\UnachievableException::class);
161 iterator_to_array($iterator);
173 ->expects($this->atLeastOnce())
174 ->method(
"getPreconditions")
176 ->willReturn([$objective2]);
179 ->expects($this->atLeastOnce())
180 ->method(
"getPreconditions")
186 $iterator->setEnvironment($env2);
192 $this->expectException(Setup\UnachievableException::class);
202 ->method(
"getPreconditions")
206 ->method(
"getPreconditions")
210 ->method(
"getPreconditions")
211 ->willReturn([$objective_1, $objective_fail, $objective_2]);
216 $this->assertEquals($objective_1, $iterator->current());
218 $this->assertEquals($objective_fail, $iterator->current());
219 $iterator->markAsFailed($objective_fail);
221 $this->assertEquals($objective_2, $iterator->current());
230 ->getMockBuilder(Setup\Objective::class)
231 ->onlyMethods([
"getHash",
"getLabel",
"isNotable",
"getPreconditions",
"achieve",
"isApplicable"])
232 ->setMockClassName(
"Mock_ObjectiveNo" . ($no++))
237 ->willReturn($hash ??
"" . $no);
244 $this->expectException(Setup\UnachievableException::class);
254 ->method(
"getPreconditions")
255 ->willReturn([$objective_fail]);
257 ->method(
"getPreconditions")
260 ->method(
"getPreconditions")
261 ->willReturn([$objective_1, $objective_2]);
263 $iterator =
new class ($env, $objective_3, $objective_fail) extends Setup\
ObjectiveIterator {
267 MockObject $objective_fail
270 $this->failed[$objective_fail->getHash()] =
true;
274 $this->assertEquals($objective_fail, $iterator->current());
281 $this->expectException(Setup\UnachievableException::class);
290 ->method(
"getPreconditions")
291 ->willReturn([$objective_fail]);
293 ->method(
"getPreconditions")
294 ->willReturn([$objective_1]);
296 $iterator =
new class ($env, $objective_2, $objective_fail) extends Setup\
ObjectiveIterator {
300 MockObject $objective_fail
303 $this->failed[$objective_fail->getHash()] =
true;
307 $this->assertEquals($objective_fail, $iterator->current());
testFailedPreconditionLastOnStack()
testAllObjectivesOnlyReturnsObjectiveOnce()
An objective is a desired state of the system that is supposed to be created by the setup...
testFailedPreconditionWithOtherOnStack()
__construct()
Constructor setup ILIAS global object public.
testAllObjectivesDetectsCycle()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
Tries to enumerate all preconditions for the given objective, where the ones that can be achieved (i...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...