Skip to content
Snippets Groups Projects
Commit 62c07455 authored by Tymoteusz Motylewski's avatar Tymoteusz Motylewski Committed by Andreas Fernandez
Browse files

[TASK] Add unit tests for TYPO3SEARCH markers

Add two unit tests for Indexer, covering content extraction
from between TYPO3SEARCH_begin and TYPO3SEARCH_end markers.

Add note to documentation that it's possible to have multiple
TYPO3SEARCH marker pairs.

Resolves: #74815
Releases: master, 7.6, 6.2
Change-Id: I37c67dfc055dc30698831eef6d0231d929fef957
Reviewed-on: https://review.typo3.org/47175


Reviewed-by: default avatarDaniel Goerz <ervaude@gmail.com>
Tested-by: default avatarDaniel Goerz <ervaude@gmail.com>
Reviewed-by: default avatarAndreas Fernandez <typo3@scripting-base.de>
Tested-by: default avatarAndreas Fernandez <typo3@scripting-base.de>
parent e9f2bfae
Branches
Tags
No related merge requests found
......@@ -40,3 +40,5 @@ Rules:
until that point is excluded and preceding content until next "end"
marker is included.
#. If there are multiple marker pairs in HTML, content from in between
all pairs is included.
\ No newline at end of file
......@@ -120,4 +120,102 @@ class IndexerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
$result = $this->subject->extractBaseHref($html);
$this->assertEquals($baseHref, $result);
}
/**
* Tests whether indexer can extract content between "TYPO3SEARCH_begin" and "TYPO3SEARCH_end" markers
*
* @test
*/
public function typoSearchTagsRemovesBodyContentOutsideMarkers()
{
$body = <<<EOT
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Some Title</title>
<link href='css/normalize.css' rel='stylesheet' type='text/css'/>
</head>
<body>
<div>
<div class="non_searchable">
not searchable content
</div>
<!--TYPO3SEARCH_begin-->
<div class="searchable">
lorem ipsum
</div>
<!--TYPO3SEARCH_end-->
<div class="non_searchable">
not searchable content
</div>
</body>
</html>
EOT;
$expected = <<<EOT
<div class="searchable">
lorem ipsum
</div>
EOT;
$result = $this->subject->typoSearchTags($body);
$this->assertTrue($result);
$this->assertEquals($expected, $body);
}
/**
* Tests whether indexer can extract content between multiple pairs of "TYPO3SEARCH" markers
*
* @test
*/
public function typoSearchTagsHandlesMultipleMarkerPairs()
{
$body = <<<EOT
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Some Title</title>
<link href='css/normalize.css' rel='stylesheet' type='text/css'/>
</head>
<body>
<div>
<div class="non_searchable">
not searchable content
</div>
<!--TYPO3SEARCH_begin-->
<div class="searchable">
lorem ipsum
</div>
<!--TYPO3SEARCH_end-->
<div class="non_searchable">
not searchable content
</div>
<!--TYPO3SEARCH_begin-->
<div class="searchable">
lorem ipsum2
</div>
<!--TYPO3SEARCH_end-->
<div class="non_searchable">
not searchable content
</div>
</body>
</html>
EOT;
$expected = <<<EOT
<div class="searchable">
lorem ipsum
</div>
<div class="searchable">
lorem ipsum2
</div>
EOT;
$result = $this->subject->typoSearchTags($body);
$this->assertTrue($result);
$this->assertEquals($expected, $body);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment