ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PlayerAudioTest.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");
23
27
32{
33 public function getUIFactory(): NoUIFactory
34 {
35 return new class (
36 $this->createMock(I\Component\Modal\InterruptiveItem\Factory::class),
37 $this->createMock(FieldFactory::class),
38 ) extends NoUIFactory {
39 public function __construct(
40 protected I\Component\Modal\InterruptiveItem\Factory $interruptive_item_factory,
41 protected FieldFactory $field_factory,
42 ) {
43 }
44
45 public function modal(): I\Component\Modal\Factory
46 {
47 return new I\Component\Modal\Factory(
48 new I\Component\SignalGenerator(),
49 $this->interruptive_item_factory,
50 $this->field_factory,
51 );
52 }
53 public function button(): I\Component\Button\Factory
54 {
55 return new I\Component\Button\Factory();
56 }
57 };
58 }
59
60 public function getFactory(): C\Player\Factory
61 {
62 return new I\Component\Player\Factory();
63 }
64
65 public function testImplementsFactoryInterface(): void
66 {
67 $f = $this->getFactory();
68
69 $audio = $f->audio("/foo", "bar");
70
71 $this->assertInstanceOf("ILIAS\\UI\\Component\\Player\\Audio", $audio);
72 }
73
74 public function testGetTitleGetSource(): void
75 {
76 $f = $this->getFactory();
77
78 $audio = $f->audio("/foo");
79
80 $this->assertEquals("/foo", $audio->getSource());
81 }
82
83 public function testGetTitleGetTranscript(): void
84 {
85 $f = $this->getFactory();
86
87 $audio = $f->audio("/foo", "bar");
88
89 $this->assertEquals("bar", $audio->getTranscription());
90 }
91
92 public function testRenderAudio(): void
93 {
94 $f = $this->getFactory();
95 $r = $this->getDefaultRenderer();
96
97 $audio = $f->audio("/foo");
98
99 $html = $r->render($audio);
100
101 $expected = <<<EOT
102<div class="il-audio-container">
103 <audio class="il-audio-player" id="id_1" src="/foo" preload="metadata"></audio>
104</div>
105EOT;
106 $this->assertHTMLEquals(
107 $this->brutallyTrimHTML($expected),
108 $this->brutallyTrimHTML($html)
109 );
110 }
111
112 public function testRenderWithTranscript(): void
113 {
114 $f = $this->getFactory();
115 $r = $this->getDefaultRenderer();
116
117 $audio = $f->audio("/foo", "x*123");
118
119 $html = $r->render($audio);
120
121 $this->assertEquals(
122 true,
123 is_int(strpos($html, "ui_transcription</button>"))
124 );
125 $this->assertEquals(
126 true,
127 is_int(strpos($html, "il-modal-lightbox"))
128 );
129 $this->assertEquals(
130 true,
131 is_int(strpos($html, "x*123"))
132 );
133 }
134}
Factory for Date Formats.
Definition: Factory.php:27
Provides common functionality for UI tests.
Definition: Base.php:337
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
modal(string $title="", string $cancel_label="")
button(string $caption, string $cmd)