Skip to content

Commit

Permalink
[TASK] Make ResourceCompressorTest notice free
Browse files Browse the repository at this point in the history
Resolves: #84406
Releases: master
Change-Id: I7d7004e2e53d5277ca611f397cc3dbae1c5cb823
Reviewed-on: https://review.typo3.org/56285
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: Andreas Wolf <andreas.wolf@typo3.org>
Tested-by: Andreas Wolf <andreas.wolf@typo3.org>
  • Loading branch information
Łukasz Uznański authored and andreaswolf committed Mar 17, 2018
1 parent 3dce8e6 commit 5f8d2b3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
4 changes: 2 additions & 2 deletions typo3/sysext/core/Classes/Resource/ResourceCompressor.php
Expand Up @@ -130,7 +130,7 @@ public function concatenateCssFiles(array $cssFiles, array $options = [])
if (!isset($filesToIncludeByType[$type])) {
$filesToIncludeByType[$type] = [];
}
if ($fileOptions['forceOnTop']) {
if (!empty($fileOptions['forceOnTop'])) {
array_unshift($filesToIncludeByType[$type], $filenameFromMainDir);
} else {
$filesToIncludeByType[$type][] = $filenameFromMainDir;
Expand Down Expand Up @@ -179,7 +179,7 @@ public function concatenateJsFiles(array $jsFiles)
$filesToInclude[$fileOptions['section']] = [];
}
$filenameFromMainDir = $this->getFilenameFromMainDir($fileOptions['file']);
if ($fileOptions['forceOnTop']) {
if (!empty($fileOptions['forceOnTop'])) {
array_unshift($filesToInclude[$fileOptions['section']], $filenameFromMainDir);
} else {
$filesToInclude[$fileOptions['section']][] = $filenameFromMainDir;
Expand Down
34 changes: 15 additions & 19 deletions typo3/sysext/core/Tests/Unit/Resource/ResourceCompressorTest.php
@@ -1,4 +1,5 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Core\Tests\Unit\Resource;

/*
Expand All @@ -21,11 +22,6 @@
*/
class ResourceCompressorTest extends BaseTestCase
{
/**
* Subject is not notice free, disable E_NOTICES
*/
protected static $suppressNotices = true;

/**
* @var ResourceCompressor|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
*/
Expand All @@ -34,7 +30,7 @@ class ResourceCompressorTest extends BaseTestCase
/**
* Set up the test
*/
protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->subject = $this->getAccessibleMock(ResourceCompressor::class, ['compressCssFile', 'compressJsFile', 'createMergedCssFile', 'createMergedJsFile', 'getFilenameFromMainDir', 'checkBaseDirectory']);
Expand All @@ -43,7 +39,7 @@ protected function setUp()
/**
* @return array
*/
public function cssFixStatementsDataProvider()
public function cssFixStatementsDataProvider(): array
{
return [
'nothing to do - no charset/import/namespace' => [
Expand Down Expand Up @@ -87,7 +83,7 @@ public function cssFixStatementsDataProvider()
* @param string $input
* @param string $expected
*/
public function cssFixStatementsMovesStatementsToTopIfNeeded($input, $expected)
public function cssFixStatementsMovesStatementsToTopIfNeeded($input, $expected): void
{
$result = $this->subject->_call('cssFixStatements', $input);
$resultWithReadableLinefeed = str_replace(LF, 'LF', $result);
Expand All @@ -97,7 +93,7 @@ public function cssFixStatementsMovesStatementsToTopIfNeeded($input, $expected)
/**
* @test
*/
public function compressedCssFileIsFlaggedToNotCompressAgain()
public function compressedCssFileIsFlaggedToNotCompressAgain(): void
{
$fileName = 'fooFile.css';
$compressedFileName = $fileName . '.gzip';
Expand All @@ -122,7 +118,7 @@ public function compressedCssFileIsFlaggedToNotCompressAgain()
/**
* @test
*/
public function compressedJsFileIsFlaggedToNotCompressAgain()
public function compressedJsFileIsFlaggedToNotCompressAgain(): void
{
$fileName = 'fooFile.js';
$compressedFileName = $fileName . '.gzip';
Expand All @@ -147,7 +143,7 @@ public function compressedJsFileIsFlaggedToNotCompressAgain()
/**
* @test
*/
public function concatenatedCssFileIsFlaggedToNotConcatenateAgain()
public function concatenatedCssFileIsFlaggedToNotConcatenateAgain(): void
{
$fileName = 'fooFile.css';
$concatenatedFileName = 'merged_' . $fileName;
Expand All @@ -172,7 +168,7 @@ public function concatenatedCssFileIsFlaggedToNotConcatenateAgain()
/**
* @test
*/
public function concatenatedCssFilesAreSeparatedByMediaType()
public function concatenatedCssFilesAreSeparatedByMediaType(): void
{
$allFileName = 'allFile.css';
$screenFileName1 = 'screenFile.css';
Expand Down Expand Up @@ -215,7 +211,7 @@ public function concatenatedCssFilesAreSeparatedByMediaType()
/**
* @test
*/
public function concatenatedCssFilesObeyForceOnTopOption()
public function concatenatedCssFilesObeyForceOnTopOption(): void
{
$screen1FileName = 'screen1File.css';
$screen2FileName = 'screen2File.css';
Expand Down Expand Up @@ -250,7 +246,7 @@ public function concatenatedCssFilesObeyForceOnTopOption()
/**
* @test
*/
public function concatenatedCssFilesObeyExcludeFromConcatenation()
public function concatenatedCssFilesObeyExcludeFromConcatenation(): void
{
$screen1FileName = 'screen1File.css';
$screen2FileName = 'screen2File.css';
Expand Down Expand Up @@ -290,7 +286,7 @@ public function concatenatedCssFilesObeyExcludeFromConcatenation()
/**
* @test
*/
public function concatenatedJsFileIsFlaggedToNotConcatenateAgain()
public function concatenatedJsFileIsFlaggedToNotConcatenateAgain(): void
{
$fileName = 'fooFile.js';
$concatenatedFileName = 'merged_' . $fileName;
Expand All @@ -315,7 +311,7 @@ public function concatenatedJsFileIsFlaggedToNotConcatenateAgain()
/**
* @return array
*/
public function calcStatementsDataProvider()
public function calcStatementsDataProvider(): array
{
return [
'simple calc' => [
Expand Down Expand Up @@ -343,7 +339,7 @@ public function calcStatementsDataProvider()
* @param string $input
* @param string $expected
*/
public function calcFunctionMustRetainWhitespaces($input, $expected)
public function calcFunctionMustRetainWhitespaces($input, $expected): void
{
$result = $this->subject->_call('compressCssString', $input);
$this->assertSame($expected, trim($result));
Expand All @@ -352,7 +348,7 @@ public function calcFunctionMustRetainWhitespaces($input, $expected)
/**
* @return array
*/
public function compressCssFileContentDataProvider()
public function compressCssFileContentDataProvider(): array
{
$path = dirname(__FILE__) . '/ResourceCompressorTest/Fixtures/';
return [
Expand Down Expand Up @@ -392,7 +388,7 @@ public function compressCssFileContentDataProvider()
* @param string $cssFile
* @param string $expected
*/
public function compressCssFileContent($cssFile, $expected)
public function compressCssFileContent($cssFile, $expected): void
{
$cssContent = file_get_contents($cssFile);
$compressedCss = $this->subject->_call('compressCssString', $cssContent);
Expand Down

0 comments on commit 5f8d2b3

Please sign in to comment.