2 declare(strict_types = 1);
21 use TYPO3\CMS\Core\Package\PackageManager;
47 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
82 'TEXT' => TextContentObject::class,
83 'CASE' => CaseContentObject::class,
84 'COBJ_ARRAY' => ContentObjectArrayContentObject::class,
85 'COA' => ContentObjectArrayContentObject::class,
86 'COA_INT' => ContentObjectArrayInternalContentObject::class,
87 'USER' => UserContentObject::class,
88 'USER_INT' => UserInternalContentObject::class,
89 'FILE' => FileContentObject::class,
90 'FILES' => FilesContentObject::class,
91 'IMAGE' => ImageContentObject::class,
92 'IMG_RESOURCE' => ImageResourceContentObject::class,
93 'CONTENT' => ContentContentObject::class,
94 'RECORDS' => RecordsContentObject::class,
95 'HMENU' => HierarchicalMenuContentObject::class,
96 'CASEFUNC' => CaseContentObject::class,
97 'LOAD_REGISTER' => LoadRegisterContentObject::class,
98 'RESTORE_REGISTER' => RestoreRegisterContentObject::class,
99 'TEMPLATE' => TemplateContentObject::class,
100 'FLUIDTEMPLATE' => FluidTemplateContentObject::class,
101 'SVG' => ScalableVectorGraphicsContentObject::class,
102 'EDITPANEL' => EditPanelContentObject::class
108 protected function setUp(): void
110 $GLOBALS[
'SIM_ACCESS_TIME'] = 1534278180;
111 $packageManagerMock = $this->getMockBuilder(PackageManager::class)
112 ->disableOriginalConstructor()
114 $this->templateServiceMock =
115 $this->getMockBuilder(TemplateService::class)
116 ->setConstructorArgs([
null, $packageManagerMock])
117 ->setMethods([
'linkData'])
119 $pageRepositoryMock =
120 $this->getAccessibleMock(PageRepository::class, [
'getRawRecord',
'getMountPointInfo']);
121 $this->frontendControllerMock =
122 $this->getAccessibleMock(
123 TypoScriptFrontendController::class,
129 $this->frontendControllerMock->_set(
'context', GeneralUtility::makeInstance(Context::class));
131 $this->frontendControllerMock->config = [];
132 $this->frontendControllerMock->page = [];
133 $this->frontendControllerMock->sys_page = $pageRepositoryMock;
136 $this->subject = $this->getAccessibleMock(
137 ContentObjectRenderer::class,
138 [
'getResourceFactory',
'getEnvironmentVariable'],
139 [$this->frontendControllerMock]
142 $logger = $this->prophesize(Logger::class);
143 $this->subject->setLogger($logger->reveal());
144 $this->subject->setContentObjectClassMap($this->contentObjectMap);
145 $this->subject->start([],
'tt_content');
158 file_put_contents($fileNameAndPath,
'Some test data');
162 $expectedLink = str_replace(
'%2F',
'/', rawurlencode($relativeFileNameAndPath));
163 $result = $this->subject->filelink($fileName, [
'path' =>
'typo3temp/var/tests/'],
true);
164 $this->assertEquals(
'<a href="' . $expectedLink .
'">' . $fileName .
'</a>', $result);
166 GeneralUtility::unlink_tempfile($fileNameAndPath);
183 $content = $this->getUniqueId(
'content');
185 'addParams' => $this->getUniqueId(
'not used'),
186 'addParams.' => [$this->getUniqueId(
'addParams.')],
188 $return = $this->getUniqueId(
'return');
189 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
190 ->setMethods([
'addParams'])->getMock();
192 ->expects($this->once())
193 ->method(
'addParams')
194 ->with($content, $conf[
'addParams.'])
195 ->willReturn($return);
216 $content = $this->getUniqueId(
'content');
218 'filelink' => $this->getUniqueId(
'not used'),
219 'filelink.' => [$this->getUniqueId(
'filelink.')],
221 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
222 ->setMethods([
'filelink'])->getMock();
223 $subject->expects($this->once())->method(
'filelink')
224 ->with($content, $conf[
'filelink.'])->willReturn(
'return');
245 'filelist' => $this->getUniqueId(
'filelist'),
246 'filelist.' => [$this->getUniqueId(
'not used')],
248 $subject = $this->getMockBuilder(ContentObjectRenderer::class)
249 ->setMethods([
'filelist'])->getMock();
250 $subject->expects($this->once())->method(
'filelist')
251 ->with($conf[
'filelist'])->willReturn(
'return');
264 'Text without tag is wrapped with <p> tag' => [
267 '<p class="bodytext">Text without tag</p>',
269 'Text wrapped with <p> tag remains the same' => [
270 '<p class="myclass">Text with <p> tag</p>',
272 '<p class="myclass">Text with <p> tag</p>',
274 'Text with absolute external link' => [
275 'Text with <link http://example.com/foo/>external link</link>',
277 '<p class="bodytext">Text with <a href="http://example.com/foo/">external link</a></p>',
279 'Empty lines are not duplicated' => [
282 '<p class="bodytext"> </p>',
284 'Multiple empty lines with no text' => [
287 '<p class="bodytext"> </p>' . LF .
'<p class="bodytext"> </p>' . LF .
'<p class="bodytext"> </p>',
289 'Empty lines are not duplicated at the end of content' => [
292 '<p class="bodytext">test</p>' . LF .
'<p class="bodytext"> </p>',
294 'Empty lines are not trimmed' => [
297 '<p class="bodytext"> </p>' . LF .
'<p class="bodytext">test</p>' . LF .
'<p class="bodytext"> </p>',
311 $this->assertEquals($expectedResult, $this->subject->stdWrap_parseFunc($value, $configuration));