3 declare(strict_types=1);
35 protected function setUp(): void
44 $this->dic = is_object($DIC) ? clone
$DIC :
$DIC;
47 $user = $this->getMockBuilder(ilObjUser::class)
48 ->disableOriginalConstructor()
50 $user->expects($this->never())
51 ->method($this->anything());
72 $mock_db->method(
'quote')
73 ->willReturnCallback(
function ($arg1,
string $arg2) {
74 return (
string) $arg1;
76 $mock_db->method(
'quoteIdentifier')
77 ->willReturnCallback(
function (
string $arg1) {
83 $this->web_link_repo = $this->getMockBuilder(ilWebLinkDatabaseRepository::class)
84 ->setConstructorArgs([$webr_id, $update_history])
85 ->onlyMethods([
'getCurrentTime',
'getNewDateTimeImmutable'])
88 $this->web_link_repo->method(
'getCurrentTime')
89 ->willReturn($current_time);
90 $this->web_link_repo->method(
'getNewDateTimeImmutable')
91 ->willReturnOnConsecutiveCalls(...$datetimes);
117 $datetime = $this->getMockBuilder(DateTimeImmutable::class)
118 ->disableOriginalConstructor()
119 ->onlyMethods([
'getTimestamp'])
121 $datetime->method(
'getTimestamp')
122 ->willReturn($timestamp);
135 $mock_db = $this->getMockBuilder(ilDBInterface::class)
136 ->disableOriginalConstructor()
139 $mock_db->expects($this->exactly(3))
146 ->willReturn(7, 71, 72);
148 $mock_db->expects($this->exactly(3))
154 'webr_id' => [
'integer', 0],
155 'link_id' => [
'integer', 7],
156 'param_id' => [
'integer', 71],
157 'name' => [
'text',
'name1'],
164 'webr_id' => [
'integer', 0],
165 'link_id' => [
'integer', 7],
166 'param_id' => [
'integer', 72],
167 'name' => [
'text',
'name2'],
174 'internal' => [
'integer', 0],
175 'webr_id' => [
'integer', 0],
176 'link_id' => [
'integer', 7],
177 'title' => [
'text',
'title'],
178 'description' => [
'text',
'description'],
179 'target' => [
'text',
'target'],
180 'active' => [
'integer', 1],
181 'create_date' => [
'integer', 12345678],
182 'last_update' => [
'integer', 12345678]
187 $history = Mockery::mock(
'alias:' . ilHistory::class);
188 $history->shouldReceive(
'_createEntry')
190 ->with(0,
'add', [
'title']);
192 $link_input = Mockery::mock(
'alias:' . ilLinkInputGUI::class);
193 $link_input->shouldReceive(
'isInternalLink')
221 [$datetime1, $datetime2]
252 [$expected_param1, $expected_param2]
254 $this->web_link_repo->createItem($item)
266 $mock_db = $this->getMockBuilder(ilDBInterface::class)
267 ->disableOriginalConstructor()
270 $mock_db->expects($this->exactly(3))
277 ->willReturn(7, 71, 72);
279 $mock_db->expects($this->exactly(2))
285 'webr_id' => [
'integer', 0],
286 'link_id' => [
'integer', 7],
287 'param_id' => [
'integer', 72],
288 'name' => [
'text',
'name2'],
295 'internal' => [
'integer', 1],
296 'webr_id' => [
'integer', 0],
297 'link_id' => [
'integer', 7],
298 'title' => [
'text',
'title'],
299 'description' => [
'text',
'description'],
300 'target' => [
'text',
'trg|123'],
301 'active' => [
'integer', 1],
302 'create_date' => [
'integer', 12345678],
303 'last_update' => [
'integer', 12345678]
308 $history = Mockery::mock(
'alias:' . ilHistory::class);
309 $history->shouldReceive(
'_createEntry')
311 ->with(0,
'add', [
'title']);
313 $link_input = Mockery::mock(
'alias:' . ilLinkInputGUI::class);
314 $link_input->shouldReceive(
'isInternalLink')
344 [$datetime1, $datetime2]
368 $this->web_link_repo->createItem($item)
378 $mock_db = $this->getMockBuilder(ilDBInterface::class)
379 ->disableOriginalConstructor()
382 $mock_db->expects($this->once())
387 $mock_db->expects($this->never())
390 $history = Mockery::mock(
'alias:' . ilHistory::class);
391 $history->shouldReceive(
'_createEntry')
394 $link_input = Mockery::mock(
'alias:' . ilLinkInputGUI::class);
395 $link_input->shouldReceive(
'isInternalLink')
425 [$datetime1, $datetime2]
428 $this->expectException(ilWebLinkDatabaseRepositoryException::class);
429 $this->web_link_repo->createItem($item);
438 $mock_db = $this->getMockBuilder(ilDBInterface::class)
439 ->disableOriginalConstructor()
442 $mock_db->expects($this->never())
445 $mock_db->expects($this->once())
450 'webr_id' => [
'integer', 0],
451 'title' => [
'text',
'title'],
452 'description' => [
'text',
''],
453 'create_date' => [
'integer', 12345678],
454 'last_update' => [
'integer', 12345678]
458 $history = Mockery::mock(
'alias:' . ilHistory::class);
459 $history->shouldReceive(
'_createEntry')
461 ->with(0,
'add', [
'title']);
476 [$datetime1, $datetime2]
487 $this->web_link_repo->createList($list)
497 $mock_db = $this->getMockBuilder(ilDBInterface::class)
498 ->disableOriginalConstructor()
509 [$datetime1, $datetime2]
526 [$draft_param1, $draft_param2]
583 $repo = $this->getMockBuilder(ilWebLinkDatabaseRepository::class)
584 ->setConstructorArgs([0,
true])
585 ->onlyMethods([
'createItem'])
588 $repo->expects($this->exactly(2))
589 ->method(
'createItem')
590 ->withConsecutive([$draft_item1], [$draft_item2])
591 ->willReturn($item1, $item2);
598 $repo->createAllItemsInDraftContainer($draft_container)
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...
getNewDateTimeMock(int $timestamp)
setGlobalDBAndRepo(ilDBInterface $mock_db, int $webr_id, bool $update_history, int $current_time, array $datetimes)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilWebLinkRepository $web_link_repo
Customizing of pimple-DIC for ILIAS.
testCreateAllItemsInDraftContainer()
disabled
setGlobal(string $name, MockObject $obj)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testCreateItemBrokenInternalLinkException()
disabled
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testCreateInternalItemWithBrokenParameter()
Test creating an item with one intact and one broken parameter, and an internal link.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
foreach($mandatory_scripts as $file) $timestamp
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const VALUES
TODO Once the GUI is updated, undefined can be dropped.
testCreateExternalItem()
Test creating an item with two intact parameters, and an external link.
Unit tests for ilWebLinkDatabaseRepository.