Applying patch from 'phally' to update Set::extract to properly tokenize xpath selectors which contain hyphens (-). Fixes #6140

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8059 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
jperras 2009-02-25 16:23:13 +00:00
parent 5ded592c1e
commit f20ccc745c
2 changed files with 39 additions and 1 deletions

View file

@ -388,7 +388,7 @@ class Set extends Object {
if (!isset($contexts[0])) {
$contexts = array($data);
}
$tokens = array_slice(preg_split('/(?<!=)\/(?![a-z]*\])/', $path), 1);
$tokens = array_slice(preg_split('/(?<!=)\/(?![a-z-]*\])/', $path), 1);
do {
$token = array_shift($tokens);

View file

@ -919,6 +919,44 @@ class SetTest extends CakeTestCase {
$expected = array(7,2,1);
$r = Set::extract('/CallType[name=Internal Voice]/../x/hour', $multiple);
$this->assertEqual($r, $expected);
$f = array(
array(
'file' => array(
'name' => 'zipfile.zip',
'type' => 'application/zip',
'tmp_name' => '/tmp/php178.tmp',
'error' => 0,
'size' => '564647'
)
),
array(
'file' => array(
'name' => 'zipfile2.zip',
'type' => 'application/x-zip-compressed',
'tmp_name' => '/tmp/php179.tmp',
'error' => 0,
'size' => '354784'
)
),
array(
'file' => array(
'name' => 'picture.jpg',
'type' => 'image/jpeg',
'tmp_name' => '/tmp/php180.tmp',
'error' => 0,
'size' => '21324'
)
)
);
$expected = array(array('name' => 'zipfile2.zip','type' => 'application/x-zip-compressed','tmp_name' => '/tmp/php179.tmp','error' => 0,'size' => '354784'));
$r = Set::extract('/file/.[type=application/x-zip-compressed]', $f);
$this->assertEqual($r, $expected);
$expected = array(array('name' => 'zipfile.zip','type' => 'application/zip','tmp_name' => '/tmp/php178.tmp','error' => 0,'size' => '564647'));
$r = Set::extract('/file/.[type=application/zip]', $f);
$this->assertEqual($r, $expected);
}
/**
* testMatches method