ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 57 of file ilDatabaseUpdateStepsTest.php.

Member Function Documentation

◆ setUp()

ilDatabaseUpdateStepsTest::setUp ( )
protected

Definition at line 59 of file ilDatabaseUpdateStepsTest.php.

References base().

59  : void
60  {
61  $this->base = $this->createMock(Objective::class);
62 
63  $this->test1 = new Test_ilDatabaseUpdateSteps($this->base);
64  }
base()
Definition: base.php:4
+ Here is the call graph for this function:

◆ testAchieveAllSteps()

ilDatabaseUpdateStepsTest::testAchieveAllSteps ( )

Definition at line 165 of file ilDatabaseUpdateStepsTest.php.

References $i, and base().

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

◆ testAchieveSomeSteps()

ilDatabaseUpdateStepsTest::testAchieveSomeSteps ( )

Definition at line 202 of file ilDatabaseUpdateStepsTest.php.

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

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

◆ testGetAllSteps()

ilDatabaseUpdateStepsTest::testGetAllSteps ( )

Definition at line 156 of file ilDatabaseUpdateStepsTest.php.

References ilDatabaseUpdateSteps\$steps.

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

◆ testGetStep1()

ilDatabaseUpdateStepsTest::testGetStep1 ( )

Definition at line 66 of file ilDatabaseUpdateStepsTest.php.

References base().

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

◆ testGetStep2()

ilDatabaseUpdateStepsTest::testGetStep2 ( )

Definition at line 84 of file ilDatabaseUpdateStepsTest.php.

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

◆ testGetStep2WithAdditionalPrecondition()

ilDatabaseUpdateStepsTest::testGetStep2WithAdditionalPrecondition ( )

Definition at line 103 of file ilDatabaseUpdateStepsTest.php.

References ILIAS\Setup\NullObjective\getPreconditions().

104  {
105  $env = $this->createMock(Environment::class);
106 
107  $this->test1->step_2_precondition = new NullObjective;
108 
109  $step1 = $this->test1->getStep(1);
110  $step2 = $this->test1->getStep(2);
111 
112  $preconditions = $step2->getPreconditions($env);
113 
114  $this->assertCount(2, $preconditions);
115  $this->assertEquals($step1->getHash(), $preconditions[0]->getHash());
116  $this->assertEquals($this->test1->step_2_precondition, $preconditions[1]);
117  }
A non-objective, nothing to do to achieve it...
getPreconditions(Environment $environment)
Objectives might depend on other objectives.
+ Here is the call graph for this function:

◆ testGetStep4Finished1()

ilDatabaseUpdateStepsTest::testGetStep4Finished1 ( )

Definition at line 137 of file ilDatabaseUpdateStepsTest.php.

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

◆ testGetStep4Finished2()

ilDatabaseUpdateStepsTest::testGetStep4Finished2 ( )

Definition at line 119 of file ilDatabaseUpdateStepsTest.php.

References base().

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

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