/** * Test if highlighting works correct * * @test */ public function checkHighlightArrayOfWordsInContent() { if (TYPO3_VERSION_INTEGER >= 6002000) { $lib = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_kesearch_lib'); } else { $lib = t3lib_div::makeInstance('tx_kesearch_lib'); } $lib->conf['resultChars'] = 300; $lib->swords = array('Abgangszeugnis'); if (TYPO3_VERSION_INTEGER >= 6002000) { $lib->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_cObj'); } else { $lib->cObj = t3lib_div::makeInstance('tslib_cObj'); } $sr = new tx_kesearch_lib_searchresult($lib); // highlight one word $wordArray = array('Abgangszeugnis'); $result = $sr->highlightArrayOfWordsInContent($wordArray, $this->content); $this->assertContains('<span class="hit">', $result); // highlight one word // but in this case the word doesn't exists $wordArray = array('Abgangszaugnis'); $result = $sr->highlightArrayOfWordsInContent($wordArray, $this->content); $this->assertNotContains('<span class="hit">', $result); // highlight a word in a teaser $wordArray = array('Abgangszeugnis'); $result = $sr->highlightArrayOfWordsInContent($wordArray, $sr->buildTeaserContent($this->content)); $this->assertContains('<span class="hit">', $result); }