ILIAS  release_8 Revision v8.24
PlayerAudioTest.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
43 public function modal(): C\Modal\Factory
44 {
45 return new I\Component\Modal\Factory(new I\Component\SignalGenerator(), $this->factory);
46 }
47 public function button(): C\Button\Factory
48 {
49 return new I\Component\Button\Factory();
50 }
51 };
52 }
53
54 public function getFactory(): C\Player\Factory
55 {
56 return new I\Component\Player\Factory();
57 }
58
59 public function test_implements_factory_interface(): void
60 {
61 $f = $this->getFactory();
62
63 $audio = $f->audio("/foo", "bar");
64
65 $this->assertInstanceOf("ILIAS\\UI\\Component\\Player\\Audio", $audio);
66 }
67
68 public function test_get_title_get_source(): void
69 {
70 $f = $this->getFactory();
71
72 $audio = $f->audio("/foo");
73
74 $this->assertEquals("/foo", $audio->getSource());
75 }
76
77 public function test_get_title_get_transcript(): void
78 {
79 $f = $this->getFactory();
80
81 $audio = $f->audio("/foo", "bar");
82
83 $this->assertEquals("bar", $audio->getTranscription());
84 }
85
86 public function test_render_audio(): void
87 {
88 $f = $this->getFactory();
89 $r = $this->getDefaultRenderer();
90
91 $audio = $f->audio("/foo");
92
93 $html = $r->render($audio);
94
95 $expected = <<<EOT
96<div class="il-audio-container">
97 <audio class="il-audio-player" id="id_1" src="/foo" preload="metadata"></audio>
98</div>
99EOT;
100 $this->assertHTMLEquals(
101 $this->brutallyTrimHTML($expected),
102 $this->brutallyTrimHTML($html)
103 );
104 }
105
106 public function test_render_with_transcript(): void
107 {
108 $f = $this->getFactory();
109 $r = $this->getDefaultRenderer();
110
111 $audio = $f->audio("/foo", "x*123");
112
113 $html = $r->render($audio);
114
115 $this->assertEquals(
116 true,
117 is_int(strpos($html, "ui_transcription</button>"))
118 );
119 $this->assertEquals(
120 true,
121 is_int(strpos($html, "il-modal-lightbox"))
122 );
123 $this->assertEquals(
124 true,
125 is_int(strpos($html, "x*123"))
126 );
127 }
128}
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