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

Public Member Functions

 testStartedThrowsOnLongClassName ()
 
 testFinishedThrowsOnLongClassName ()
 
 testGetLastStartedStepThrowsOnLongClassName ()
 
 testGetLastFinishedStepThrowsOnLongClassName ()
 
 testStartedThrowsOnStartStepNotLargerThenLastFinishedStep ()
 
 testStartedThrowsWhenLastStepNotFinished ()
 
 testFinishedThrowsWhenOtherStepThenLastIsFinished ()
 
 testGetLastStartedStepStartsWithZero ()
 
 testGetLastFinishedStepStartsWithZero ()
 
 testStartedWritesToDB ()
 
 testFinishedWritesToDB ()
 
 testGetLastStartedStepQueriesDB ()
 
 testGetLastFinishedStepQueriesDB ()
 

Data Fields

const CLASS_NAME_200 = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
 
const CLASS_NAME_201 = "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
 

Protected Member Functions

 setUp ()
 

Detailed Description

Definition at line 21 of file ilDBStepExecutionDBTest.php.

Member Function Documentation

◆ setUp()

ilDBStepExecutionDBTest::setUp ( )
protected

Definition at line 26 of file ilDBStepExecutionDBTest.php.

26 : void
27 {
28 $this->db = $this->createMock(\ilDBInterface::class);
29 $this->execution_db = new \ilDBStepExecutionDB($this->db, fn () => new \DateTime());
30 }

◆ testFinishedThrowsOnLongClassName()

ilDBStepExecutionDBTest::testFinishedThrowsOnLongClassName ( )

Definition at line 38 of file ilDBStepExecutionDBTest.php.

38 : void
39 {
40 $this->expectException(\InvalidArgumentException::class);
41 $this->execution_db->finished(self::CLASS_NAME_201, 1);
42 }

◆ testFinishedThrowsWhenOtherStepThenLastIsFinished()

ilDBStepExecutionDBTest::testFinishedThrowsWhenOtherStepThenLastIsFinished ( )

Definition at line 101 of file ilDBStepExecutionDBTest.php.

101 : void
102 {
103 $STEP = 1;
104 $NOW = "2021-08-12 13:37:23.111111";
105
106 $execution_db = $this->getMockBuilder(\ilDBStepExecutionDB::class)
107 ->onlyMethods(["getLastStartedStep", "getLastFinishedStep"])
108 ->setConstructorArgs([$this->db, fn () => new \DateTime($NOW)])
109 ->getMock();
110
111 $execution_db->expects($this->once())
112 ->method("getLastStartedStep")
113 ->with(self::CLASS_NAME_200)
114 ->willReturn(2);
115
116 $this->expectException(\RuntimeException::class);
117
118 $execution_db->finished(self::CLASS_NAME_200, $STEP);
119 }

◆ testFinishedWritesToDB()

ilDBStepExecutionDBTest::testFinishedWritesToDB ( )

Definition at line 181 of file ilDBStepExecutionDBTest.php.

181 : void
182 {
183 $STEP = 2;
184 $NOW = "2021-08-12 13:37:23.222222";
185
186 $execution_db = $this->getMockBuilder(\ilDBStepExecutionDB::class)
187 ->onlyMethods(["getLastStartedStep", "getLastFinishedStep"])
188 ->setConstructorArgs([$this->db, fn () => new \DateTime($NOW)])
189 ->getMock();
190
191 $execution_db->expects($this->once())
192 ->method("getLastStartedStep")
193 ->with(self::CLASS_NAME_200)
194 ->willReturn(2);
195
196 $this->db->expects($this->once())
197 ->method("update")
198 ->with(
200 [
202 ],
203 [
204 ilDBStepExecutionDB::FIELD_CLASS => ["text", self::CLASS_NAME_200],
205 ilDBStepExecutionDB::FIELD_STEP => ["integer", $STEP]
206 ]
207 );
208
209 $execution_db->finished(self::CLASS_NAME_200, $STEP);
210 }

References ilDBStepExecutionDB\FIELD_CLASS, ilDBStepExecutionDB\FIELD_FINISHED, ilDBStepExecutionDB\FIELD_STEP, and ilDBStepExecutionDB\TABLE_NAME.

◆ testGetLastFinishedStepQueriesDB()

ilDBStepExecutionDBTest::testGetLastFinishedStepQueriesDB ( )

Definition at line 241 of file ilDBStepExecutionDBTest.php.

