23 public const CLASS_NAME_200 =
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
24 public const CLASS_NAME_201 =
"012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
31 protected function setUp(): void
33 $this->db = $this->createMock(\ilDBInterface::class);
34 $this->execution_db = new \ilDBStepExecutionDB($this->db, fn() =>
new \
DateTime());
39 $this->expectException(\InvalidArgumentException::class);
40 $this->execution_db->started(self::CLASS_NAME_201, 1);
45 $this->expectException(\InvalidArgumentException::class);
46 $this->execution_db->finished(self::CLASS_NAME_201, 1);
51 $this->expectException(\InvalidArgumentException::class);
52 $this->execution_db->getLastStartedStep(self::CLASS_NAME_201);
57 $this->expectException(\InvalidArgumentException::class);
58 $this->execution_db->getLastFinishedStep(self::CLASS_NAME_201);
64 $NOW =
"2021-08-12 13:37:23.111111";
66 $execution_db = $this->getMockBuilder(\ilDBStepExecutionDB::class)
67 ->onlyMethods([
"getLastStartedStep",
"getLastFinishedStep"])
68 ->setConstructorArgs([$this->db, fn() =>
new \
DateTime($NOW)])
71 $execution_db->expects($this->once())
72 ->method(
"getLastFinishedStep")
73 ->with(self::CLASS_NAME_200)
76 $this->expectException(\RuntimeException::class);
78 $execution_db->
started(self::CLASS_NAME_200, $STEP);
83 $NOW =
"2021-08-12 13:37:23.111111";
85 $execution_db = $this->getMockBuilder(\ilDBStepExecutionDB::class)
86 ->onlyMethods([
"getLastStartedStep",
"getLastFinishedStep"])
87 ->setConstructorArgs([$this->db, fn() =>
new \
DateTime($NOW)])
90 $execution_db->expects($this->once())
91 ->method(
"getLastFinishedStep")
92 ->with(self::CLASS_NAME_200)
96 $execution_db->expects($this->once())
97 ->method(
"getLastStartedStep")
98 ->with(self::CLASS_NAME_200)
101 $this->expectException(\RuntimeException::class);
103 $execution_db->
started(self::CLASS_NAME_200, 3);
109 $NOW =
"2021-08-12 13:37:23.111111";
111 $execution_db = $this->getMockBuilder(\ilDBStepExecutionDB::class)
112 ->onlyMethods([
"getLastStartedStep",
"getLastFinishedStep"])
113 ->setConstructorArgs([$this->db, fn() =>
new \
DateTime($NOW)])
116 $execution_db->expects($this->once())
117 ->method(
"getLastStartedStep")
118 ->with(self::CLASS_NAME_200)
121 $this->expectException(\RuntimeException::class);
123 $execution_db->
finished(self::CLASS_NAME_200, $STEP);
128 $result = $this->getMockBuilder(ilDBStatement::class)->getMock();
131 ->willReturn($result);
133 ->method(
"fetchAssoc")
136 $this->assertEquals(0, $this->execution_db->getLastStartedStep(self::CLASS_NAME_200));
141 $result = $this->getMockBuilder(ilDBStatement::class)->getMock();
144 ->willReturn($result);
146 ->method(
"fetchAssoc")
149 $this->assertEquals(0, $this->execution_db->getLastFinishedStep(self::CLASS_NAME_200));
155 $NOW =
"2021-08-12 13:37:23.111111";
157 $execution_db = $this->getMockBuilder(\ilDBStepExecutionDB::class)
158 ->onlyMethods([
"getLastStartedStep",
"getLastFinishedStep"])
159 ->setConstructorArgs([$this->db, fn() =>
new \
DateTime($NOW)])
162 $execution_db->expects($this->once())
163 ->method(
"getLastStartedStep")
164 ->with(self::CLASS_NAME_200)
167 $execution_db->expects($this->once())
168 ->method(
"getLastFinishedStep")
169 ->with(self::CLASS_NAME_200)
172 $this->db->expects($this->once())
183 $execution_db->
started(self::CLASS_NAME_200, $STEP);
189 $NOW =
"2021-08-12 13:37:23.222222";
191 $execution_db = $this->getMockBuilder(\ilDBStepExecutionDB::class)
192 ->onlyMethods([
"getLastStartedStep",
"getLastFinishedStep"])
193 ->setConstructorArgs([$this->db, fn() =>
new \
DateTime($NOW)])
196 $execution_db->expects($this->once())
197 ->method(
"getLastStartedStep")
198 ->with(self::CLASS_NAME_200)
201 $this->db->expects($this->once())
214 $execution_db->
finished(self::CLASS_NAME_200, $STEP);
221 $this->db->expects($this->once())
223 ->willReturnCallback(
224 function ($field, $type) {
225 $this->assertEquals(self::CLASS_NAME_200, $field);
226 $this->assertEquals(
'text', $type);
231 $result = $this->getMockBuilder(ilDBStatement::class)->getMock();
232 $this->db->expects($this->once())
239 ->willReturn($result);
240 $this->db->expects($this->once())
241 ->method(
"fetchAssoc")
244 $this->assertEquals($STEP, $this->execution_db->getLastStartedStep(self::CLASS_NAME_200));
251 $this->db->expects($this->once())
253 ->willReturnCallback(
254 function ($field, $type) {
255 $this->assertEquals(self::CLASS_NAME_200, $field);
256 $this->assertEquals(
'text', $type);
262 $result = $this->getMockBuilder(ilDBStatement::class)->getMock();
263 $this->db->expects($this->once())
271 ->willReturn($result);
272 $this->db->expects($this->once())
273 ->method(
"fetchAssoc")
276 $this->assertEquals($STEP, $this->execution_db->getLastFinishedStep(self::CLASS_NAME_200));
started(string $class, int $step)
testGetLastStartedStepThrowsOnLongClassName()
ilDBStepExecutionDB $execution_db
ilDBInterface PHPUnit Framework MockObject MockObject $db
testFinishedThrowsOnLongClassName()
finished(string $class, int $step)
testGetLastFinishedStepStartsWithZero()
testStartedThrowsWhenLastStepNotFinished()
testGetLastStartedStepStartsWithZero()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testGetLastStartedStepQueriesDB()
testStartedThrowsOnLongClassName()
testGetLastFinishedStepQueriesDB()
testGetLastFinishedStepThrowsOnLongClassName()
testFinishedThrowsWhenOtherStepThenLastIsFinished()
testStartedThrowsOnStartStepNotLargerThenLastFinishedStep()