[TASK] Make AudioTagRendererTest notice free 15/56315/3
authorSascha Löffler <lsascha@gmail.com>
Sat, 17 Mar 2018 14:51:49 +0000 (15:51 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 17 Mar 2018 17:03:34 +0000 (18:03 +0100)
Resolves: #84439
Releases: master
Change-Id: Id230be5a20b0bbc21590636502e9ce2fb58d8c7d
Reviewed-on: https://review.typo3.org/56315
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/AudioTagRenderer.php
typo3/sysext/core/Tests/Unit/Resource/Rendering/AudioTagRendererTest.php

index 44cfd18..3bc4139 100644 (file)
@@ -77,10 +77,10 @@ class AudioTagRenderer implements FileRendererInterface
         }
 
         $additionalAttributes = [];
-        if (is_array($options['additionalAttributes'])) {
+        if (isset($options['additionalAttributes']) && is_array($options['additionalAttributes'])) {
             $additionalAttributes[] = 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) . '"';
             });
index 1d163e7..93dc4e5 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\AudioTagRenderer;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
 /**
  * Class AudioTagRendererTest
  */
-class AudioTagRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class AudioTagRendererTest extends UnitTestCase
 {
     /**
-     * Subject is not notice free, disable E_NOTICES
-     */
-    protected static $suppressNotices = true;
-
-    /**
      * @test
      */
     public function getPriorityReturnsCorrectValue()
     {
-        $audioTagRenderer = new \TYPO3\CMS\Core\Resource\Rendering\AudioTagRenderer();
+        $audioTagRenderer = new AudioTagRenderer();
 
         $this->assertSame(1, $audioTagRenderer->getPriority());
     }
@@ -39,13 +39,13 @@ class AudioTagRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
      */
     public function canRenderReturnsTrueOnCorrectFile()
     {
-        $audioTagRenderer = new \TYPO3\CMS\Core\Resource\Rendering\AudioTagRenderer();
+        $audioTagRenderer = new AudioTagRenderer();
 
-        $fileResourceMock1 = $this->createMock(\TYPO3\CMS\Core\Resource\File::class);
+        $fileResourceMock1 = $this->createMock(File::class);
         $fileResourceMock1->expects($this->any())->method('getMimeType')->will($this->returnValue('audio/mpeg'));
-        $fileResourceMock2 = $this->createMock(\TYPO3\CMS\Core\Resource\File::class);
+        $fileResourceMock2 = $this->createMock(File::class);
         $fileResourceMock2->expects($this->any())->method('getMimeType')->will($this->returnValue('audio/wav'));
-        $fileResourceMock3 = $this->createMock(\TYPO3\CMS\Core\Resource\File::class);
+        $fileResourceMock3 = $this->createMock(File::class);
         $fileResourceMock3->expects($this->any())->method('getMimeType')->will($this->returnValue('audio/ogg'));
 
         $this->assertTrue($audioTagRenderer->canRender($fileResourceMock1));
@@ -58,9 +58,9 @@ class AudioTagRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
      */
     public function canRenderReturnsFalseOnCorrectFile()
     {
-        $audioTagRenderer = new \TYPO3\CMS\Core\Resource\Rendering\AudioTagRenderer();
+        $audioTagRenderer = new AudioTagRenderer();
 
-        $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'));
 
         $this->assertFalse($audioTagRenderer->canRender($fileResourceMock));
@@ -125,9 +125,9 @@ class AudioTagRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
      */
     public function renderOutputIsCorrect($url, $arguments, $expected)
     {
-        $audioTagRenderer = new \TYPO3\CMS\Core\Resource\Rendering\AudioTagRenderer();
+        $audioTagRenderer = new AudioTagRenderer();
 
-        $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'));
         $fileResourceMock->expects($this->any())->method('getPublicUrl')->will($this->returnValue($url));