ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilContactGUITest Class Reference
+ Inheritance diagram for ilContactGUITest:
+ Collaboration diagram for ilContactGUITest:

Public Member Functions

 setUp ()
 
 tearDown ()
 
 testConstruct ()
 
 testShowContacts ()
 

Private Member Functions

 setBuddySystem (?ilBuddySystem $system)
 
 setMailRefId (?int $mail_ref)
 

Private Attributes

Container $old_dic = null
 
array $container = []
 

Detailed Description

Definition at line 37 of file ilContactGUITest.php.

Member Function Documentation

◆ setBuddySystem()

ilContactGUITest::setBuddySystem ( ?ilBuddySystem  $system)
private

Definition at line 152 of file ilContactGUITest.php.

152 : void
153 {
154 $p = new ReflectionProperty(ilBuddySystem::class, 'instance');
155 $p->setValue(null, $system);
156 }

Referenced by testShowContacts().

+ Here is the caller graph for this function:

◆ setMailRefId()

ilContactGUITest::setMailRefId ( ?int  $mail_ref)
private

Definition at line 158 of file ilContactGUITest.php.

158 : void
159 {
160 $p = new ReflectionProperty(ilMailGlobalServices::class, 'global_mail_services_cache');
161 $array = $p->getValue();
162 $array[ilMailGlobalServices::CACHE_TYPE_REF_ID] = $mail_ref;
163 $p->setValue(null, $array);
164 }

References ilMailGlobalServices\CACHE_TYPE_REF_ID.

Referenced by testShowContacts().

+ Here is the caller graph for this function:

◆ setUp()

ilContactGUITest::setUp ( )

Definition at line 44 of file ilContactGUITest.php.

44 : void
45 {
46 $this->container = [
47 'ilDB' => $this->mock(ilDBInterface::class),
48 'tpl' => $this->mock(ilGlobalTemplateInterface::class),
49 'ilCtrl' => $this->mock(ilCtrlInterface::class),
50 'lng' => $this->mock(ilLanguage::class),
51 'ilTabs' => $this->mock(ilTabsGUI::class),
52 'ilHelp' => $this->mock(ilHelpGUI::class),
53 'ilToolbar' => $this->mock(ilToolbarGUI::class),
54 'ilUser' => $this->mock(ilObjUser::class),
55 'ilErr' => $this->mock(ilErrorHandling::class),
56 'rbacsystem' => $this->mock(ilRbacSystem::class),
57 'ui.renderer' => $this->mock(Renderer::class),
58 'ui.factory' => $this->mock(UIFactory::class),
59 'query' => $this->mock(ArrayBasedRequestWrapper::class),
60 'static_url' => $this->mock(StaticURL::class),
61 'ilObjDataCache' => $this->mock(ilObjectDataCache::class),
62 ];
63 $this->old_dic = $GLOBALS['DIC'] ?? null;
64 $GLOBALS['DIC'] = $this->mockTree(Container::class, [
65 'database' => $this->container['ilDB'],
66 'ui' => ['renderer' => $this->container['ui.renderer'], 'factory' => $this->container['ui.factory']],
67 'http' => ['wrapper' => ['query' => $this->container['query']]],
68 ]);
69 $GLOBALS['DIC']->method('offsetGet')->willReturnCallback(fn($k) => $this->container[$k]);
70 }
$GLOBALS["DIC"]
Definition: wac.php:54

References $GLOBALS.

◆ tearDown()

ilContactGUITest::tearDown ( )

Definition at line 72 of file ilContactGUITest.php.

72 : void
73 {
74 $GLOBALS['DIC'] = $this->old_dic;
75 }

References $GLOBALS, and $old_dic.

◆ testConstruct()

ilContactGUITest::testConstruct ( )

Definition at line 77 of file ilContactGUITest.php.

77 : void
78 {
79 if (!defined('ILIAS_LOG_ENABLED')) {
80 define('ILIAS_LOG_ENABLED', false);
81 }
82
83 $this->assertInstanceOf(ilContactGUI::class, new ilContactGUI((new class () extends ilFormatMail {
84 public function __construct()
85 {
86 }
87 })::class));
88 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

◆ testShowContacts()

ilContactGUITest::testShowContacts ( )

Definition at line 90 of file ilContactGUITest.php.

90 : void
91 {
92 $this->setMailRefId(123);
93 $this->setBuddySystem($this->mockMethod(ilBuddySystem::class, 'isEnabled', [], true));
94
95 if (!defined('ILIAS_HTTP_PATH')) {
96 define('ILIAS_HTTP_PATH', 'http://ilias.de/');
97 }
98 if (!defined('CLIENT_ID')) {
99 define('CLIENT_ID', 'dummy');
100 }
101
102 $query_params = [
103 'inv_room_ref_id' => 9,
104 'inv_usr_ids' => [56],
105 ];
106
107 $this->container['query']->expects(self::exactly(2))->method('retrieve')->willReturnCallback(fn(string $key) => $query_params[$key]);
108
109 $this->container['query']->method('has')->willReturnCallback(fn($key) => isset($query_params[$key]));
110
111 $relations_table_class = get_class(new class () extends RelationsTable {
112 public static array $components;
113 public function __construct()
114 {
115 }
116
117 public function build(array $multi_actions, string $target_url, callable $action): array
118 {
119 return self::$components;
120 }
121 });
122
123 $relations_table_class::$components = [$this->mock(Component::class)];
124
125 $ul = $this->mock(Unordered::class);
126 $message_box = $this->mock(MessageBox::class);
127 $message_box->expects(self::once())->method('withButtons')->willReturn($message_box);
128
129
130 $this->container['ui.factory']->method('messageBox')->willReturn($this->mockTree(MessageBoxFactory::class, ['success' => $message_box]));
131 $this->container['ui.factory']->method('listing')->willReturn($this->mockTree(Listing::class, ['unordered' => $ul]));
132
133 $render_params = [null, 'bar' => $ul, 'foo' => [$message_box, ...$relations_table_class::$components]];
134 $this->container['ui.renderer']->expects(self::exactly(2))->method('render')->willReturnCallback(function ($arg) use (&$render_params) {
135 $this->assertSame(next($render_params), $arg);
136 return key($render_params);
137 });
138 $this->container['tpl']->expects(self::once())->method('setContent')->with('foo');
139
140 $gui = new ilContactGUI(get_class(new class () extends ilFormatMail {
141 public function __construct()
142 {
143 }
144 }), $relations_table_class);
145
146 (new ReflectionMethod($gui, 'showContacts'))->invoke($gui);
147
148 $this->setBuddySystem(null);
149 $this->setMailRefId(null);
150 }
$components
setMailRefId(?int $mail_ref)
setBuddySystem(?ilBuddySystem $system)

References $components, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\User\Profile\ChangeMail\next, setBuddySystem(), and setMailRefId().

+ Here is the call graph for this function:

Field Documentation

◆ $container

array ilContactGUITest::$container = []
private

Definition at line 42 of file ilContactGUITest.php.

◆ $old_dic

Container ilContactGUITest::$old_dic = null
private

Definition at line 41 of file ilContactGUITest.php.

Referenced by tearDown().


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