ILIAS  release_8 Revision v8.24
PermanentLinkGUITest.php
Go to the documentation of this file.
1<?php
2
19use PHPUnit\Framework\TestCase;
20
24class PermanentLinkGUITest extends TestCase
25{
26 protected function setGlobalVariable(string $name, $value): void
27 {
28 global $DIC;
29
30 $GLOBALS[$name] = $value;
31
32 unset($DIC[$name]);
33 $DIC[$name] = static function (\ILIAS\DI\Container $c) use ($value) {
34 return $value;
35 };
36 }
37
38 protected function setUp(): void
39 {
41 $GLOBALS['DIC'] = $dic;
42
43 if (!defined("ILIAS_LOG_ENABLED")) {
44 define("ILIAS_LOG_ENABLED", false);
45 }
46
47 parent::setUp();
48
49 $db_mock = $this->createMock(ilDBInterface::class);
50 $db_mock->method("fetchAssoc")
51 ->will(
52 $this->onConsecutiveCalls(
53 [
54 "component" => "Services/EventHandling",
55 "id" => "MyTestComponent"
56 ],
57 null
58 )
59 );
60
61
62 $this->setGlobalVariable(
63 "ilDB",
64 $db_mock
65 );
66 $this->setGlobalVariable(
67 "ilSetting",
68 $this->createMock(ilSetting::class)
69 );
70 $component_repository = $this->createMock(ilComponentRepository::class);
71 $this->setGlobalVariable(
72 "component.repository",
73 $component_repository
74 );
75 $component_factory = $this->createMock(ilComponentFactory::class);
76 $this->setGlobalVariable(
77 "component.factory",
78 $component_factory
79 );
80
81 $languageMock = $this->getMockBuilder(ilLanguage::class)
82 ->disableOriginalConstructor()
83 ->getMock();
84 $this->setGlobalVariable(
85 "lng",
86 $languageMock
87 );
88
89 $ctrl = $this->getMockBuilder('ilCtrl')->disableOriginalConstructor()->onlyMethods(
90 ['setParameterByClass', 'redirectByClass', 'forwardCommand']
91 )->getMock();
92 $ctrl->method('setParameterByClass');
93 $ctrl->method('redirectByClass');
94
95 $this->setGlobalVariable('ilCtrl', $ctrl);
96
97 $objectDataCache = $this
98 ->getMockBuilder(ilObjectDataCache::class)
99 ->disableOriginalConstructor()
100 ->getMock();
101
102 $this->setGlobalVariable('ilObjDataCache', $objectDataCache);
103 }
104
105 protected function tearDown(): void
106 {
107 }
108
109 public function testProperties(): void
110 {
111 $pm = new ilPermanentLinkGUI(
112 "wiki",
113 55
114 );
115 $pm->setAppend("append");
116 $this->assertEquals(
117 "append",
118 $pm->getAppend()
119 );
120 $pm->setId(66);
121 $this->assertEquals(
122 66,
123 $pm->getId()
124 );
125 $pm->setTitle("title");
126 $this->assertEquals(
127 "title",
128 $pm->getTitle()
129 );
130 }
131}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
setGlobalVariable(string $name, $value)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
if($format !==null) $name
Definition: metadata.php:247
$dic
Definition: result.php:32