mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Case-insensitive matching when using array of phrases in TextHelper::highlight
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4878 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
bb8c52dac0
commit
35c7807cc3
2 changed files with 12 additions and 1 deletions
|
@ -68,7 +68,7 @@ class TextHelper extends AppHelper {
|
|||
$key = $value;
|
||||
$value = $highlighter;
|
||||
|
||||
$replace[] = '|(' . $key . ')|';
|
||||
$replace[] = '|(' . $key . ')|i';
|
||||
$with[] = empty($value) ? $highlighter : $value;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,17 @@ class TextTest extends UnitTestCase {
|
|||
$expected = '<b>This</b> is a test <b>text</b>';
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
|
||||
function testHighlightCaseInsensitivity() {
|
||||
$text = 'This is a Test text';
|
||||
$expected = 'This is a <b>Test</b> text';
|
||||
|
||||
$result = $this->helper->highlight($text, 'test', '<b>\1</b>');
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = $this->helper->highlight($text, array('test'), '<b>\1</b>');
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
unset($this->helper);
|
||||
|
|
Loading…
Reference in a new issue