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:
dho 2007-04-21 16:55:09 +00:00
parent bb8c52dac0
commit 35c7807cc3
2 changed files with 12 additions and 1 deletions

View file

@ -68,7 +68,7 @@ class TextHelper extends AppHelper {
$key = $value;
$value = $highlighter;
$replace[] = '|(' . $key . ')|';
$replace[] = '|(' . $key . ')|i';
$with[] = empty($value) ? $highlighter : $value;
}

View file

@ -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);