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])
    87                                         'getNewDateTimeImmutable',
    93         $this->web_link_repo->method(
'getCurrentTime')
    94                             ->willReturn($current_time);
    95         $this->web_link_repo->method(
'getNewDateTimeImmutable')
    96                             ->willReturnOnConsecutiveCalls(...$datetimes);
    99     protected function setGlobal(
string $name, MockObject $obj): void
   105         $DIC[$name] = 
static function (
Container $c) use ($obj) {
   122         $datetime = $this->getMockBuilder(DateTimeImmutable::class)
   123                          ->disableOriginalConstructor()
   124                          ->onlyMethods([
'getTimestamp'])
   127                  ->willReturn($timestamp);
   140         $mock_db = $this->getMockBuilder(ilDBInterface::class)
   141                         ->disableOriginalConstructor()
   144         $mock_db->expects($this->exactly(3))
   146                 ->willReturn(7, 71, 72);
   155         $mock_db->expects($this->exactly(3))
   157                 ->willReturnCallback(fn($table, 
$data) => match([$table, 
$data]) {
   161                             'webr_id' => [
'integer', 0],
   162                             'link_id' => [
'integer', 7],
   163                             'param_id' => [
'integer', 71],
   164                             'name' => [
'text', 
'name1'],
   171                             'webr_id' => [
'integer', 0],
   172                             'link_id' => [
'integer', 7],
   173                             'param_id' => [
'integer', 72],
   174                             'name' => [
'text', 
'name2'],
   181                             'internal' => [
'integer', 0],
   182                             'webr_id' => [
'integer', 0],
   183                             'link_id' => [
'integer', 7],
   184                             'title' => [
'text', 
'title'],
   185                             'description' => [
'text', 
'description'],
   186                             'target' => [
'text', 
'target'],
   187                             'active' => [
'integer', 1],
   188                             'create_date' => [
'integer', 12345678],
   189                             'last_update' => [
'integer', 12345678]
   219             [$datetime1, $datetime2]
   222         $this->web_link_repo->expects($this->once())
   223                             ->method(
'createHistoryEntry')
   224                             ->with(0, 
'add', [
'title']);
   225         $this->web_link_repo->expects($this->never())
   226                             ->method(
'isInternalLink');
   256                 [$expected_param1, $expected_param2]
   258             $this->web_link_repo->createItem($item)
   270         $mock_db = $this->getMockBuilder(ilDBInterface::class)
   271                         ->disableOriginalConstructor()
   273         $mock_db->expects($this->exactly(3))
   275                 ->willReturn(7, 71, 72);
   284         $mock_db->expects($this->exactly(2))
   286                 ->willReturnCallback(fn($table, 
$data) => match([$table, 
$data]) {
   290                             'webr_id' => [
'integer', 0],
   291                             'link_id' => [
'integer', 7],
   292                             'param_id' => [
'integer', 72],
   293                             'name' => [
'text', 
'name2'],
   300                             'internal' => [
'integer', 1],
   301                             'webr_id' => [
'integer', 0],
   302                             'link_id' => [
'integer', 7],
   303                             'title' => [
'text', 
'title'],
   304                             'description' => [
'text', 
'description'],
   305                             'target' => [
'text', 
'trg|123'],
   306                             'active' => [
'integer', 1],
   307                             'create_date' => [
'integer', 12345678],
   308                             'last_update' => [
'integer', 12345678]
   338             [$datetime1, $datetime2]
   341         $this->web_link_repo->expects($this->once())
   342                             ->method(
'createHistoryEntry')
   343                             ->with(0, 
'add', [
'title']);
   344         $this->web_link_repo->expects($this->once())
   345                             ->method(
'isInternalLink')
   370             $this->web_link_repo->createItem($item)
   380         $mock_db = $this->getMockBuilder(ilDBInterface::class)
   381                         ->disableOriginalConstructor()
   384         $mock_db->expects($this->once())
   389         $mock_db->expects($this->never())
   417             [$datetime1, $datetime2]
   420         $this->web_link_repo->expects($this->never())
   421                             ->method(
'createHistoryEntry');
   422         $this->web_link_repo->expects($this->once())
   423                             ->method(
'isInternalLink')
   427         $this->expectException(ilWebLinkDatabaseRepositoryException::class);
   428         $this->web_link_repo->createItem($item);
   437         $mock_db = $this->getMockBuilder(ilDBInterface::class)
   438                         ->disableOriginalConstructor()
   441         $mock_db->expects($this->never())
   444         $mock_db->expects($this->once())
   449                         'webr_id' => [
'integer', 0],
   450                         'title' => [
'text', 
'title'],
   451                         'description' => [
'text', 
''],
   452                         'create_date' => [
'integer', 12345678],
   453                         'last_update' => [
'integer', 12345678]
   470             [$datetime1, $datetime2]
   473         $this->web_link_repo->expects($this->once())
   474                             ->method(
'createHistoryEntry')
   475                             ->with(0, 
'add', [
'title']);
   485             $this->web_link_repo->createList($list)
   495         $mock_db = $this->getMockBuilder(ilDBInterface::class)
   496                         ->disableOriginalConstructor()
   507             [$datetime1, $datetime2]
   524             [$draft_param1, $draft_param2]
   581         $repo = $this->getMockBuilder(ilWebLinkDatabaseRepository::class)
   582                      ->setConstructorArgs([0, 
true])
   583                      ->onlyMethods([
'createItem'])
   586         $repo->expects($this->exactly(2))
   587              ->method(
'createItem')
   588              ->willReturnCallback(fn($item) => match($item) {
   589                  $draft_item1 => $item1,
   590                  $draft_item2 => $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...
 
Customizing of pimple-DIC for ILIAS. 
 
testCreateAllItemsInDraftContainer()
disabled 
 
setGlobal(string $name, MockObject $obj)
 
ilWebLinkRepository &MockObject $web_link_repo
 
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...
 
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...
 
Immutable class for internal Web Link items. 
 
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.