[TASK] Make PdoBackendTest notice free 58/56258/2
authorSascha Löffler <lsascha@gmail.com>
Fri, 16 Mar 2018 21:16:41 +0000 (22:16 +0100)
committerTymoteusz Motylewski <t.motylewski@gmail.com>
Fri, 16 Mar 2018 21:30:10 +0000 (22:30 +0100)
Resolves: #84378
Releases: master
Change-Id: Ia17ae3e651da32507d43c313cab73e7bd34632e9
Reviewed-on: https://review.typo3.org/56258
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
typo3/sysext/core/Classes/Log/Writer/FileWriter.php
typo3/sysext/core/Tests/Unit/Cache/Backend/PdoBackendTest.php

index 25a4f27..d7022fe 100644 (file)
@@ -152,7 +152,7 @@ class FileWriter extends AbstractWriter
      */
     protected function openLogFile()
     {
-        if (is_resource(self::$logFileHandles[$this->logFile])) {
+        if (isset(self::$logFileHandles[$this->logFile]) && is_resource(self::$logFileHandles[$this->logFile])) {
             return;
         }
 
index 856e0b2..c9b6505 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;
 
 /*
@@ -14,17 +15,18 @@ namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Cache\Backend\PdoBackend;
+use TYPO3\CMS\Core\Cache\Exception;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
 /**
  * Testcase for the PDO cache backend
  */
-class PdoBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class PdoBackendTest extends UnitTestCase
 {
     /**
-     * Subject is not notice free, disable E_NOTICES
-     */
-    protected static $suppressNotices = true;
-
-    /**
      * Sets up this testcase
      */
     protected function setUp()
@@ -39,10 +41,10 @@ class PdoBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function setThrowsExceptionIfNoFrontEndHasBeenSet()
     {
-        $this->expectException(\TYPO3\CMS\Core\Cache\Exception::class);
+        $this->expectException(Exception::class);
         $this->expectExceptionCode(1259515600);
 
-        $backend = new \TYPO3\CMS\Core\Cache\Backend\PdoBackend('Testing');
+        $backend = new PdoBackend('Testing');
         $data = 'Some data';
         $identifier = 'MyIdentifier';
         $backend->set($identifier, $data);
@@ -218,11 +220,11 @@ class PdoBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function flushRemovesOnlyOwnEntries()
     {
-        $thisCache = $this->createMock(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface::class);
+        $thisCache = $this->createMock(FrontendInterface::class);
         $thisCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thisCache'));
         $thisBackend = $this->setUpBackend();
         $thisBackend->setCache($thisCache);
-        $thatCache = $this->createMock(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface::class);
+        $thatCache = $this->createMock(FrontendInterface::class);
         $thatCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('thatCache'));
         $thatBackend = $this->setUpBackend();
         $thatBackend->setCache($thatCache);
@@ -279,9 +281,9 @@ class PdoBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     protected function setUpBackend()
     {
-        $mockCache = $this->createMock(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface::class);
+        $mockCache = $this->createMock(FrontendInterface::class);
         $mockCache->expects($this->any())->method('getIdentifier')->will($this->returnValue('TestCache'));
-        $backend = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\Backend\PdoBackend::class, 'Testing');
+        $backend = GeneralUtility::makeInstance(PdoBackend::class, 'Testing');
         $backend->setCache($mockCache);
         $backend->setDataSourceName('sqlite::memory:');
         $backend->initializeObject();