ILIAS  release_8 Revision v8.24
LinkInputTest Class Reference
+ Inheritance diagram for LinkInputTest:
+ Collaboration diagram for LinkInputTest:

Public Member Functions

 setUp ()
 
 testImplementsFactoryInterface ()
 
 testRendering ()
 
 testProducesNullWhenNoDataExists ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Protected Member Functions

 buildFactory ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Private Attributes

DefNamesource $name_source
 

Detailed Description

Definition at line 32 of file LinkInputTest.php.

Member Function Documentation

◆ buildFactory()

LinkInputTest::buildFactory ( )
protected

Definition at line 41 of file LinkInputTest.php.

41 : Factory
42 {
43 $data_factory = new Data\Factory();
44 $language = $this->createMock(ilLanguage::class);
45 $language->method("txt")
46 ->will($this->returnArgument(0));
47
48 return new Factory(
49 $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
50 new SignalGenerator(),
51 $data_factory,
52 new ILIAS\Refinery\Factory($data_factory, $language),
53 $language
54 );
55 }
Builds data types.
Definition: Factory.php:21
This is a legacy support of Component\Input\Field\Input that has been moved to Component\Input\Contai...
Definition: Input.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.

Referenced by testImplementsFactoryInterface(), testProducesNullWhenNoDataExists(), and testRendering().

+ Here is the caller graph for this function:

◆ setUp()

LinkInputTest::setUp ( )

Reimplemented from ILIAS_UI_TestBase.

Definition at line 36 of file LinkInputTest.php.

36 : void
37 {
38 $this->name_source = new DefNamesource();
39 }

◆ testImplementsFactoryInterface()

LinkInputTest::testImplementsFactoryInterface ( )

Definition at line 57 of file LinkInputTest.php.

57 : void
58 {
59 $factory = $this->buildFactory();
60 $url = $factory->link("Test Label", "Test Byline");
61
62 $this->assertInstanceOf(Field\Link::class, $url);
63 }
$factory
Definition: metadata.php:75
$url

References $factory, $url, and buildFactory().

+ Here is the call graph for this function:

◆ testProducesNullWhenNoDataExists()

LinkInputTest::testProducesNullWhenNoDataExists ( )

Definition at line 94 of file LinkInputTest.php.

94 : void
95 {
96 $f = $this->buildFactory();
97 $input = $f->link("", "")
98 ->withNameFrom(new class () implements NameSource {
99 public function getNewName(): string
100 {
101 return "name";
102 }
103 public function getNewDedicatedName(): string
104 {
105 return "dedicated_name";
106 }
107 });
108 $input = $input->withInput(new class () implements InputData {
109 public function getOr($_, $default): string
110 {
111 return "";
112 }
113 public function get($_): string
114 {
115 return "";
116 }
117 public function has($name): bool
118 {
119 return true;
120 }
121
122 });
123 $result = $input->getContent();
124
125 $this->assertNull($result->value());
126 }
Describes how Input-Elements want to interact with posted data.
Definition: InputData.php:30
Describes a source for input names.
Definition: NameSource.php:27
if($format !==null) $name
Definition: metadata.php:247
has(string $class_name)

References Vendor\Package\$f, $name, buildFactory(), and ILIAS\GlobalScreen\has().

+ Here is the call graph for this function:

◆ testRendering()

LinkInputTest::testRendering ( )

Definition at line 65 of file LinkInputTest.php.

65 : void
66 {
67 $factory = $this->buildFactory();
68 $renderer = $this->getDefaultRenderer();
69 $label = "Test Label";
70 $byline = "Test Byline";
71 $url = $factory->link($label, $byline)->withNameFrom($this->name_source);
72 $html = $this->normalizeHTML($renderer->render($url));
73
74 $expected = '
75 <div class="form-group row">
76 <label for="id_1" class="control-label col-sm-4 col-md-3 col-lg-2">ui_link_label</label>
77 <div class="col-sm-8 col-md-9 col-lg-10">
78 <input id="id_1" type="text" name="name_0/label_1" class="form-control form-control-sm" />
79 </div>
80 </div>
81 <div class="form-group row">
82 <label for="id_2" class="control-label col-sm-4 col-md-3 col-lg-2">ui_link_url</label>
83 <div class="col-sm-8 col-md-9 col-lg-10">
84 <input id="id_2" type="url" name="name_0/url_2" class="form-control form-control-sm" />
85 </div>
86 </div>';
87
88 $this->assertEquals(
89 $this->brutallyTrimHTML($expected),
90 $this->brutallyTrimHTML($html)
91 );
92 }
normalizeHTML(string $html)
Definition: Base.php:422
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355

References $factory, $url, ILIAS_UI_TestBase\brutallyTrimHTML(), buildFactory(), ILIAS_UI_TestBase\getDefaultRenderer(), and ILIAS_UI_TestBase\normalizeHTML().

+ Here is the call graph for this function:

Field Documentation

◆ $name_source

DefNamesource LinkInputTest::$name_source
private

Definition at line 34 of file LinkInputTest.php.


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