Definition at line 27 of file ObjectiveIteratorTest.php.
◆ newObjective()
ILIAS\Tests\Setup\ObjectiveIteratorTest::newObjective |
( |
|
$hash = null | ) |
|
|
protected |
Definition at line 225 of file ObjectiveIteratorTest.php.
Referenced by ILIAS\Tests\Setup\ObjectiveIteratorTest\testAllObjectives(), ILIAS\Tests\Setup\ObjectiveIteratorTest\testAllObjectivesDetectsCycle(), ILIAS\Tests\Setup\ObjectiveIteratorTest\testAllObjectivesOnlyReturnsObjectiveOnce(), ILIAS\Tests\Setup\ObjectiveIteratorTest\testBasicAlgorithm(), ILIAS\Tests\Setup\ObjectiveIteratorTest\testFailedPreconditionLastOnStack(), ILIAS\Tests\Setup\ObjectiveIteratorTest\testFailedPreconditionWithOtherOnStack(), ILIAS\Tests\Setup\ObjectiveIteratorTest\testMarkFailed(), ILIAS\Tests\Setup\ObjectiveIteratorTest\testRewind(), and ILIAS\Tests\Setup\ObjectiveIteratorTest\testSetEnvironment().
230 ->getMockBuilder(Setup\Objective::class)
231 ->onlyMethods([
"getHash",
"getLabel",
"isNotable",
"getPreconditions",
"achieve",
"isApplicable"])
232 ->setMockClassName(
"Mock_ObjectiveNo" . ($no++))
237 ->willReturn($hash ??
"" . $no);
◆ testAllObjectives()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testAllObjectives |
( |
| ) |
|
Definition at line 74 of file ObjectiveIteratorTest.php.
References ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
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")
103 $iterator =
new Setup\ObjectiveIterator($environment, $objective1);
106 $objective11->getHash() => $objective11,
107 $objective121->getHash() => $objective121,
108 $objective12->getHash() => $objective12,
109 $objective1->getHash() => $objective1
112 $this->assertEquals($expected, iterator_to_array($iterator));
◆ testAllObjectivesDetectsCycle()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testAllObjectivesDetectsCycle |
( |
| ) |
|
Definition at line 141 of file ObjectiveIteratorTest.php.
References ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
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);
160 $iterator =
new Setup\ObjectiveIterator($environment, $objective1);
161 iterator_to_array($iterator);
◆ testAllObjectivesOnlyReturnsObjectiveOnce()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testAllObjectivesOnlyReturnsObjectiveOnce |
( |
| ) |
|
Definition at line 115 of file ObjectiveIteratorTest.php.
References ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
117 $environment = $this->createMock(Setup\Environment::class);
123 ->method(
"getPreconditions")
125 ->willReturn([$objective11, $objective11]);
128 ->method(
"getPreconditions")
132 $iterator =
new Setup\ObjectiveIterator($environment, $objective1);
135 $objective11->getHash() => $objective11,
136 $objective1->getHash() => $objective1
138 $this->assertEquals($expected, iterator_to_array($iterator));
◆ testBasicAlgorithm()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testBasicAlgorithm |
( |
| ) |
|
Definition at line 29 of file ObjectiveIteratorTest.php.
References ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
33 $environment = $this->createMock(Setup\Environment::class);
36 ->expects($this->once())
37 ->method(
"getPreconditions")
41 $iterator =
new Setup\ObjectiveIterator($environment, $objective);
43 $this->assertTrue($iterator->valid());
44 $this->assertSame($objective, $iterator->current());
45 $this->assertSame($hash, $iterator->key());
49 $this->assertFalse($iterator->valid());
◆ testFailedPreconditionLastOnStack()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testFailedPreconditionLastOnStack |
( |
| ) |
|
Definition at line 279 of file ObjectiveIteratorTest.php.
References ILIAS\GlobalScreen\Provider\__construct(), ILIAS\__construct(), and ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
281 $this->expectException(Setup\UnachievableException::class);
283 $env =
new Setup\ArrayEnvironment([]);
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 {
298 Setup\Environment $environment,
299 Setup\Objective $objective,
300 MockObject $objective_fail
303 $this->failed[$objective_fail->getHash()] =
true;
307 $this->assertEquals($objective_fail, $iterator->current());
__construct()
Constructor setup ILIAS global object public.
__construct(Container $dic, ilPlugin $plugin)
◆ testFailedPreconditionWithOtherOnStack()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testFailedPreconditionWithOtherOnStack |
( |
| ) |
|
Definition at line 242 of file ObjectiveIteratorTest.php.
References ILIAS\GlobalScreen\Provider\__construct(), ILIAS\__construct(), and ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
244 $this->expectException(Setup\UnachievableException::class);
246 $env =
new Setup\ArrayEnvironment([]);
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 {
265 Setup\Environment $environment,
266 Setup\Objective $objective,
267 MockObject $objective_fail
270 $this->failed[$objective_fail->getHash()] =
true;
274 $this->assertEquals($objective_fail, $iterator->current());
__construct()
Constructor setup ILIAS global object public.
__construct(Container $dic, ilPlugin $plugin)
◆ testMarkFailed()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testMarkFailed |
( |
| ) |
|
Definition at line 190 of file ObjectiveIteratorTest.php.
References ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
192 $this->expectException(Setup\UnachievableException::class);
194 $env =
new Setup\ArrayEnvironment([]);
202 ->method(
"getPreconditions")
206 ->method(
"getPreconditions")
210 ->method(
"getPreconditions")
211 ->willReturn([$objective_1, $objective_fail, $objective_2]);
213 $iterator =
new Setup\ObjectiveIterator($env, $objective_3);
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());
◆ testRewind()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testRewind |
( |
| ) |
|
Definition at line 52 of file ObjectiveIteratorTest.php.
References ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
56 $environment = $this->createMock(Setup\Environment::class);
58 $iterator =
new Setup\ObjectiveIterator($environment, $objective);
61 ->expects($this->once())
62 ->method(
"getPreconditions")
69 $this->assertTrue($iterator->valid());
70 $this->assertSame($objective, $iterator->current());
71 $this->assertSame($hash, $iterator->key());
◆ testSetEnvironment()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testSetEnvironment |
( |
| ) |
|
Definition at line 164 of file ObjectiveIteratorTest.php.
References ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
166 $env1 =
new Setup\ArrayEnvironment([]);
167 $env2 =
new Setup\ArrayEnvironment([]);
173 ->expects($this->atLeastOnce())
174 ->method(
"getPreconditions")
176 ->willReturn([$objective2]);
179 ->expects($this->atLeastOnce())
180 ->method(
"getPreconditions")
184 $iterator =
new Setup\ObjectiveIterator($env1, $objective1);
186 $iterator->setEnvironment($env2);
The documentation for this class was generated from the following file: