15 $environment = $this->createMock(Setup\Environment::class);
18 ->expects($this->once())
19 ->method(
"getPreconditions")
25 $this->assertTrue($iterator->valid());
26 $this->assertSame($objective, $iterator->current());
27 $this->assertSame($hash, $iterator->key());
31 $this->assertFalse($iterator->valid());
38 $environment = $this->createMock(Setup\Environment::class);
43 ->expects($this->once())
44 ->method(
"getPreconditions")
51 $this->assertTrue($iterator->valid());
52 $this->assertSame($objective, $iterator->current());
53 $this->assertSame($hash, $iterator->key());
58 $environment = $this->createMock(Setup\Environment::class);
66 ->method(
"getPreconditions")
68 ->willReturn([$objective11, $objective12]);
71 ->method(
"getPreconditions")
76 ->method(
"getPreconditions")
78 ->willReturn([$objective121]);
81 ->method(
"getPreconditions")
88 $objective11->getHash() => $objective11,
89 $objective121->getHash() => $objective121,
90 $objective12->getHash() => $objective12,
91 $objective1->getHash() => $objective1
94 $this->assertEquals($expected, iterator_to_array($iterator));
99 $environment = $this->createMock(Setup\Environment::class);
105 ->method(
"getPreconditions")
107 ->willReturn([$objective11, $objective11]);
110 ->method(
"getPreconditions")
117 $objective11->getHash() => $objective11,
118 $objective1->getHash() => $objective1
120 $this->assertEquals($expected, iterator_to_array($iterator));
125 $environment = $this->createMock(Setup\Environment::class);
131 ->method(
"getPreconditions")
133 ->willReturn([$objective2]);
136 ->method(
"getPreconditions")
138 ->willReturn([$objective1]);
140 $this->expectException(Setup\UnachievableException::class);
143 iterator_to_array($iterator);
155 ->expects($this->atLeastOnce())
156 ->method(
"getPreconditions")
158 ->willReturn([$objective2]);
161 ->expects($this->atLeastOnce())
162 ->method(
"getPreconditions")
168 $iterator->setEnvironment($env2);
174 $this->expectException(Setup\UnachievableException::class);
184 ->method(
"getPreconditions")
188 ->method(
"getPreconditions")
192 ->method(
"getPreconditions")
193 ->willReturn([$objective_1, $objective_fail, $objective_2]);
198 $this->assertEquals($objective_1, $iterator->current());
200 $this->assertEquals($objective_fail, $iterator->current());
201 $iterator->markAsFailed($objective_fail);
203 $this->assertEquals($objective_2, $iterator->current());
212 ->getMockBuilder(Setup\Objective::class)
213 ->setMethods([
"getHash",
"getLabel",
"isNotable",
"withResourcesFrom",
"getPreconditions",
"achieve"])
214 ->setMockClassName(
"Mock_ObjectiveNo" . ($no++))
219 ->willReturn($hash ??
"" . $no);
testAllObjectivesDetectsCycle()
testAllObjectivesOnlyReturnsObjectiveOnce()
Tries to enumerate all preconditions for the given objective, where the ones that can be achieved (i...