Skip to content

Commit

Permalink
[TASK] typo3/testing-framework now flushes runtime caches
Browse files Browse the repository at this point in the history
Unit test tearDown() now always calls
GeneralUtility::flushInternalRuntimeCaches() so most explicit
calls in unit tests can be removed.

composer require --dev typo3/testing-framework:~4.8.2

Resolves: #85948
Related: #85946
Releases: master, 8.7
Change-Id: I798047a06c3265404383540cacbd40d9719e7bfe
Reviewed-on: https://review.typo3.org/58008
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
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>
  • Loading branch information
stucki authored and lolli42 committed Sep 1, 2018
1 parent e0c5ac1 commit db52b04
Show file tree
Hide file tree
Showing 17 changed files with 8 additions and 42 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -69,7 +69,7 @@
"fiunchinho/phpunit-randomizer": "^4.0",
"friendsofphp/php-cs-fixer": "^2.12.2",
"typo3/cms-styleguide": "~9.2.0",
"typo3/testing-framework": "~4.8.1"
"typo3/testing-framework": "~4.8.2"
},
"suggest": {
"ext-gd": "GDlib/Freetype is required for building images with text (GIFBUILDER) and can also be used to scale images",
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -60,7 +60,6 @@ protected function setUp()
$this->testGlobalNamespace = $this->getUniqueId('TEST');
$GLOBALS['TCA'][$this->testTableName] = ['ctrl' => []];
$GLOBALS[$this->testGlobalNamespace] = [];
GeneralUtility::flushInternalRuntimeCaches();
$this->setUpBackend();
$this->matchCondition = $this->getAccessibleMock(ConditionMatcher::class, ['determineRootline'], [], '', false);
$this->matchCondition->method('determineRootline')->willReturn([
Expand Down
Expand Up @@ -74,7 +74,6 @@ public function getAuthInfoArrayReturnsEmptyPidListIfNoCheckPidValueIsGiven()
*/
public function getHttpHeadersReturnsNormalNoCacheHeadersForNonIe()
{
GeneralUtility::flushInternalRuntimeCaches();
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 6.2; rv:22.0) Gecko/20130405 Firefox/23.0';
$_SERVER['HTTPS'] = 'on';
$subject = $this->getAccessibleMockForAbstractClass(AbstractUserAuthentication::class);
Expand All @@ -87,7 +86,6 @@ public function getHttpHeadersReturnsNormalNoCacheHeadersForNonIe()
*/
public function getHttpHeadersReturnsSpecialNoCacheHeadersForIe()
{
GeneralUtility::flushInternalRuntimeCaches();
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US)';
$_SERVER['HTTPS'] = 'on';
$subject = $this->getAccessibleMockForAbstractClass(AbstractUserAuthentication::class);
Expand Down
Expand Up @@ -59,7 +59,6 @@ protected function setUp(): void

$this->resetSingletonInstances = true;
$GLOBALS['TYPO3_REQUEST'] = new ServerRequest();
GeneralUtility::flushInternalRuntimeCaches();

$typoScriptConditionProvider = GeneralUtility::makeInstance(TypoScriptConditionProvider::class);

Expand Down
Expand Up @@ -17,22 +17,13 @@

use TYPO3\CMS\Core\Http\ServerRequestFactory;
use TYPO3\CMS\Core\Http\UploadedFile;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

/**
* Testcase for \TYPO3\CMS\Core\Http\ServerRequestFactory
*/
class ServerRequestFactoryTest extends UnitTestCase
{
/**
* Set up
*/
protected function setUp()
{
GeneralUtility::flushInternalRuntimeCaches();
}

/**
* @test
*/
Expand Down
Expand Up @@ -19,7 +19,6 @@
use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\YouTubeHelper;
use TYPO3\CMS\Core\Resource\Rendering\YouTubeRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

/**
Expand All @@ -38,7 +37,6 @@ class YouTubeRendererTest extends UnitTestCase
protected function setUp()
{
parent::setUp();
GeneralUtility::flushInternalRuntimeCaches();
$_SERVER['HTTP_HOST'] = 'test.server.org';

/** @var YouTubeHelper|\PHPUnit_Framework_MockObject_MockObject $youTubeHelper */
Expand Down
5 changes: 0 additions & 5 deletions typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
Expand Up @@ -62,7 +62,6 @@ class GeneralUtilityTest extends UnitTestCase
*/
protected function setUp()
{
GeneralUtilityFixture::flushInternalRuntimeCaches();
GeneralUtilityFixture::$isAllowedHostHeaderValueCallCount = 0;
GeneralUtilityFixture::setAllowHostHeaderValue(false);
$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = GeneralUtility::ENV_TRUSTED_HOSTS_PATTERN_ALLOW_ALL;
Expand Down Expand Up @@ -1537,7 +1536,6 @@ public static function hostnameAndPortDataProvider()
*/
public function getIndpEnvTypo3HostOnlyParsesHostnamesAndIpAdresses($httpHost, $expectedIp)
{
GeneralUtility::flushInternalRuntimeCaches();
$_SERVER['HTTP_HOST'] = $httpHost;
$this->assertEquals($expectedIp, GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'));
}
Expand Down Expand Up @@ -1729,7 +1727,6 @@ public function getIndpEnvForHostThrowsExceptionForNotAllowedHostnameValues($htt
{
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1396795884);

$_SERVER['HTTP_HOST'] = $httpHost;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = $hostNamePattern;
GeneralUtilityFixture::getIndpEnv('HTTP_HOST');
Expand Down Expand Up @@ -2027,7 +2024,6 @@ public function sanitizeLocalUrlAcceptsNotEncodedValidUrls($url, $host, $subDire
{
$_SERVER['HTTP_HOST'] = $host;
$_SERVER['SCRIPT_NAME'] = $subDirectory . 'typo3/index.php';
GeneralUtility::flushInternalRuntimeCaches();
$this->assertEquals($url, GeneralUtility::sanitizeLocalUrl($url));
}

Expand All @@ -2042,7 +2038,6 @@ public function sanitizeLocalUrlAcceptsEncodedValidUrls($url, $host, $subDirecto
{
$_SERVER['HTTP_HOST'] = $host;
$_SERVER['SCRIPT_NAME'] = $subDirectory . 'typo3/index.php';
GeneralUtility::flushInternalRuntimeCaches();
$this->assertEquals(rawurlencode($url), GeneralUtility::sanitizeLocalUrl(rawurlencode($url)));
}

Expand Down
2 changes: 1 addition & 1 deletion typo3/sysext/core/composer.json
Expand Up @@ -51,7 +51,7 @@
"fiunchinho/phpunit-randomizer": "^4.0",
"friendsofphp/php-cs-fixer": "^2.12.2",
"typo3/cms-styleguide": "~9.2.0",
"typo3/testing-framework": "~4.8.1"
"typo3/testing-framework": "~4.8.2"
},
"suggest": {
"ext-fileinfo": "Used for proper file type detection in the file abstraction layer",
Expand Down
Expand Up @@ -393,7 +393,6 @@ public function buildBackendUriRespectsSection()
*/
public function buildBackendUriCreatesAbsoluteUrisIfSpecified()
{
GeneralUtility::flushInternalRuntimeCaches();
GeneralUtility::_GETset(['route' => '/test/Path']);
$_SERVER['HTTP_HOST'] = 'baseuri';
$_SERVER['SCRIPT_NAME'] = '/typo3/index.php';
Expand Down
Expand Up @@ -18,7 +18,6 @@
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Core\Resource\ProcessedFile;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Service\EnvironmentService;
use TYPO3\CMS\Extbase\Service\ImageService;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
Expand Down Expand Up @@ -50,7 +49,6 @@ protected function setUp(): void
{
$this->environmentService = $this->createMock(EnvironmentService::class);
$this->subject = new ImageService($this->environmentService);
GeneralUtility::flushInternalRuntimeCaches();
$_SERVER['HTTP_HOST'] = 'foo.bar';
}

Expand Down
Expand Up @@ -85,7 +85,6 @@ protected function tearDown()
*/
protected function setUpFakeSitePathAndHost()
{
GeneralUtility::flushInternalRuntimeCaches();
$_SERVER['ORIG_PATH_INFO'] = $_SERVER['PATH_INFO'] = $_SERVER['ORIG_SCRIPT_NAME'] = $_SERVER['SCRIPT_NAME'] = $this->testSitePath . TYPO3_mainDir;
$_SERVER['HTTP_HOST'] = $this->testHostName;
}
Expand Down
Expand Up @@ -18,7 +18,6 @@
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\ServerRequestFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Compatibility\LegacyDomainResolver;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

Expand All @@ -37,7 +36,6 @@ protected function setUp()
{
parent::setUp();
$this->subject = $this->getAccessibleMock(LegacyDomainResolver::class, ['dummy'], [], '', false);
GeneralUtility::flushInternalRuntimeCaches();
}

/**
Expand Down
Expand Up @@ -49,7 +49,6 @@ protected function setUp(): void
$GLOBALS['TYPO3_REQUEST'] = new ServerRequest();

$this->testGlobalNamespace = $this->getUniqueId('TEST');
GeneralUtility::flushInternalRuntimeCaches();
$GLOBALS[$this->testGlobalNamespace] = [];
$GLOBALS['TSFE'] = new \stdClass();
$GLOBALS['TSFE']->page = [];
Expand Down
Expand Up @@ -18,7 +18,6 @@
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Http\ServerRequestFactory;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\CMS\Frontend\Page\PageRepository;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
Expand All @@ -40,7 +39,6 @@ class TypoScriptFrontendControllerTest extends UnitTestCase

protected function setUp()
{
GeneralUtility::flushInternalRuntimeCaches();
$this->subject = $this->getAccessibleMock(TypoScriptFrontendController::class, ['dummy'], [], '', false);
$this->subject->_set('context', new Context());
$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '170928423746123078941623042360abceb12341234231';
Expand Down Expand Up @@ -240,7 +238,6 @@ public function initializeSearchWordDataBuildsCorrectRegex(array $searchWordGetP
$this->subject->config = ['config' => ['sword_standAlone' => 1]];
}

GeneralUtility::flushInternalRuntimeCaches();
$request = ServerRequestFactory::fromGlobals();
$this->subject->preparePageContentGeneration($request);
$this->assertEquals($this->subject->sWordRegEx, $expectedRegex);
Expand Down
Expand Up @@ -43,8 +43,6 @@ class AbstractTypolinkBuilderTest extends UnitTestCase
*/
protected function setUp()
{
GeneralUtility::flushInternalRuntimeCaches();

$this->createMockedLoggerAndLogManager();

$this->frontendControllerMock = $this->getAccessibleMock(
Expand Down
Expand Up @@ -15,7 +15,6 @@
* The TYPO3 project - inspiring people to share!
*/

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

Expand All @@ -32,7 +31,6 @@ class TypoScriptFrontendControllerTest extends UnitTestCase
protected function setUp()
{
parent::setUp();
GeneralUtility::flushInternalRuntimeCaches();
$this->subject = $this->getAccessibleMock(TypoScriptFrontendController::class, ['dummy'], [], '', false);
}

Expand Down

0 comments on commit db52b04

Please sign in to comment.