ILIAS  release_8 Revision v8.24
ilDatabaseUpdateStepsExecutedObjectiveTest Class Reference
+ Inheritance diagram for ilDatabaseUpdateStepsExecutedObjectiveTest:
+ Collaboration diagram for ilDatabaseUpdateStepsExecutedObjectiveTest:

Public Member Functions

 testCorrectExecutionOrder ()
 
 testUsesExecutionLock ()
 
 testOnlyExecuteNonExecutedSteps ()
 
 testExceptionOnNonMatchingStartAndFinished ()
 

Data Fields

Test_ilDatabaseUpdateSteps $steps
 
ilDatabaseUpdateStepsExecutedObjective $objective
 

Protected Member Functions

 setUp ()
 

Detailed Description

Member Function Documentation

◆ setUp()

ilDatabaseUpdateStepsExecutedObjectiveTest::setUp ( )
protected

Definition at line 67 of file ilDatabaseUpdateStepsExecutedObjectiveTest.php.

67 : void
68 {
69 $this->steps = new Test_ilDatabaseUpdateSteps();
70 $this->objective = new ilDatabaseUpdateStepsExecutedObjective($this->steps);
71 }
This class attempt to achieve a set of database update steps.

◆ testCorrectExecutionOrder()

ilDatabaseUpdateStepsExecutedObjectiveTest::testCorrectExecutionOrder ( )

Definition at line 73 of file ilDatabaseUpdateStepsExecutedObjectiveTest.php.

73 : void
74 {
75 $execution_log = new class () implements ilDatabaseUpdateStepExecutionLog {
76 public function started(string $class, int $step): void
77 {
78 }
79 public function finished(string $class, int $step): void
80 {
81 }
82 public function getLastStartedStep(string $class): int
83 {
84 return 0;
85 }
86 public function getLastFinishedStep(string $class): int
87 {
88 return 0;
89 }
90 };
91 $steps_reader = new class () extends ilDBStepReader {
92 };
93 $db = $this->createMock(ilDBInterface::class);
94 $env = new ArrayEnvironment([
95 ilDBStepReader::class => $steps_reader,
96 ilDBStepExecutionDB::class => $execution_log,
97 Environment::RESOURCE_DATABASE => $db
98 ]);
99
100 $db->expects($this->exactly(3))
101 ->method("connect");
102
103 $this->objective->achieve($env);
104
105 $this->assertEquals([1,2,4], $this->steps->called);
106 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ testExceptionOnNonMatchingStartAndFinished()

ilDatabaseUpdateStepsExecutedObjectiveTest::testExceptionOnNonMatchingStartAndFinished ( )

Definition at line 195 of file ilDatabaseUpdateStepsExecutedObjectiveTest.php.

195 : void
196 {
197 $this->expectException(RuntimeException::class);
198
199 $execution_log = new class () implements ilDatabaseUpdateStepExecutionLog {
200 public function started(string $class, int $step): void
201 {
202 }
203 public function finished(string $class, int $step): void
204 {
205 }
206 public function getLastStartedStep(string $class): int
207 {
208 return 2;
209 }
210 public function getLastFinishedStep(string $class): int
211 {
212 return 1;
213 }
214 };
215 $db = $this->createMock(ilDBInterface::class);
216 $env = new ArrayEnvironment([
217 ilDBStepExecutionDB::class => $execution_log,
218 Environment::RESOURCE_DATABASE => $db
219 ]);
220 $this->objective->achieve($env);
221 }

◆ testOnlyExecuteNonExecutedSteps()

ilDatabaseUpdateStepsExecutedObjectiveTest::testOnlyExecuteNonExecutedSteps ( )

Definition at line 160 of file ilDatabaseUpdateStepsExecutedObjectiveTest.php.

160 : void
161 {
162 $execution_log = new class () implements ilDatabaseUpdateStepExecutionLog {
163 public function started(string $class, int $step): void
164 {
165 }
166 public function finished(string $class, int $step): void
167 {
168 }
169 public function getLastStartedStep(string $class): int
170 {
171 return 1;
172 }
173 public function getLastFinishedStep(string $class): int
174 {
175 return 1;
176 }
177 };
178 $steps_reader = new class () extends ilDBStepReader {
179 };
180 $db = $this->createMock(ilDBInterface::class);
181 $env = new ArrayEnvironment([
182 ilDBStepReader::class => $steps_reader,
183 ilDBStepExecutionDB::class => $execution_log,
184 Environment::RESOURCE_DATABASE => $db
185 ]);
186
187 $db->expects($this->exactly(2))
188 ->method("connect");
189
190 $this->objective->achieve($env);
191
192 $this->assertEquals([2,4], $this->steps->called);
193 }

◆ testUsesExecutionLock()

ilDatabaseUpdateStepsExecutedObjectiveTest::testUsesExecutionLock ( )

Definition at line 108 of file ilDatabaseUpdateStepsExecutedObjectiveTest.php.

108 : void
109 {
110 $execution_log = new class ($this) implements ilDatabaseUpdateStepExecutionLog {
112
114 {
115 $this->test = $test;
116 }
117 public function started(string $class, int $step): void
118 {
119 $this->test->steps->called[] = ["started", $class, $step];
120 }
121 public function finished(string $class, int $step): void
122 {
123 $this->test->steps->called[] = ["finished", $class, $step];
124 }
125 public function getLastStartedStep(string $class): int
126 {
127 return 0;
128 }
129 public function getLastFinishedStep(string $class): int
130 {
131 return 0;
132 }
133 };
134 $steps_reader = new class () extends ilDBStepReader {
135 };
136 $db = $this->createMock(ilDBInterface::class);
137 $env = new ArrayEnvironment([
138 ilDBStepReader::class => $steps_reader,
139 ilDBStepExecutionDB::class => $execution_log,
140 Environment::RESOURCE_DATABASE => $db
141 ]);
142
143 $this->objective->achieve($env);
144
145 $expected = [
146 ["started", Test_ilDatabaseUpdateSteps::class, 1],
147 1,
148 ["finished", Test_ilDatabaseUpdateSteps::class, 1],
149 ["started", Test_ilDatabaseUpdateSteps::class, 2],
150 2,
151 ["finished", Test_ilDatabaseUpdateSteps::class, 2],
152 ["started", Test_ilDatabaseUpdateSteps::class, 4],
153 4,
154 ["finished", Test_ilDatabaseUpdateSteps::class, 4]
155 ];
156
157 $this->assertEquals($expected, $this->steps->called);
158 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Field Documentation

◆ $objective

ilDatabaseUpdateStepsExecutedObjective ilDatabaseUpdateStepsExecutedObjectiveTest::$objective

◆ $steps

Test_ilDatabaseUpdateSteps ilDatabaseUpdateStepsExecutedObjectiveTest::$steps

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