mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 10:36:16 +00:00
Fixed a String::tokenize bug for a single enclosed item, closes #4627
Added basic test coverage for String::tokenize git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6827 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
fca356c040
commit
6f64efb342
2 changed files with 19 additions and 2 deletions
|
@ -157,8 +157,7 @@ class String extends Object {
|
|||
}
|
||||
if ($data{$tmpOffset} == $leftBound) {
|
||||
$depth++;
|
||||
}
|
||||
if ($data{$tmpOffset} == $rightBound) {
|
||||
} elseif ($data{$tmpOffset} == $rightBound) {
|
||||
$depth--;
|
||||
}
|
||||
$offset = ++$tmpOffset;
|
||||
|
|
|
@ -116,5 +116,23 @@ class StringTest extends UnitTestCase {
|
|||
$result = String::insert($string, array('b' => 2, 'c' => 3), array('clean' => true));
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
function testTokenize() {
|
||||
$result = String::tokenize('A,(short,boring test)');
|
||||
$expected = array('A', '(short,boring test)');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = String::tokenize('A,(short,more interesting( test)');
|
||||
$expected = array('A', '(short,more interesting( test)');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = String::tokenize('A,(short,very interesting( test))');
|
||||
$expected = array('A', '(short,very interesting( test))');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = String::tokenize('"single tag"', ' ', '"', '"');
|
||||
$expected = array('"single tag"');
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue