2 namespace TYPO3\CMS\IndexedSearch\Tests\Unit;
34 $this->subject = $this->getMock(\TYPO3\CMS\IndexedSearch\Indexer::class, array(
'dummy'));
42 $html =
'test <a href="' . $this->getUniqueId() .
'">test</a> test';
43 $result = $this->subject->extractHyperLinks($html);
44 $this->assertEquals(1, count($result));
45 $this->assertEquals(
'', $result[0][
'localPath']);
53 $temporaryFileName = tempnam(PATH_site .
'typo3temp/',
't3unit-');
54 $this->testFilesToDelete[] = $temporaryFileName;
55 $html =
'test <a href="testfile">test</a> test';
56 $GLOBALS[
'T3_VAR'][
'ext'][
'indexed_search'][
'indexLocalFiles'] = array(
59 $result = $this->subject->extractHyperLinks($html);
60 $this->assertEquals(1, count($result));
61 $this->assertEquals($temporaryFileName, $result[0][
'localPath']);
69 $baseURL = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv(
'TYPO3_SITE_URL');
70 $html =
'test <a href="' . $baseURL .
'index.php">test</a> test';
71 $result = $this->subject->extractHyperLinks($html);
72 $this->assertEquals(1, count($result));
73 $this->assertEquals(PATH_site .
'index.php', $result[0][
'localPath']);
81 $html =
'test <a href="index.php">test</a> test';
82 $result = $this->subject->extractHyperLinks($html);
83 $this->assertEquals(1, count($result));
84 $this->assertEquals(PATH_site .
'index.php', $result[0][
'localPath']);
92 $path = substr(PATH_typo3, strlen(PATH_site) - 1);
93 $html =
'test <a href="' . $path .
'index.php">test</a> test';
94 $result = $this->subject->extractHyperLinks($html);
95 $this->assertEquals(1, count($result));
96 $this->assertEquals(PATH_typo3 .
'index.php', $result[0][
'localPath']);
104 $absRefPrefix =
'/' . $this->getUniqueId();
105 $html =
'test <a href="' . $absRefPrefix .
'index.php">test</a> test';
106 $GLOBALS[
'TSFE'] = $this->getMock(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class, array(), array(),
'',
false);
107 $GLOBALS[
'TSFE']->config[
'config'][
'absRefPrefix'] = $absRefPrefix;
108 $result = $this->subject->extractHyperLinks($html);
109 $this->assertEquals(1, count($result));
110 $this->assertEquals(PATH_site .
'index.php', $result[0][
'localPath']);
118 $baseHref =
'http://example.com/';
119 $html =
'<html><head><Base Href="' . $baseHref .
'" /></head></html>';
120 $result = $this->subject->extractBaseHref($html);
121 $this->assertEquals($baseHref, $result);