[BUGFIX] Add missing namespace parts
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Resource / Rendering / AudioTagRendererTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Resource\Rendering;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Class AudioTagRendererTest
19 */
20 class AudioTagRendererTest extends \TYPO3\Components\TestingFramework\Core\Unit\UnitTestCase
21 {
22 /**
23 * @test
24 */
25 public function getPriorityReturnsCorrectValue()
26 {
27 $audioTagRenderer = new \TYPO3\CMS\Core\Resource\Rendering\AudioTagRenderer();
28
29 $this->assertSame(1, $audioTagRenderer->getPriority());
30 }
31
32 /**
33 * @test
34 */
35 public function canRenderReturnsTrueOnCorrectFile()
36 {
37 $audioTagRenderer = new \TYPO3\CMS\Core\Resource\Rendering\AudioTagRenderer();
38
39 $fileResourceMock1 = $this->createMock(\TYPO3\CMS\Core\Resource\File::class);
40 $fileResourceMock1->expects($this->any())->method('getMimeType')->will($this->returnValue('audio/mpeg'));
41 $fileResourceMock2 = $this->createMock(\TYPO3\CMS\Core\Resource\File::class);
42 $fileResourceMock2->expects($this->any())->method('getMimeType')->will($this->returnValue('audio/wav'));
43 $fileResourceMock3 = $this->createMock(\TYPO3\CMS\Core\Resource\File::class);
44 $fileResourceMock3->expects($this->any())->method('getMimeType')->will($this->returnValue('audio/ogg'));
45
46 $this->assertTrue($audioTagRenderer->canRender($fileResourceMock1));
47 $this->assertTrue($audioTagRenderer->canRender($fileResourceMock2));
48 $this->assertTrue($audioTagRenderer->canRender($fileResourceMock3));
49 }
50
51 /**
52 * @test
53 */
54 public function canRenderReturnsFalseOnCorrectFile()
55 {
56 $audioTagRenderer = new \TYPO3\CMS\Core\Resource\Rendering\AudioTagRenderer();
57
58 $fileResourceMock = $this->createMock(\TYPO3\CMS\Core\Resource\File::class);
59 $fileResourceMock->expects($this->any())->method('getMimeType')->will($this->returnValue('video/mp4'));
60
61 $this->assertFalse($audioTagRenderer->canRender($fileResourceMock));
62 }
63
64 /**
65 * @test
66 */
67 public function renderOutputIsCorrect()
68 {
69 $audioTagRenderer = new \TYPO3\CMS\Core\Resource\Rendering\AudioTagRenderer();
70
71 $fileResourceMock = $this->createMock(\TYPO3\CMS\Core\Resource\File::class);
72 $fileResourceMock->expects($this->any())->method('getMimeType')->will($this->returnValue('audio/mpeg'));
73 $fileResourceMock->expects($this->any())->method('getPublicUrl')->will($this->returnValue('//:path/myAudioFile?foo=bar&baz=true'));
74
75 $this->assertSame(
76 '<audio controls><source src="//:path/myAudioFile?foo=bar&amp;baz=true" type="audio/mpeg"></audio>',
77 $audioTagRenderer->render($fileResourceMock, '300m', '200')
78 );
79 }
80
81 /**
82 * @test
83 */
84 public function renderOutputWithLoopIsCorrect()
85 {
86 $audioTagRenderer = new \TYPO3\CMS\Core\Resource\Rendering\AudioTagRenderer();
87
88 $fileResourceMock = $this->createMock(\TYPO3\CMS\Core\Resource\File::class);
89 $fileResourceMock->expects($this->any())->method('getMimeType')->will($this->returnValue('audio/mpeg'));
90 $fileResourceMock->expects($this->any())->method('getPublicUrl')->will($this->returnValue('//:path/myAudioFile'));
91
92 $this->assertSame(
93 '<audio controls loop><source src="//:path/myAudioFile" type="audio/mpeg"></audio>',
94 $audioTagRenderer->render($fileResourceMock, '300m', '200', ['loop' => 1])
95 );
96 }
97
98 /**
99 * @test
100 */
101 public function renderOutputWithAutoplayIsCorrect()
102 {
103 $audioTagRenderer = new \TYPO3\CMS\Core\Resource\Rendering\AudioTagRenderer();
104
105 $fileResourceMock = $this->createMock(\TYPO3\CMS\Core\Resource\File::class);
106 $fileResourceMock->expects($this->any())->method('getMimeType')->will($this->returnValue('audio/mpeg'));
107 $fileResourceMock->expects($this->any())->method('getPublicUrl')->will($this->returnValue('//:path/myAudioFile'));
108
109 $this->assertSame(
110 '<audio controls autoplay><source src="//:path/myAudioFile" type="audio/mpeg"></audio>',
111 $audioTagRenderer->render($fileResourceMock, '300m', '200', ['autoplay' => 1])
112 );
113 }
114
115 /**
116 * @test
117 */
118 public function renderOutputWithAutoplayAndWithoutControllsIsCorrect()
119 {
120 $audioTagRenderer = new \TYPO3\CMS\Core\Resource\Rendering\AudioTagRenderer();
121
122 $fileResourceMock = $this->createMock(\TYPO3\CMS\Core\Resource\File::class);
123 $fileResourceMock->expects($this->any())->method('getMimeType')->will($this->returnValue('audio/mpeg'));
124 $fileResourceMock->expects($this->any())->method('getPublicUrl')->will($this->returnValue('//:path/myAudioFile'));
125
126 $this->assertSame(
127 '<audio autoplay><source src="//:path/myAudioFile" type="audio/mpeg"></audio>',
128 $audioTagRenderer->render($fileResourceMock, '300m', '200', ['controls' => 0, 'autoplay' => 1])
129 );
130 }
131 }