241 : void
242 {
243 $STEP = 23;
244
245 $this->db->expects($this->once())
246 ->method("quote")
247 ->withConsecutive(
248 [self::CLASS_NAME_200, "text"],
249 )
250 ->willReturnOnConsecutiveCalls(
251 "CLASS"
252 );
253
254 $result = $this->getMockBuilder(ilDBStatement::class)->getMock();
255 $this->db->expects($this->once())
256 ->method("query")
257 ->with(
260 " WHERE " . ilDBStepExecutionDB::FIELD_CLASS . " = CLASS" .
261 " AND " . ilDBStepExecutionDB::FIELD_FINISHED . " IS NOT NULL"
262 )
263 ->willReturn($result);
264 $this->db->expects($this->once())
265 ->method("fetchAssoc")
266 ->willReturn([ilDBStepExecutionDB::FIELD_STEP => $STEP]);
267
268 $this->assertEquals($STEP, $this->execution_db->getLastFinishedStep(self::CLASS_NAME_200));
269 }

References ilDBStepExecutionDB\FIELD_CLASS, ilDBStepExecutionDB\FIELD_FINISHED, ilDBStepExecutionDB\FIELD_STEP, and ilDBStepExecutionDB\TABLE_NAME.

◆ testGetLastFinishedStepStartsWithZero()

ilDBStepExecutionDBTest::testGetLastFinishedStepStartsWithZero ( )

Definition at line 134 of file ilDBStepExecutionDBTest.php.

134 : void
135 {
136 $result = $this->getMockBuilder(ilDBStatement::class)->getMock();
137 $this->db
138 ->method("query")
139 ->willReturn($result);
140 $this->db
141 ->method("fetchAssoc")
142 ->willReturn([ilDBStepExecutionDB::FIELD_STEP => null]);
143
144 $this->assertEquals(0, $this->execution_db->getLastFinishedStep(self::CLASS_NAME_200));
145 }

References ilDBStepExecutionDB\FIELD_STEP.

◆ testGetLastFinishedStepThrowsOnLongClassName()

ilDBStepExecutionDBTest::testGetLastFinishedStepThrowsOnLongClassName ( )

Definition at line 50 of file ilDBStepExecutionDBTest.php.

50 : void
51 {
52 $this->expectException(\InvalidArgumentException::class);
53 $this->execution_db->getLastFinishedStep(self::CLASS_NAME_201);
54 }

◆ testGetLastStartedStepQueriesDB()

ilDBStepExecutionDBTest::testGetLastStartedStepQueriesDB ( )

Definition at line 212 of file ilDBStepExecutionDBTest.php.

212 : void
213 {
214 $STEP = 23;
215
216 $this->db->expects($this->once())
217 ->method("quote")
218 ->withConsecutive(
219 [self::CLASS_NAME_200, "text"],
220 )
221 ->willReturnOnConsecutiveCalls(
222 "CLASS"
223 );
224
225 $result = $this->getMockBuilder(ilDBStatement::class)->getMock();
226 $this->db->expects($this->once())
227 ->method("query")
228 ->with(
231 " WHERE " . ilDBStepExecutionDB::FIELD_CLASS . " = CLASS"
232 )
233 ->willReturn($result);
234 $this->db->expects($this->once())
235 ->method("fetchAssoc")
236 ->willReturn([ilDBStepExecutionDB::FIELD_STEP => $STEP]);
237
238 $this->assertEquals($STEP, $this->execution_db->getLastStartedStep(self::CLASS_NAME_200));
239 }

References ilDBStepExecutionDB\FIELD_CLASS, ilDBStepExecutionDB\FIELD_STEP, and ilDBStepExecutionDB\TABLE_NAME.

◆ testGetLastStartedStepStartsWithZero()

ilDBStepExecutionDBTest::testGetLastStartedStepStartsWithZero ( )

Definition at line 121 of file ilDBStepExecutionDBTest.php.

121 : void
122 {
123 $result = $this->getMockBuilder(ilDBStatement::class)->getMock();
124 $this->db
125 ->method("query")
126 ->willReturn($result);
127 $this->db
128 ->method("fetchAssoc")
129 ->willReturn([ilDBStepExecutionDB::FIELD_STEP => null]);
130
131 $this->assertEquals(0, $this->execution_db->getLastStartedStep(self::CLASS_NAME_200));
132 }

References ilDBStepExecutionDB\FIELD_STEP.

◆ testGetLastStartedStepThrowsOnLongClassName()

ilDBStepExecutionDBTest::testGetLastStartedStepThrowsOnLongClassName ( )

Definition at line 44 of file ilDBStepExecutionDBTest.php.

