ILIAS  release_7 Revision v7.30-3-g800a261c036
ilDatabaseUpdateStepsTest Class Reference
+ Inheritance diagram for ilDatabaseUpdateStepsTest:
+ Collaboration diagram for ilDatabaseUpdateStepsTest:

Public Member Functions

 testGetStep1 ()
 
 testGetStep2 ()
 
 testGetStep2WithAdditionalPrecondition ()
 
 testGetStep4Finished2 ()
 
 testGetStep4Finished1 ()
 
 testGetAllSteps ()
 
 testAchieveAllSteps ()
 
 testAchieveSomeSteps ()
 

Protected Member Functions

 setUp ()
 

Detailed Description

Definition at line 56 of file ilDatabaseUpdateStepsTest.php.

Member Function Documentation

◆ setUp()

ilDatabaseUpdateStepsTest::setUp ( )
protected

Definition at line 58 of file ilDatabaseUpdateStepsTest.php.

58 : void
59 {
60 $this->base = $this->createMock(Objective::class);
61
62 $this->test1 = new Test_ilDatabaseUpdateSteps($this->base);
63 }
base()
Definition: base.php:4

References base().

+ Here is the call graph for this function:

◆ testAchieveAllSteps()

ilDatabaseUpdateStepsTest::testAchieveAllSteps ( )

Definition at line 164 of file ilDatabaseUpdateStepsTest.php.

