ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
UrlInputTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21require_once(__DIR__ . "/../../../../../../../vendor/composer/vendor/autoload.php");
22require_once(__DIR__ . "/../../../Base.php");
23require_once(__DIR__ . "/InputTest.php");
24require_once(__DIR__ . "/CommonFieldRendering.php");
25
29use ILIAS\Data;
30use ILIAS\Refinery\Factory as Refinery;
31
33{
34 use CommonFieldRendering;
35
37
38 public function setUp(): void
39 {
40 $this->name_source = new DefNamesource();
41 }
42
43 public function testImplementsFactoryInterface(): void
44 {
45 $factory = $this->getFieldFactory();
46 $url = $factory->url("Test Label", "Test Byline");
47
48 $this->assertInstanceOf(\ILIAS\UI\Component\Input\Container\Form\FormInput::class, $url);
49 $this->assertInstanceOf(Field\Url::class, $url);
50 }
51
52 public function testRendering(): void
53 {
54 $factory = $this->getFieldFactory();
55 $renderer = $this->getDefaultRenderer();
56 $label = "Test Label";
57 $byline = "Test Byline";
58 $url = $factory->url($label, $byline)->withNameFrom($this->name_source);
59 $expected = $this->getFormWrappedHtml(
60 'url-field-input',
61 $label,
62 '<input id="id_1" type="url" name="name_0" class="c-field-url" />',
63 $byline,
64 'id_1'
65 );
66 $this->assertEquals($expected, $this->render($url));
67 }
68
69 public function testRenderValue(): void
70 {
71 $factory = $this->getFieldFactory();
72 $label = "Test Label";
73 $value = "https://www.ilias.de/";
74 $url = $factory->url($label)->withValue($value)
75 ->withNameFrom($this->name_source);
76 $expected = $this->getFormWrappedHtml(
77 'url-field-input',
78 $label,
79 '<input id="id_1" type="url" value="https://www.ilias.de/" name="name_0" class="c-field-url" />',
80 null,
81 'id_1'
82 );
83 $this->assertEquals($expected, $this->render($url));
84 }
85
86 public function testCommonRendering(): void
87 {
88 $f = $this->getFieldFactory();
89 $url = $f->url('label', null)->withNameFrom($this->name_source);
90
91 $this->testWithError($url);
92 $this->testWithNoByline($url);
93 $this->testWithRequired($url);
94 $this->testWithDisabled($url);
95 $this->testWithAdditionalOnloadCodeRendersId($url);
96 }
97
98}
$renderer
Builds data types.
Definition: Factory.php:36
Definition: UI.php:24
Provides common functionality for UI tests.
Definition: Base.php:337
testImplementsFactoryInterface()
DefNamesource $name_source
This describes commonalities between all inputs.
Definition: Input.php:47
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Checkbox.php:21
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
$url
Definition: shib_logout.php:68