Skip to content

Commit

Permalink
[TASK] Make IconFactoryTest notice free
Browse files Browse the repository at this point in the history
Resolves: #84377
Releases: master
Change-Id: I13aee8542becdb3d537f622de4068abbea3aa0b5
Reviewed-on: https://review.typo3.org/56255
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>
Tested-by: TYPO3com <no-reply@typo3.com>
  • Loading branch information
lsascha authored and lolli42 committed Mar 16, 2018
1 parent 0228fa5 commit 5734b7a
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions typo3/sysext/core/Tests/Unit/Imaging/IconFactoryTest.php
@@ -1,4 +1,5 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Core\Tests\Unit\Imaging;

/*
Expand All @@ -18,18 +19,17 @@
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider;
use TYPO3\CMS\Core\Imaging\IconRegistry;
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\Folder;
use TYPO3\CMS\Core\Resource\ResourceStorage;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

/**
* TestCase for \TYPO3\CMS\Core\Imaging\IconFactory
*/
class IconFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
class IconFactoryTest extends UnitTestCase
{
/**
* Subject is not notice free, disable E_NOTICES
*/
protected static $suppressNotices = true;

/**
* @var \TYPO3\CMS\Core\Imaging\IconFactory
*/
Expand Down Expand Up @@ -82,7 +82,7 @@ class IconFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
*/
protected function setUp()
{
$this->iconRegistryMock = $this->prophesize(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
$this->iconRegistryMock = $this->prophesize(IconRegistry::class);
$this->subject = new IconFactory($this->iconRegistryMock->reveal());

$this->iconRegistryMock->isRegistered('tcarecords--default')->willReturn(false);
Expand Down Expand Up @@ -453,6 +453,7 @@ public function getIconForResourceWithMountRootReturnsMountFolderIcon()
*/
public function getIconForRecordWithNullTableReturnsMissingIcon()
{
$GLOBALS['TCA']['']['ctrl'] = [];
$this->assertContains(
'<span class="t3js-icon icon icon-size-default icon-state-default icon-default-not-found" data-identifier="default-not-found">',
$this->subject->getIconForRecord('', [])->render()
Expand Down Expand Up @@ -492,6 +493,7 @@ public function getIconForRecordWithMockRecordReturnsNormalIcon()
'ctrl' => [
'typeicon_column' => 'CType',
'typeicon_classes' => [
'default' => '',
'text' => 'mimetypes-x-content-text',
],
],
Expand All @@ -513,6 +515,7 @@ public function getIconForRecordWithMockRecordOfTypePluginReturnsPluginIcon()
'ctrl' => [
'typeicon_column' => 'CType',
'typeicon_classes' => [
'default' => '',
'list' => 'mimetypes-x-content-plugin',
],
],
Expand All @@ -539,6 +542,7 @@ public function getIconForRecordWithMockRecordWithHiddenFlagReturnsNormalIconAnd
],
'typeicon_column' => 'CType',
'typeicon_classes' => [
'default' => '',
'text' => 'mimetypes-x-content-text',
],
],
Expand All @@ -560,9 +564,9 @@ public function getIconForRecordWithMockRecordWithHiddenFlagReturnsNormalIconAnd
*/
protected function getTestSubjectFileObject($extension, $mimeType = '')
{
$mockedStorage = $this->createMock(\TYPO3\CMS\Core\Resource\ResourceStorage::class);
$mockedFile = $this->getMockBuilder(\TYPO3\CMS\Core\Resource\File::class)
->setConstructorArgs([[], $mockedStorage])
$mockedStorage = $this->createMock(ResourceStorage::class);
$mockedFile = $this->getMockBuilder(File::class)
->setConstructorArgs([['identifier' => '', 'name' => ''], $mockedStorage])
->getMock();
$mockedFile->expects($this->atMost(1))->method('getExtension')->will($this->returnValue($extension));
$mockedFile->expects($this->atLeastOnce())->method('getMimeType')->will($this->returnValue($mimeType));
Expand All @@ -577,12 +581,12 @@ protected function getTestSubjectFileObject($extension, $mimeType = '')
*/
protected function getTestSubjectFolderObject($identifier)
{
$mockedStorage = $this->createMock(\TYPO3\CMS\Core\Resource\ResourceStorage::class);
$mockedStorage = $this->createMock(ResourceStorage::class);
$mockedStorage->expects($this->any())->method('getRootLevelFolder')->will($this->returnValue(
new \TYPO3\CMS\Core\Resource\Folder($mockedStorage, '/', '/')
new Folder($mockedStorage, '/', '/')
));
$mockedStorage->expects($this->any())->method('checkFolderActionPermission')->will($this->returnValue(true));
$mockedStorage->expects($this->any())->method('isBrowsable')->will($this->returnValue(true));
return new \TYPO3\CMS\Core\Resource\Folder($mockedStorage, $identifier, $identifier);
return new Folder($mockedStorage, $identifier, $identifier);
}
}

0 comments on commit 5734b7a

Please sign in to comment.