44 : void
45 {
46 $this->expectException(\InvalidArgumentException::class);
47 $this->execution_db->getLastStartedStep(self::CLASS_NAME_201);
48 }

◆ testStartedThrowsOnLongClassName()

ilDBStepExecutionDBTest::testStartedThrowsOnLongClassName ( )

Definition at line 32 of file ilDBStepExecutionDBTest.php.

32 : void
33 {
34 $this->expectException(\InvalidArgumentException::class);
35 $this->execution_db->started(self::CLASS_NAME_201, 1);
36 }

◆ testStartedThrowsOnStartStepNotLargerThenLastFinishedStep()

ilDBStepExecutionDBTest::testStartedThrowsOnStartStepNotLargerThenLastFinishedStep ( )

Definition at line 56 of file ilDBStepExecutionDBTest.php.

56 : void
57 {
58 $STEP = 1;
59 $NOW = "2021-08-12 13:37:23.111111";
60
61 $execution_db = $this->getMockBuilder(\ilDBStepExecutionDB::class)
62 ->onlyMethods(["getLastStartedStep", "getLastFinishedStep"])
63 ->setConstructorArgs([$this->db, fn () => new \DateTime($NOW)])
64 ->getMock();
65
66 $execution_db->expects($this->once())
67 ->method("getLastFinishedStep")
68 ->with(self::CLASS_NAME_200)
69 ->willReturn(2);
70
71 $this->expectException(\RuntimeException::class);
72
73 $execution_db->started(self::CLASS_NAME_200, $STEP);
74 }

◆ testStartedThrowsWhenLastStepNotFinished()

ilDBStepExecutionDBTest::testStartedThrowsWhenLastStepNotFinished ( )

Definition at line 76 of file ilDBStepExecutionDBTest.php.

76 : void
77 {
78 $NOW = "2021-08-12 13:37:23.111111";
79
80 $execution_db = $this->getMockBuilder(\ilDBStepExecutionDB::class)
81 ->onlyMethods(["getLastStartedStep", "getLastFinishedStep"])
82 ->setConstructorArgs([$this->db, fn () => new \DateTime($NOW)])
83 ->getMock();
84
85 $execution_db->expects($this->once())
86 ->method("getLastFinishedStep")
87 ->with(self::CLASS_NAME_200)
88 ->willReturn(1);
89
90
91 $execution_db->expects($this->once())
92 ->method("getLastStartedStep")
93 ->with(self::CLASS_NAME_200)
94 ->willReturn(2);
95
96 $this->expectException(\RuntimeException::class);
97
98 $execution_db->started(self::CLASS_NAME_200, 3);
99 }

◆ testStartedWritesToDB()

ilDBStepExecutionDBTest::testStartedWritesToDB ( )

Definition at line 147 of file ilDBStepExecutionDBTest.php.

147 : void
148 {
149 $STEP = 2;
150 $NOW = "2021-08-12 13:37:23.111111";
151
152 $execution_db = $this->getMockBuilder(\ilDBStepExecutionDB::class)
153 ->onlyMethods(["getLastStartedStep", "getLastFinishedStep"])
154 ->setConstructorArgs([$this->db, fn () => new \DateTime($NOW)])
155 ->getMock();
156
157 $execution_db->expects($this->once())
158 ->method("getLastStartedStep")
159 ->with(self::CLASS_NAME_200)
160 ->willReturn(1);
161
162 $execution_db->expects($this->once())
163 ->method("getLastFinishedStep")
164 ->with(self::CLASS_NAME_200)
165 ->willReturn(1);
166
167 $this->db->expects($this->once())
168 ->method("insert")
169 ->with(
171 [
172 ilDBStepExecutionDB::FIELD_CLASS => ["text", self::CLASS_NAME_200],
173 ilDBStepExecutionDB::FIELD_STEP => ["integer", $STEP],
174 ilDBStepExecutionDB::FIELD_STARTED => ["text", $NOW]
175 ]
176 );
177
178 $execution_db->started(self::CLASS_NAME_200, $STEP);
179 }

References ilDBStepExecutionDB\FIELD_CLASS, ilDBStepExecutionDB\FIELD_STARTED, ilDBStepExecutionDB\FIELD_STEP, and ilDBStepExecutionDB\TABLE_NAME.

Field Documentation

◆ CLASS_NAME_200

const ilDBStepExecutionDBTest::CLASS_NAME_200 = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"

Definition at line 23 of file ilDBStepExecutionDBTest.php.

◆ CLASS_NAME_201

const ilDBStepExecutionDBTest::CLASS_NAME_201 = "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"

Definition at line 24 of file ilDBStepExecutionDBTest.php.


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