ILIAS  release_8 Revision v8.24
LegacyTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21require_once(__DIR__ . "/../../../../libs/composer/vendor/autoload.php");
22require_once(__DIR__ . "/../../Base.php");
23
26
31{
32 public function getUIFactory(): NoUIFactory
33 {
34 return new class () extends NoUIFactory {
35 public function legacy(string $content): C\Legacy\Legacy
36 {
37 return new IC\Legacy\Legacy($content, new IC\SignalGenerator());
38 }
39 };
40 }
41
42 public function test_implements_factory_interface(): void
43 {
44 $f = $this->getUIFactory();
45
46 $this->assertInstanceOf("ILIAS\\UI\\Factory", $f);
47 $this->assertInstanceOf(
48 "ILIAS\\UI\\Component\\Legacy\\Legacy",
49 $f->legacy("Legacy Content")
50 );
51 }
52
53 public function test_get_content(): void
54 {
55 $f = $this->getUIFactory();
56 $g = $f->legacy("Legacy Content");
57
58 $this->assertEquals("Legacy Content", $g->getContent());
59 }
60
61
62 public function test_render_content(): void
63 {
64 $f = $this->getUIFactory();
65 $r = $this->getDefaultRenderer();
66
67 $g = $f->legacy("Legacy Content");
68
69 $this->assertEquals("Legacy Content", $r->render($g));
70 }
71
75 public function test_create_with_custom_signal(): void
76 {
77 $f = $this->getUIFactory();
78 $signal_name = 'Custom Signal';
79
80 $f->legacy('')->withCustomSignal($signal_name, '');
81 }
82
83 public function test_get_existing_custom_signal(): void
84 {
85 $f = $this->getUIFactory();
86 $signal_name = 'Custom Signal';
87 $g = $f->legacy('')->withCustomSignal($signal_name, '');
88
89 $this->assertNotNull($g->getCustomSignal($signal_name));
90 }
91
93 {
94 $f = $this->getUIFactory();
95 $signal_name = 'Custom Signal';
96 $g = $f->legacy('');
97
98 $this->expectException(InvalidArgumentException::class);
99 $this->expectExceptionMessage("Signal with name $signal_name is not registered");
100 $g->getCustomSignal($signal_name);
101 }
102
103 public function test_get_list_of_signals(): void
104 {
105 $f = $this->getUIFactory();
106 $signal_name_1 = 'Custom Signal 1';
107 $signal_name_2 = 'Custom Signal 2';
108
109 $g = $f->legacy('')->withCustomSignal($signal_name_1, '')->withCustomSignal($signal_name_2, '');
110 $l = $g->getAllCustomSignals();
111
112 $this->assertIsArray($l);
113 }
114
116 {
117 $f = $this->getUIFactory();
118 $signal_name_1 = 'Custom Signal 1';
119 $custom_code_1 = 'custom_js1();';
120 $signal_name_2 = 'Custom Signal 2';
121 $custom_code_2 = 'custom_js2();';
122
123 $g = $f->legacy('')
124 ->withCustomSignal($signal_name_1, $custom_code_1)
125 ->withCustomSignal($signal_name_2, $custom_code_2);
126 $signal_list = $g->getAllCustomSignals();
127
128 $this->assertEquals(2, count($signal_list));
129 $this->assertEquals($signal_list[$signal_name_1]['js_code'], $custom_code_1);
130 $this->assertEquals($signal_list[$signal_name_2]['js_code'], $custom_code_2);
131 }
132}
Provides common functionality for UI tests.
Definition: Base.php:299
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: LegacyTest.php:31
test_get_content()
Definition: LegacyTest.php:53
test_get_list_with_custom_signals_and_code()
Definition: LegacyTest.php:115
test_create_with_custom_signal()
@doesNotPerformAssertions
Definition: LegacyTest.php:75
test_render_content()
Definition: LegacyTest.php:62
test_get_non_existing_custom_signal()
Definition: LegacyTest.php:92
test_get_existing_custom_signal()
Definition: LegacyTest.php:83
test_implements_factory_interface()
Definition: LegacyTest.php:42
test_get_list_of_signals()
Definition: LegacyTest.php:103
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...