ILIAS  release_8 Revision v8.24
PlayerVideoTest.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
27
32{
33 public function getUIFactory(): NoUIFactory
34 {
35 $field_factory = $this->createMock(FieldFactory::class);
36 return new class ($field_factory) extends NoUIFactory {
37 protected FieldFactory $factory;
38 public function __construct(FieldFactory $factory)
39 {
40 $this->factory = $factory;
41 }
42 public function modal(): C\Modal\Factory
43 {
44 return new I\Component\Modal\Factory(new I\Component\SignalGenerator(), $this->factory);
45 }
46 public function button(): C\Button\Factory
47 {
48 return new I\Component\Button\Factory();
49 }
50 };
51 }
52
53 public function getFactory(): C\Player\Factory
54 {
55 return new I\Component\Player\Factory();
56 }
57
58 public function test_implements_factory_interface(): void
59 {
60 $f = $this->getFactory();
61
62 $video = $f->video("/foo");
63
64 $this->assertInstanceOf("ILIAS\\UI\\Component\\Player\\Video", $video);
65 }
66
67 public function test_get_title_get_source(): void
68 {
69 $f = $this->getFactory();
70
71 $video = $f->video("/foo");
72
73 $this->assertEquals("/foo", $video->getSource());
74 }
75
76 public function test_get_title_get_poster(): void
77 {
78 $f = $this->getFactory();
79
80 $video = $f->video("/foo")->withPoster("bar.jpg");
81
82 $this->assertEquals("bar.jpg", $video->getPoster());
83 }
84
85 public function test_get_title_get_subtitle_file(): void
86 {
87 $f = $this->getFactory();
88
89 $video = $f->video("/foo")->withAdditionalSubtitleFile("en", "subtitles.vtt");
90
91 $this->assertEquals(["en" => "subtitles.vtt"], $video->getSubtitleFiles());
92 }
93
94 public function test_render_video(): void
95 {
96 $f = $this->getFactory();
97 $r = $this->getDefaultRenderer();
98
99 $video = $f->video("/foo");
100
101 $html = $r->render($video);
102 $expected = <<<EOT
103<div class="il-video-container">
104 <video class="il-video-player" id="id_1" src="/foo" style="max-width: 100%;" preload="metadata" >
105 </video>
106</div>
107EOT;
108 $this->assertHTMLEquals(
109 $this->brutallyTrimHTML($expected),
110 $this->brutallyTrimHTML($html)
111 );
112 }
113
114 public function test_render_with_poster(): void
115 {
116 $f = $this->getFactory();
117 $r = $this->getDefaultRenderer();
118
119 $video = $f->video("/foo")->withPoster("bar.jpg");
120
121 $html = $r->render($video);
122
123 $expected = <<<EOT
124<div class="il-video-container">
125 <video class="il-video-player" id="id_1" src="/foo" style="max-width: 100%;" preload="metadata" poster="bar.jpg">
126 </video>
127</div>
128EOT;
129 $this->assertHTMLEquals(
130 $this->brutallyTrimHTML($expected),
131 $this->brutallyTrimHTML($html)
132 );
133 }
134
135 public function test_render_with_subtitles(): void
136 {
137 $f = $this->getFactory();
138 $r = $this->getDefaultRenderer();
139
140 $video = $f->video("/foo")->withAdditionalSubtitleFile("en", "subtitles.vtt");
141
142 $html = $r->render($video);
143 $expected = <<<EOT
144<div class="il-video-container">
145 <video class="il-video-player" id="id_1" src="/foo" style="max-width: 100%;" preload="metadata" >
146 <track kind="subtitles" src="subtitles.vtt" srclang="en" />
147 </video>
148</div>
149EOT;
150 $this->assertHTMLEquals(
151 $this->brutallyTrimHTML($expected),
152 $this->brutallyTrimHTML($html)
153 );
154 }
155}
Provides common functionality for UI tests.
Definition: Base.php:299
assertHTMLEquals(string $expected_html_as_string, string $html_as_string)
Definition: Base.php:427
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This is what a factory for input fields looks like.
Definition: Factory.php:29
$factory
Definition: metadata.php:75
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
modal()
This second example shows a scenario in which the Close Button is used in an overlay as indicated in ...
Definition: modal.php:12