5use PHPUnit\Framework\TestCase;
44 if ($this->step_2_precondition && $num === 2) {
58 protected function setUp() : void
60 $this->
base = $this->createMock(Objective::class);
67 $env = $this->createMock(Environment::class);
69 $step1 = $this->test1->getStep(1);
71 $this->assertInstanceOf(ilDatabaseUpdateStep::class, $step1);
73 hash(
"sha256", Test_ilDatabaseUpdateSteps::class .
"::step_1"),
77 $preconditions = $step1->getPreconditions($env);
79 $this->assertCount(1, $preconditions);
80 $this->assertSame($this->
base, $preconditions[0]);
85 $env = $this->createMock(Environment::class);
87 $step1 = $this->test1->getStep(1);
88 $step2 = $this->test1->getStep(2);
90 $this->assertInstanceOf(ilDatabaseUpdateStep::class, $step2);
92 hash(
"sha256", Test_ilDatabaseUpdateSteps::class .
"::step_2"),
96 $preconditions = $step2->getPreconditions($env);
98 $this->assertCount(1, $preconditions);
99 $this->assertEquals($step1->getHash(), $preconditions[0]->getHash());
104 $env = $this->createMock(Environment::class);
108 $step1 = $this->test1->getStep(1);
109 $step2 = $this->test1->getStep(2);
113 $this->assertCount(2, $preconditions);
114 $this->assertEquals($step1->getHash(), $preconditions[0]->getHash());
115 $this->assertEquals($this->test1->step_2_precondition, $preconditions[1]);
120 $env = $this->createMock(Environment::class);
122 $step4 = $this->test1->getStep(4, 2);
124 $this->assertInstanceOf(ilDatabaseUpdateStep::class, $step4);
126 hash(
"sha256", Test_ilDatabaseUpdateSteps::class .
"::step_4"),
130 $preconditions = $step4->getPreconditions($env);
132 $this->assertCount(1, $preconditions);
133 $this->assertEquals($this->
base, $preconditions[0]);
138 $env = $this->createMock(Environment::class);
140 $step4 = $this->test1->getStep(4, 1);
141 $step2 = $this->test1->getStep(2, 1);
143 $this->assertInstanceOf(ilDatabaseUpdateStep::class, $step4);
145 hash(
"sha256", Test_ilDatabaseUpdateSteps::class .
"::step_4"),
149 $preconditions = $step4->getPreconditions($env);
151 $this->assertCount(1, $preconditions);
152 $this->assertEquals($step2->getHash(), $preconditions[0]->getHash());
157 $steps = $this->test1->_getSteps();
161 $this->assertEquals($expected, array_values(
$steps));
166 $env = $this->createMock(Environment::class);
167 $db = $this->createMock(\ilDBInterface::class);
170 ->method(
"getResource")
171 ->will($this->returnValueMap([
172 [Environment::RESOURCE_DATABASE, $db],
173 [\ilDatabaseUpdateStepExecutionLog::class,
null]
177 ->expects($this->exactly(3))
181 ->method(
"getPreconditions")
185 ->expects($this->once())
191 while (
$i->valid()) {
192 $current =
$i->current();
193 $env = $current->achieve($env);
194 $i->setEnvironment($env);
198 $this->assertEquals([1,2,4], $this->test1->called);
203 $env = $this->createMock(Environment::class);
204 $log = $this->createMock(\ilDatabaseUpdateStepExecutionLog::class);
205 $db = $this->createMock(\ilDBInterface::class);
208 ->method(
"getResource")
209 ->will($this->returnValueMap([
210 [Environment::RESOURCE_DATABASE, $db],
211 [\ilDatabaseUpdateStepExecutionLog::class,
$log]
215 ->expects($this->atLeastOnce())
216 ->method(
"getLastFinishedStep")
217 ->with(Test_ilDatabaseUpdateSteps::class)
221 ->expects($this->exactly(2))
225 ->method(
"getPreconditions")
229 ->expects($this->once())
235 while (
$i->valid()) {
236 $current =
$i->current();
237 $env = $current->achieve($env);
238 $i->setEnvironment($env);
242 $this->assertEquals([2,4], $this->test1->called);
An exception for terminatinating execution or to throw for unit testing.
Tries to enumerate all preconditions for the given objective, where the ones that can be achieved (i....
A non-objective, nothing to do to achieve it...
getPreconditions(Setup\Environment $environment)
step_2(\ilDBInterface $db)
getAdditionalPreconditionsForStep(int $num)
Get preconditions for steps.
step_1(\ilDBInterface $db)
step_4(\ilDBInterface $db)
testGetStep2WithAdditionalPrecondition()
This base-class simplifies the creation of (consecutive) database updates.
getSteps()
Get the numbers of the steps in this class.
An environment holds resources to be used in the setup process.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
connect($return_false_on_error=false)