2 declare(strict_types = 1);
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
38 $html =
'test <a href="' . $this->getUniqueId() .
'">test</a> test';
40 $result = $subject->extractHyperLinks($html);
41 $this->assertEquals(1, count($result));
42 $this->assertEquals(
'', $result[0][
'localPath']);
51 $this->testFilesToDelete[] = $temporaryFileName;
52 $html =
'test <a href="testfile">test</a> test';
53 $GLOBALS[
'T3_VAR'][
'ext'][
'indexed_search'][
'indexLocalFiles'] = [
54 \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5(
'testfile') => $temporaryFileName,
57 $result = $subject->extractHyperLinks($html);
58 $this->assertEquals(1, count($result));
59 $this->assertEquals($temporaryFileName, $result[0][
'localPath']);
67 $baseURL = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv(
'TYPO3_SITE_URL');
68 $html =
'test <a href="' . $baseURL .
'index.php">test</a> test';
70 $result = $subject->extractHyperLinks($html);
71 $this->assertEquals(1, count($result));
80 $html =
'test <a href="index.php">test</a> test';
82 $result = $subject->extractHyperLinks($html);
83 $this->assertEquals(1, count($result));
92 $html =
'test <a href="typo3/index.php">test</a> test';
94 $result = $subject->extractHyperLinks($html);
95 $this->assertEquals(1, count($result));
104 $absRefPrefix =
'/' . $this->getUniqueId();
105 $html =
'test <a href="' . $absRefPrefix .
'index.php">test</a> test';
106 $GLOBALS[
'TSFE'] = $this->createMock(TypoScriptFrontendController::class);
109 'absRefPrefix' => $absRefPrefix,
114 $result = $subject->extractHyperLinks($html);
115 $this->assertEquals(1, count($result));
124 $baseHref =
'http://example.com/';
125 $html =
'<html><head><Base Href="' . $baseHref .
'" /></head></html>';
127 $result = $subject->extractBaseHref($html);
128 $this->assertEquals($baseHref, $result);
141 <meta http-equiv=
"Content-Type" content=
"text/html;charset=utf-8"/>
142 <title>Some Title</title>
143 <link href=
'css/normalize.css' rel=
'stylesheet' type=
'text/css'/>
147 <div
class=
"non_searchable">
148 not searchable content
150 <!--TYPO3SEARCH_begin-->
151 <div
class=
"searchable">
154 <!--TYPO3SEARCH_end-->
155 <div
class=
"non_searchable">
156 not searchable content
163 <div
class=
"searchable">
170 $result = $subject->typoSearchTags($body);
171 $this->assertTrue($result);
172 $this->assertEquals($expected, $body);
185 <meta http-equiv=
"Content-Type" content=
"text/html;charset=utf-8"/>
186 <title>Some Title</title>
187 <link href=
'css/normalize.css' rel=
'stylesheet' type=
'text/css'/>
191 <div
class=
"non_searchable">
192 not searchable content
194 <!--TYPO3SEARCH_begin-->
195 <div
class=
"searchable">
198 <!--TYPO3SEARCH_end-->
199 <div
class=
"non_searchable">
200 not searchable content
202 <!--TYPO3SEARCH_begin-->
203 <div
class=
"searchable">
206 <!--TYPO3SEARCH_end-->
207 <div
class=
"non_searchable">
208 not searchable content
215 <div
class=
"searchable">
219 <div
class=
"searchable">
226 $result = $subject->typoSearchTags($body);
227 $this->assertTrue($result);
228 $this->assertEquals($expected, $body);