Skip to content

Commit

Permalink
[TASK] Make PdoBackendTest notice free
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
lsascha authored and tmotyl committed Mar 16, 2018
1 parent ad2f598 commit 9aa6349
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion typo3/sysext/core/Classes/Log/Writer/FileWriter.php
Expand Up @@ -152,7 +152,7 @@ public function writeLog(LogRecord $record)
*/
protected function openLogFile()
{
if (is_resource(self::$logFileHandles[$this->logFile])) {
if (isset(self::$logFileHandles[$this->logFile]) && is_resource(self::$logFileHandles[$this->logFile])) {
return;
}

Expand Down
26 changes: 14 additions & 12 deletions typo3/sysext/core/Tests/Unit/Cache/Backend/PdoBackendTest.php
@@ -1,4 +1,5 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;

/*
Expand All @@ -14,16 +15,17 @@
* 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
*/
Expand All @@ -39,10 +41,10 @@ protected function setUp()
*/
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);
Expand Down Expand Up @@ -218,11 +220,11 @@ public function flushRemovesAllCacheEntries()
*/
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);
Expand Down Expand Up @@ -279,9 +281,9 @@ public function collectGarbageReallyRemovesAllExpiredCacheEntries()
*/
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();
Expand Down

0 comments on commit 9aa6349

Please sign in to comment.