Definition at line 11 of file ObjectiveIteratorTest.php.
◆ newObjective()
ILIAS\Tests\Setup\ObjectiveIteratorTest::newObjective |
( |
|
$hash = null | ) |
|
|
protected |
Definition at line 209 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().
214 ->getMockBuilder(Setup\Objective::class)
215 ->setMethods([
"getHash",
"getLabel",
"isNotable",
"withResourcesFrom",
"getPreconditions",
"achieve",
"isApplicable"])
216 ->setMockClassName(
"Mock_ObjectiveNo" . ($no++))
221 ->willReturn($hash ??
"" . $no);
◆ testAllObjectives()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testAllObjectives |
( |
| ) |
|
Definition at line 58 of file ObjectiveIteratorTest.php.
References ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
60 $environment = $this->createMock(Setup\Environment::class);
68 ->method(
"getPreconditions")
70 ->willReturn([$objective11, $objective12]);
73 ->method(
"getPreconditions")
78 ->method(
"getPreconditions")
80 ->willReturn([$objective121]);
83 ->method(
"getPreconditions")
87 $iterator =
new Setup\ObjectiveIterator($environment, $objective1);
90 $objective11->getHash() => $objective11,
91 $objective121->getHash() => $objective121,
92 $objective12->getHash() => $objective12,
93 $objective1->getHash() => $objective1
96 $this->assertEquals($expected, iterator_to_array($iterator));
◆ testAllObjectivesDetectsCycle()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testAllObjectivesDetectsCycle |
( |
| ) |
|
Definition at line 125 of file ObjectiveIteratorTest.php.
References ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
127 $environment = $this->createMock(Setup\Environment::class);
133 ->method(
"getPreconditions")
135 ->willReturn([$objective2]);
138 ->method(
"getPreconditions")
140 ->willReturn([$objective1]);
142 $this->expectException(Setup\UnachievableException::class);
144 $iterator =
new Setup\ObjectiveIterator($environment, $objective1);
145 iterator_to_array($iterator);
◆ testAllObjectivesOnlyReturnsObjectiveOnce()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testAllObjectivesOnlyReturnsObjectiveOnce |
( |
| ) |
|
Definition at line 99 of file ObjectiveIteratorTest.php.
References ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
101 $environment = $this->createMock(Setup\Environment::class);
107 ->method(
"getPreconditions")
109 ->willReturn([$objective11, $objective11]);
112 ->method(
"getPreconditions")
116 $iterator =
new Setup\ObjectiveIterator($environment, $objective1);
119 $objective11->getHash() => $objective11,
120 $objective1->getHash() => $objective1
122 $this->assertEquals($expected, iterator_to_array($iterator));
◆ testBasicAlgorithm()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testBasicAlgorithm |
( |
| ) |
|
Definition at line 13 of file ObjectiveIteratorTest.php.
References ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
17 $environment = $this->createMock(Setup\Environment::class);
20 ->expects($this->once())
21 ->method(
"getPreconditions")
25 $iterator =
new Setup\ObjectiveIterator($environment, $objective);
27 $this->assertTrue($iterator->valid());
28 $this->assertSame($objective, $iterator->current());
29 $this->assertSame($hash, $iterator->key());
33 $this->assertFalse($iterator->valid());
◆ testFailedPreconditionLastOnStack()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testFailedPreconditionLastOnStack |
( |
| ) |
|
Definition at line 263 of file ObjectiveIteratorTest.php.
References ILIAS\GlobalScreen\Provider\__construct(), ILIAS\__construct(), and ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
265 $this->expectException(Setup\UnachievableException::class);
267 $env =
new Setup\ArrayEnvironment([]);
274 ->method(
"getPreconditions")
275 ->willReturn([$objective_fail]);
277 ->method(
"getPreconditions")
278 ->willReturn([$objective_1]);
280 $iterator =
new class($env, $objective_2, $objective_fail) extends Setup\ObjectiveIterator {
282 Setup\Environment $environment,
283 Setup\Objective $objective,
284 MockObject $objective_fail
287 $this->failed[$objective_fail->getHash()] =
true;
291 $this->assertEquals($objective_fail, $iterator->current());
__construct(Container $dic, ilPlugin $plugin)
__construct($a_client_id=0)
Constructor setup ILIAS global object public.
◆ testFailedPreconditionWithOtherOnStack()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testFailedPreconditionWithOtherOnStack |
( |
| ) |
|
Definition at line 226 of file ObjectiveIteratorTest.php.
References ILIAS\GlobalScreen\Provider\__construct(), ILIAS\__construct(), and ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
228 $this->expectException(Setup\UnachievableException::class);
230 $env =
new Setup\ArrayEnvironment([]);
238 ->method(
"getPreconditions")
239 ->willReturn([$objective_fail]);
241 ->method(
"getPreconditions")
244 ->method(
"getPreconditions")
245 ->willReturn([$objective_1, $objective_2]);
247 $iterator =
new class($env, $objective_3, $objective_fail) extends Setup\ObjectiveIterator {
249 Setup\Environment $environment,
250 Setup\Objective $objective,
251 MockObject $objective_fail
254 $this->failed[$objective_fail->getHash()] =
true;
258 $this->assertEquals($objective_fail, $iterator->current());
__construct(Container $dic, ilPlugin $plugin)
__construct($a_client_id=0)
Constructor setup ILIAS global object public.
◆ testMarkFailed()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testMarkFailed |
( |
| ) |
|
Definition at line 174 of file ObjectiveIteratorTest.php.
References ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
176 $this->expectException(Setup\UnachievableException::class);
178 $env =
new Setup\ArrayEnvironment([]);
186 ->method(
"getPreconditions")
190 ->method(
"getPreconditions")
194 ->method(
"getPreconditions")
195 ->willReturn([$objective_1, $objective_fail, $objective_2]);
197 $iterator =
new Setup\ObjectiveIterator($env, $objective_3);
200 $this->assertEquals($objective_1, $iterator->current());
202 $this->assertEquals($objective_fail, $iterator->current());
203 $iterator->markAsFailed($objective_fail);
205 $this->assertEquals($objective_2, $iterator->current());
◆ testRewind()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testRewind |
( |
| ) |
|
Definition at line 36 of file ObjectiveIteratorTest.php.
References ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
40 $environment = $this->createMock(Setup\Environment::class);
42 $iterator =
new Setup\ObjectiveIterator($environment, $objective);
45 ->expects($this->once())
46 ->method(
"getPreconditions")
53 $this->assertTrue($iterator->valid());
54 $this->assertSame($objective, $iterator->current());
55 $this->assertSame($hash, $iterator->key());
◆ testSetEnvironment()
ILIAS\Tests\Setup\ObjectiveIteratorTest::testSetEnvironment |
( |
| ) |
|
Definition at line 148 of file ObjectiveIteratorTest.php.
References ILIAS\Tests\Setup\ObjectiveIteratorTest\newObjective().
150 $env1 =
new Setup\ArrayEnvironment([]);
151 $env2 =
new Setup\ArrayEnvironment([]);
157 ->expects($this->atLeastOnce())
158 ->method(
"getPreconditions")
160 ->willReturn([$objective2]);
163 ->expects($this->atLeastOnce())
164 ->method(
"getPreconditions")
168 $iterator =
new Setup\ObjectiveIterator($env1, $objective1);
170 $iterator->setEnvironment($env2);
The documentation for this class was generated from the following file: