ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
LegacyTest.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2016 Timon Amstutz <timon.amstutz@ilub.unibe.ch> Extended GPL, see docs/LICENSE */
4
5require_once(__DIR__ . "/../../../../libs/composer/vendor/autoload.php");
6require_once(__DIR__ . "/../../Base.php");
7
8use \ILIAS\UI\Component as C;
9use \ILIAS\UI\Implementation\Component as IC;
10
15{
16 public function getUIFactory()
17 {
18 $factory = new class extends NoUIFactory {
19 public function legacy($content)
20 {
21 return new IC\Legacy\Legacy($content, new IC\SignalGenerator());
22 }
23 };
24 return $factory;
25 }
26
28 {
29 $f = $this->getUIFactory();
30
31 $this->assertInstanceOf("ILIAS\\UI\\Factory", $f);
32 $this->assertInstanceOf(
33 "ILIAS\\UI\\Component\\Legacy\\Legacy",
34 $f->legacy("Legacy Content")
35 );
36 }
37
38 public function test_get_content()
39 {
40 $f = $this->getUIFactory();
41 $g = $f->legacy("Legacy Content");
42
43 $this->assertEquals($g->getContent(), "Legacy Content");
44 }
45
46
47 public function test_render_content()
48 {
49 $f = $this->getUIFactory();
50 $r = $this->getDefaultRenderer();
51
52 $g = $f->legacy("Legacy Content");
53
54 $this->assertEquals($r->render($g), "Legacy Content");
55 }
56
61 {
62 $f = $this->getUIFactory();
63 $signal_name = 'Custom Signal';
64
65 $g = $f->legacy('')->withCustomSignal($signal_name, '');
66 }
67
69 {
70 $f = $this->getUIFactory();
71 $signal_name = 'Custom Signal';
72 $g = $f->legacy('')->withCustomSignal($signal_name, '');
73
74 $this->assertNotNull($g->getCustomSignal($signal_name));
75 }
76
78 {
79 $f = $this->getUIFactory();
80 $signal_name = 'Custom Signal';
81 $g = $f->legacy('');
82
83 $this->expectException(InvalidArgumentException::class);
84 $this->expectExceptionMessage("Signal with name $signal_name is not registered");
85 $g->getCustomSignal($signal_name);
86 }
87
88 public function test_get_list_of_signals()
89 {
90 $f = $this->getUIFactory();
91 $signal_name_1 = 'Custom Signal 1';
92 $signal_name_2 = 'Custom Signal 2';
93
94 $g = $f->legacy('')->withCustomSignal($signal_name_1, '')->withCustomSignal($signal_name_2, '');
95 $l = $g->getAllCustomSignals();
96
97 $this->assertIsArray($l);
98 }
99
101 {
102 $f = $this->getUIFactory();
103 $signal_name_1 = 'Custom Signal 1';
104 $custom_code_1 = 'custom_js1();';
105 $signal_name_2 = 'Custom Signal 2';
106 $custom_code_2 = 'custom_js2();';
107
108 $g = $f->legacy('')
109 ->withCustomSignal($signal_name_1, $custom_code_1)
110 ->withCustomSignal($signal_name_2, $custom_code_2);
111 $signal_list = $g->getAllCustomSignals();
112
113 $this->assertEquals(count($signal_list), 2);
114 $this->assertEquals($signal_list[$signal_name_1]['js_code'], $custom_code_1);
115 $this->assertEquals($signal_list[$signal_name_2]['js_code'], $custom_code_2);
116 }
117}
An exception for terminatinating execution or to throw for unit testing.
Provides common functionality for UI tests.
Definition: Base.php:225
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
Test on button implementation.
Definition: LegacyTest.php:15
test_get_content()
Definition: LegacyTest.php:38
test_get_list_with_custom_signals_and_code()
Definition: LegacyTest.php:100
test_create_with_custom_signal()
@doesNotPerformAssertions
Definition: LegacyTest.php:60
test_render_content()
Definition: LegacyTest.php:47
test_get_non_existing_custom_signal()
Definition: LegacyTest.php:77
test_get_existing_custom_signal()
Definition: LegacyTest.php:68
test_implements_factory_interface()
Definition: LegacyTest.php:27
test_get_list_of_signals()
Definition: LegacyTest.php:88
legacy()
Definition: legacy.php:3
$factory
Definition: metadata.php:58