165 {
166 $env = $this->createMock(Environment::class);
167 $db = $this->createMock(\ilDBInterface::class);
168
169 $env
170 ->method("getResource")
171 ->will($this->returnValueMap([
172 [Environment::RESOURCE_DATABASE, $db],
173 [\ilDatabaseUpdateStepExecutionLog::class, null]
174 ]));
175
176 $db
177 ->expects($this->exactly(3))
178 ->method("connect");
179
180 $this->base
181 ->method("getPreconditions")
182 ->willReturn([]);
183
184 $this->base
185 ->expects($this->once())
186 ->method("achieve")
187 ->with($env)
188 ->willReturn($env);
189
190 $i = new ObjectiveIterator($env, $this->test1);
191 while ($i->valid()) {
192 $current = $i->current();
193 $env = $current->achieve($env);
194 $i->setEnvironment($env);
195 $i->next();
196 }
197
198 $this->assertEquals([1,2,4], $this->test1->called);
199 }
Tries to enumerate all preconditions for the given objective, where the ones that can be achieved (i....
$i
Definition: metadata.php:24

References $i, and base().

+ Here is the call graph for this function:

◆ testAchieveSomeSteps()

ilDatabaseUpdateStepsTest::testAchieveSomeSteps ( )

Definition at line 201 of file ilDatabaseUpdateStepsTest.php.

202 {
203 $env = $this->createMock(Environment::class);
204 $log = $this->createMock(\ilDatabaseUpdateStepExecutionLog::class);
205 $db = $this->createMock(\ilDBInterface::class);
206
207 $env
208 ->method("getResource")
209 ->will($this->returnValueMap([
210 [Environment::RESOURCE_DATABASE, $db],
211 [\ilDatabaseUpdateStepExecutionLog::class, $log]
212 ]));
213
214 $log
215 ->expects($this->atLeastOnce())
216 ->method("getLastFinishedStep")
217 ->with(Test_ilDatabaseUpdateSteps::class)
218 ->willReturn(1);
219
220 $db
221 ->expects($this->exactly(2))
222 ->method("connect");
223
224 $this->base
225 ->method("getPreconditions")
226 ->willReturn([]);
227
228 $this->base
229 ->expects($this->once())
230 ->method("achieve")
231 ->with($env)
232 ->willReturn($env);
233
234 $i = new ObjectiveIterator($env, $this->test1);
235 while ($i->valid()) {
236 $current = $i->current();
237 $env = $current->achieve($env);
238 $i->setEnvironment($env);
239 $i->next();
240 }
241
242 $this->assertEquals([2,4], $this->test1->called);
243 }
$log
Definition: result.php:15

References $i, $log, and base().

+ Here is the call graph for this function:

◆ testGetAllSteps()

ilDatabaseUpdateStepsTest::testGetAllSteps ( )

Definition at line 155 of file ilDatabaseUpdateStepsTest.php.

156 {
157 $steps = $this->test1->_getSteps();
158
159 $expected = [1,2,4];
160
161 $this->assertEquals($expected, array_values($steps));
162 }
$steps
Definition: latex.php:3

References $steps.

◆ testGetStep1()

ilDatabaseUpdateStepsTest::testGetStep1 ( )

Definition at line 65 of file ilDatabaseUpdateStepsTest.php.

66 {
67 $env = $this->createMock(Environment::class);
68
69 $step1 = $this->test1->getStep(1);
70
71 $this->assertInstanceOf(ilDatabaseUpdateStep::class, $step1);
72 $this->assertEquals(
73 hash("sha256", Test_ilDatabaseUpdateSteps::class . "::step_1"),
74 $step1->getHash()
75 );
76
77 $preconditions = $step1->getPreconditions($env);
78
79 $this->assertCount(1, $preconditions);
80 $this->assertSame($this->base, $preconditions[0]);
81 }

References base().

+ Here is the call graph for this function:

◆ testGetStep2()

ilDatabaseUpdateStepsTest::testGetStep2 ( )

Definition at line 83 of file ilDatabaseUpdateStepsTest.php.

84 {
85 $env = $this->createMock(Environment::class);
86
87 $step1 = $this->test1->getStep(1);
88 $step2 = $this->test1->getStep(2);
89
90 $this->assertInstanceOf(ilDatabaseUpdateStep::class, $step2);
91 $this->assertEquals(
92 hash("sha256", Test_ilDatabaseUpdateSteps::class . "::step_2"),
93 $step2->getHash()
94 );
95
96 $preconditions = $step2->getPreconditions($env);
97
98 $this->assertCount(1, $preconditions);
99 $this->assertEquals($step1->getHash(), $preconditions[0]->getHash());
100 }

◆ testGetStep2WithAdditionalPrecondition()

ilDatabaseUpdateStepsTest::testGetStep2WithAdditionalPrecondition ( )

Definition at line 102 of file ilDatabaseUpdateStepsTest.php.

103 {
104 $env = $this->createMock(Environment::class);
105
106 $this->test1->step_2_precondition = new ILIAS\Setup\Objective\NullObjective;
107
108 $step1 = $this->test1->getStep(1);
109 $step2 = $this->test1->getStep(2);
110
111 $preconditions = $step2->getPreconditions($env);
112
113 $this->assertCount(2, $preconditions);
114 $this->assertEquals($step1->getHash(), $preconditions[0]->getHash());
115 $this->assertEquals($this->test1->step_2_precondition, $preconditions[1]);
116 }
A non-objective, nothing to do to achieve it...
getPreconditions(Setup\Environment $environment)

References ILIAS\Setup\Objective\NullObjective\getPreconditions().

+ Here is the call graph for this function:

◆ testGetStep4Finished1()

ilDatabaseUpdateStepsTest::testGetStep4Finished1 ( )

Definition at line 136 of file ilDatabaseUpdateStepsTest.php.

137 {
138 $env = $this->createMock(Environment::class);
139
140 $step4 = $this->test1->getStep(4, 1);
141 $step2 = $this->test1->getStep(2, 1);
142
143 $this->assertInstanceOf(ilDatabaseUpdateStep::class, $step4);
144 $this->assertEquals(
145 hash("sha256", Test_ilDatabaseUpdateSteps::class . "::step_4"),
146 $step4->getHash()
147 );
148
149 $preconditions = $step4->getPreconditions($env);
150
151 $this->assertCount(1, $preconditions);
152 $this->assertEquals($step2->getHash(), $preconditions[0]->getHash());
153 }

◆ testGetStep4Finished2()

ilDatabaseUpdateStepsTest::testGetStep4Finished2 ( )

Definition at line 118 of file ilDatabaseUpdateStepsTest.php.

119 {
120 $env = $this->createMock(Environment::class);
121
122 $step4 = $this->test1->getStep(4, 2);
123
124 $this->assertInstanceOf(ilDatabaseUpdateStep::class, $step4);
125 $this->assertEquals(
126 hash("sha256", Test_ilDatabaseUpdateSteps::class . "::step_4"),
127 $step4->getHash()
128 );
129
130 $preconditions = $step4->getPreconditions($env);
131
132 $this->assertCount(1, $preconditions);
133 $this->assertEquals($this->base, $preconditions[0]);
134 }

References base().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: