diff --git a/typo3/sysext/core/Classes/Resource/Rendering/VideoTagRenderer.php b/typo3/sysext/core/Classes/Resource/Rendering/VideoTagRenderer.php index 3408234b23cd74e167afb00a30b623756b2267c4..719802c14ddbf5a81356a603ef50221f5fa1426d 100644 --- a/typo3/sysext/core/Classes/Resource/Rendering/VideoTagRenderer.php +++ b/typo3/sysext/core/Classes/Resource/Rendering/VideoTagRenderer.php @@ -77,10 +77,10 @@ class VideoTagRenderer implements FileRendererInterface } $attributes = []; - if (is_array($options['additionalAttributes'])) { + if (isset($options['additionalAttributes']) && is_array($options['additionalAttributes'])) { $attributes[] = GeneralUtility::implodeAttributes($options['additionalAttributes'], true, true); } - if (is_array($options['data'])) { + if (isset($options['data']) && is_array($options['data'])) { array_walk($options['data'], function (&$value, $key) { $value = 'data-' . htmlspecialchars($key) . '="' . htmlspecialchars($value) . '"'; }); @@ -104,7 +104,7 @@ class VideoTagRenderer implements FileRendererInterface if (!empty($options['loop'])) { $attributes[] = 'loop'; } - if (is_array($options['additionalConfig'])) { + if (isset($options['additionalConfig']) && is_array($options['additionalConfig'])) { foreach ($options['additionalConfig'] as $key => $value) { if ((bool)$value) { $attributes[] = htmlspecialchars($key); diff --git a/typo3/sysext/core/Tests/Unit/Resource/Rendering/VideoTagRendererTest.php b/typo3/sysext/core/Tests/Unit/Resource/Rendering/VideoTagRendererTest.php index 6380e1d44c6caa3dc0e1aa19e72d01f3ee06609d..6c26362c1c8890e6037653fa5dfe10305abff535 100644 --- a/typo3/sysext/core/Tests/Unit/Resource/Rendering/VideoTagRendererTest.php +++ b/typo3/sysext/core/Tests/Unit/Resource/Rendering/VideoTagRendererTest.php @@ -1,4 +1,5 @@ <?php +declare(strict_types = 1); namespace TYPO3\CMS\Core\Tests\Unit\Resource\Rendering; /* @@ -14,22 +15,21 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource\Rendering; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Resource\File; +use TYPO3\CMS\Core\Resource\Rendering\VideoTagRenderer; +use TYPO3\TestingFramework\Core\Unit\UnitTestCase; + /** * Class VideoTagRendererTest */ -class VideoTagRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase +class VideoTagRendererTest extends UnitTestCase { - /** - * Subject is not notice free, disable E_NOTICES - */ - protected static $suppressNotices = true; - /** * @test */ public function getPriorityReturnsCorrectValue() { - $VideoTagRenderer = new \TYPO3\CMS\Core\Resource\Rendering\VideoTagRenderer(); + $VideoTagRenderer = new VideoTagRenderer(); $this->assertSame(1, $VideoTagRenderer->getPriority()); } @@ -39,15 +39,15 @@ class VideoTagRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas */ public function canRenderReturnsTrueOnCorrectFile() { - $VideoTagRenderer = new \TYPO3\CMS\Core\Resource\Rendering\VideoTagRenderer(); + $VideoTagRenderer = new VideoTagRenderer(); - $fileResourceMock1 = $this->createMock(\TYPO3\CMS\Core\Resource\File::class); + $fileResourceMock1 = $this->createMock(File::class); $fileResourceMock1->expects($this->any())->method('getMimeType')->will($this->returnValue('video/mp4')); - $fileResourceMock2 = $this->createMock(\TYPO3\CMS\Core\Resource\File::class); + $fileResourceMock2 = $this->createMock(File::class); $fileResourceMock2->expects($this->any())->method('getMimeType')->will($this->returnValue('video/webm')); - $fileResourceMock3 = $this->createMock(\TYPO3\CMS\Core\Resource\File::class); + $fileResourceMock3 = $this->createMock(File::class); $fileResourceMock3->expects($this->any())->method('getMimeType')->will($this->returnValue('video/ogg')); - $fileResourceMock4 = $this->createMock(\TYPO3\CMS\Core\Resource\File::class); + $fileResourceMock4 = $this->createMock(File::class); $fileResourceMock4->expects($this->any())->method('getMimeType')->will($this->returnValue('application/ogg')); $this->assertTrue($VideoTagRenderer->canRender($fileResourceMock1)); @@ -61,9 +61,9 @@ class VideoTagRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas */ public function canRenderReturnsFalseOnCorrectFile() { - $VideoTagRenderer = new \TYPO3\CMS\Core\Resource\Rendering\VideoTagRenderer(); + $VideoTagRenderer = new VideoTagRenderer(); - $fileResourceMock = $this->createMock(\TYPO3\CMS\Core\Resource\File::class); + $fileResourceMock = $this->createMock(File::class); $fileResourceMock->expects($this->any())->method('getMimeType')->will($this->returnValue('audio/mpeg')); $this->assertFalse($VideoTagRenderer->canRender($fileResourceMock)); @@ -140,9 +140,9 @@ class VideoTagRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas */ public function renderOutputIsCorrect($url, $arguments, $expected) { - $VideoTagRenderer = new \TYPO3\CMS\Core\Resource\Rendering\VideoTagRenderer(); + $VideoTagRenderer = new VideoTagRenderer(); - $fileResourceMock = $this->createMock(\TYPO3\CMS\Core\Resource\File::class); + $fileResourceMock = $this->createMock(File::class); $fileResourceMock->expects($this->any())->method('getMimeType')->will($this->returnValue('video/mp4')); $fileResourceMock->expects($this->any())->method('getPublicUrl')->will($this->returnValue($url));