[TASK] Make VideoTagRendererTest notice free 04/56304/2
authorSascha Löffler <lsascha@gmail.com>
Sat, 17 Mar 2018 13:57:50 +0000 (14:57 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 17 Mar 2018 16:13:06 +0000 (17:13 +0100)
Resolves: #84433
Releases: master
Change-Id: I4ecb9db21c0d3a06d1e345b8ddef6ff1328ee512
Reviewed-on: https://review.typo3.org/56304
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Resource/Rendering/VideoTagRenderer.php
typo3/sysext/core/Tests/Unit/Resource/Rendering/VideoTagRendererTest.php

index 3408234..719802c 100644 (file)
@@ -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);
index 6380e1d..6c26362 100644 (file)
@@ -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));