|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types = 1); |
|
3
|
|
|
namespace TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers; |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the TYPO3 CMS project. |
|
7
|
|
|
* |
|
8
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
9
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
10
|
|
|
* of the License, or any later version. |
|
11
|
|
|
* |
|
12
|
|
|
* For the full copyright and license information, please read the |
|
13
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
14
|
|
|
* |
|
15
|
|
|
* The TYPO3 project - inspiring people to share! |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
use Psr\Log\NullLogger; |
|
19
|
|
|
use TYPO3\CMS\Core\TypoScript\TemplateService; |
|
20
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
21
|
|
|
use TYPO3\CMS\Fluid\View\StandaloneView; |
|
22
|
|
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; |
|
23
|
|
|
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; |
|
24
|
|
|
use TYPO3\CMS\Frontend\Page\PageRepository; |
|
|
|
|
|
|
25
|
|
|
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
class RenderContentViewHelperTest extends FunctionalTestCase |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* @var array |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $testExtensionsToLoad = ['typo3conf/ext/qbtools']; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var array |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $coreExtensionsToLoad = ['fluid', 'fluid_styled_content']; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Note: we're not extending setUp because of the PHP 7.0 incompatible return type declaration |
|
42
|
|
|
*/ |
|
43
|
|
|
protected function setupTestEnvironment() |
|
44
|
|
|
{ |
|
45
|
|
|
$this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/pages.xml'); |
|
46
|
|
|
$this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/tt_content.xml'); |
|
47
|
|
|
$this->importDataSet(ORIGINAL_ROOT . 'typo3conf/ext/qbtools/Tests/Functional/ViewHelpers/Fixtures/sys_template.xml'); |
|
48
|
|
|
|
|
49
|
|
|
$this->initTypoScriptFrontendController(1); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function testRenderContentByUid() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->setupTestEnvironment(); |
|
55
|
|
|
|
|
56
|
|
|
$view = new StandaloneView(); |
|
57
|
|
|
$view->setTemplatePathAndFilename('typo3conf/ext/qbtools/Tests/Functional/ViewHelpers/Fixtures/rendercontent_uid_viewhelper.html'); |
|
58
|
|
|
$view->assign('id', 1); |
|
59
|
|
|
|
|
60
|
|
|
$expected = 'Test content'; |
|
61
|
|
|
$this->assertEquals($expected, trim(preg_replace('/\s+/', ' ', $view->render()))); |
|
62
|
|
|
|
|
63
|
|
|
$cacheTags = $GLOBALS['TSFE']->getPageCacheTags(); |
|
64
|
|
|
$this->assertContains('tt_content_1', $cacheTags); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function testRenderContentByPid() |
|
68
|
|
|
{ |
|
69
|
|
|
$this->setupTestEnvironment(); |
|
70
|
|
|
|
|
71
|
|
|
$view = new StandaloneView(); |
|
72
|
|
|
$view->setTemplatePathAndFilename('typo3conf/ext/qbtools/Tests/Functional/ViewHelpers/Fixtures/rendercontent_pid_viewhelper.html'); |
|
73
|
|
|
$view->assign('id', 1); |
|
74
|
|
|
|
|
75
|
|
|
$expected = 'Test content'; |
|
76
|
|
|
$this->assertEquals($expected, trim(preg_replace('/\s+/', ' ', $view->render()))); |
|
77
|
|
|
|
|
78
|
|
|
$cacheTags = $GLOBALS['TSFE']->getPageCacheTags(); |
|
79
|
|
|
|
|
80
|
|
|
$this->assertContains('pages_1', $cacheTags); |
|
81
|
|
|
$this->assertContains('tt_content_pid_1', $cacheTags); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
private function initTypoScriptFrontendController(int $uid): TypoScriptFrontendController |
|
85
|
|
|
{ |
|
86
|
|
|
$typoScriptFrontendController = GeneralUtility::makeInstance(TypoScriptFrontendController::class, null, $uid, 0); |
|
87
|
|
|
$typoScriptFrontendController->cObj = new ContentObjectRenderer(); |
|
88
|
|
|
// Remove condition once we drop support for TYPO3 v8, and always inject the logger |
|
89
|
|
|
if (method_exists($typoScriptFrontendController->cObj, 'setLogger')) { |
|
90
|
|
|
$typoScriptFrontendController->cObj->setLogger(new NullLogger()); |
|
91
|
|
|
} |
|
92
|
|
|
$typoScriptFrontendController->sys_page = GeneralUtility::makeInstance(PageRepository::class); |
|
93
|
|
|
$typoScriptFrontendController->tmpl = GeneralUtility::makeInstance(TemplateService::class); |
|
94
|
|
|
// Remove guarded method call to init, once we drop support for TYPO3 v8 |
|
95
|
|
|
if (method_exists($typoScriptFrontendController->tmpl, 'init')) { |
|
96
|
|
|
$typoScriptFrontendController->tmpl->init(); |
|
97
|
|
|
} |
|
98
|
|
|
$typoScriptFrontendController->getPageAndRootlineWithDomain(1); |
|
99
|
|
|
$typoScriptFrontendController->getConfigArray(); |
|
100
|
|
|
$GLOBALS['TSFE'] = $typoScriptFrontendController; |
|
101
|
|
|
return $typoScriptFrontendController; |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths