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\Extbase\Service\EnvironmentService; |
22
|
|
|
use TYPO3\CMS\Fluid\View\StandaloneView; |
23
|
|
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; |
24
|
|
|
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; |
25
|
|
|
use TYPO3\CMS\Frontend\Page\PageRepository; |
|
|
|
|
26
|
|
|
|
27
|
|
|
//use TYPO3\CMS\Fluid\View\StandaloneView; |
28
|
|
|
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; |
29
|
|
|
|
30
|
|
|
class RenderExternalViewHelperTest extends FunctionalTestCase |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* @var array |
34
|
|
|
*/ |
35
|
|
|
protected $testExtensionsToLoad = [ |
36
|
|
|
'typo3conf/ext/qbtools', |
37
|
|
|
'typo3conf/ext/qbtools/Tests/Functional/Fixtures/Extensions/test_extension', |
38
|
|
|
]; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var array |
42
|
|
|
*/ |
43
|
|
|
protected $coreExtensionsToLoad = ['fluid']; |
44
|
|
|
|
45
|
|
|
public function testRenderExternal() |
46
|
|
|
{ |
47
|
|
|
$view = new StandaloneView(); |
48
|
|
|
$view->setTemplatePathAndFilename('typo3conf/ext/qbtools/Tests/Functional/ViewHelpers/Fixtures/renderexternal_viewhelper.html'); |
49
|
|
|
|
50
|
|
|
$expected = 'bar:'; |
51
|
|
|
$this->assertEquals($expected, trim(preg_replace('/\s+/', ' ', $view->render()))); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function testRenderExternalWithSettings() |
55
|
|
|
{ |
56
|
|
|
$view = new StandaloneView(); |
57
|
|
|
$view->setTemplatePathAndFilename('typo3conf/ext/qbtools/Tests/Functional/ViewHelpers/Fixtures/renderexternal_viewhelper.html'); |
58
|
|
|
$view->assign('settings', ['foo' => 'baz']); |
59
|
|
|
|
60
|
|
|
$expected = 'bar: baz'; |
61
|
|
|
$this->assertEquals($expected, trim(preg_replace('/\s+/', ' ', $view->render()))); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function testRenderExternalWithPluginName() |
65
|
|
|
{ |
66
|
|
|
$this->initFrontendRendering(1); |
67
|
|
|
|
68
|
|
|
$view = new StandaloneView(); |
69
|
|
|
$view->setTemplatePathAndFilename('typo3conf/ext/qbtools/Tests/Functional/ViewHelpers/Fixtures/renderexternal_with_pluginname_viewhelper.html'); |
70
|
|
|
$view->assign('partial', 'Foo/TestPartial'); |
71
|
|
|
|
72
|
|
|
$expected = 'bar: foo'; |
73
|
|
|
$this->assertEquals($expected, trim(preg_replace('/\s+/', ' ', $view->render()))); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function testRenderExternalWithPluginNameAndToBeOverwrittenSettings() |
77
|
|
|
{ |
78
|
|
|
$this->initFrontendRendering(1); |
79
|
|
|
|
80
|
|
|
$view = new StandaloneView(); |
81
|
|
|
$view->setTemplatePathAndFilename('typo3conf/ext/qbtools/Tests/Functional/ViewHelpers/Fixtures/renderexternal_with_pluginname_viewhelper.html'); |
82
|
|
|
// These settings must not be passed to the external partial when pluginName is used |
83
|
|
|
$view->assign('settings', ['foo' => 'baz']); |
84
|
|
|
$view->assign('partial', 'Foo/TestPartial'); |
85
|
|
|
|
86
|
|
|
$expected = 'bar: foo'; |
87
|
|
|
$this->assertEquals($expected, trim(preg_replace('/\s+/', ' ', $view->render()))); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function testRenderExternalWithPluginNameAndLinkRendering() |
91
|
|
|
{ |
92
|
|
|
$this->initFrontendRendering(1); |
93
|
|
|
|
94
|
|
|
$view = new StandaloneView(); |
95
|
|
|
$view->setTemplatePathAndFilename('typo3conf/ext/qbtools/Tests/Functional/ViewHelpers/Fixtures/renderexternal_with_pluginname_viewhelper.html'); |
96
|
|
|
// These settings must not be passed to the external partial when pluginName is used |
97
|
|
|
$view->assign('settings', ['foo' => 'baz']); |
98
|
|
|
$view->assign('partial', 'Foo/TestPartialWithLink'); |
99
|
|
|
|
100
|
|
|
$expected = 'bar: index.php?id=1&tx_testextension_pi1%5Baction%5D=action&tx_testextension_pi1%5Bcontroller%5D=Dummy&'; |
101
|
|
|
$this->assertEquals($expected, trim(preg_replace('/cHash=.+/', '', preg_replace('/\s+/', ' ', $view->render())))); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
private function initFrontendRendering(int $uid): TypoScriptFrontendController |
105
|
|
|
{ |
106
|
|
|
$this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/pages.xml'); |
107
|
|
|
$this->importDataSet(ORIGINAL_ROOT . 'typo3conf/ext/qbtools/Tests/Functional/ViewHelpers/Fixtures/sys_template.xml'); |
108
|
|
|
|
109
|
|
|
// Ensure that the Extbase UriBuilder generated links in frontend mode |
110
|
|
|
$environmentServiceProphecy = $this->prophesize(EnvironmentService::class); |
111
|
|
|
$environmentServiceProphecy->isEnvironmentInFrontendMode()->willReturn(true); |
112
|
|
|
$environmentServiceProphecy->isEnvironmentInBackendMode()->willReturn(false); |
113
|
|
|
$environmentServiceProphecy->isEnvironmentInCliMode()->willReturn(false); |
114
|
|
|
$environmentServiceProphecy->getServerRequestMethod()->willReturn('GET'); |
115
|
|
|
GeneralUtility::setSingletonInstance(EnvironmentService::class, $environmentServiceProphecy->reveal()); |
116
|
|
|
|
117
|
|
|
$typoScriptFrontendController = GeneralUtility::makeInstance(TypoScriptFrontendController::class, null, $uid, 0); |
118
|
|
|
$typoScriptFrontendController->cObj = new ContentObjectRenderer(); |
119
|
|
|
// Remove condition once we drop support for TYPO3 v8, and always inject the logger |
120
|
|
|
if (method_exists($typoScriptFrontendController->cObj, 'setLogger')) { |
121
|
|
|
$typoScriptFrontendController->cObj->setLogger(new NullLogger()); |
122
|
|
|
} |
123
|
|
|
$typoScriptFrontendController->sys_page = GeneralUtility::makeInstance(PageRepository::class); |
124
|
|
|
$typoScriptFrontendController->tmpl = GeneralUtility::makeInstance(TemplateService::class); |
125
|
|
|
// Remove guarded method call to init, once we drop support for TYPO3 v8 |
126
|
|
|
if (method_exists($typoScriptFrontendController->tmpl, 'init')) { |
127
|
|
|
$typoScriptFrontendController->tmpl->init(); |
128
|
|
|
} |
129
|
|
|
$typoScriptFrontendController->getPageAndRootlineWithDomain(1); |
130
|
|
|
$typoScriptFrontendController->getConfigArray(); |
131
|
|
|
|
132
|
|
|
$GLOBALS['TSFE'] = $typoScriptFrontendController; |
133
|
|
|
return $typoScriptFrontendController; |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
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