Merge branch '1.3' into merger

Conflicts:
	cake/libs/configure.php
This commit is contained in:
mark_story 2010-11-20 23:14:33 -05:00
commit 3237402fb8
6 changed files with 76 additions and 9 deletions

View file

@ -448,7 +448,7 @@ class Controller extends Object {
foreach ($merge as $var) {
if (!empty($appVars[$var]) && is_array($this->{$var})) {
if ($var === 'components') {
if ($var !== 'uses') {
$normal = Set::normalize($this->{$var});
$app = Set::normalize($appVars[$var]);
if ($app !== $normal) {
@ -456,7 +456,7 @@ class Controller extends Object {
}
} else {
$this->{$var} = Set::merge(
$this->{$var}, array_diff($appVars[$var], $this->{$var})
array_diff($appVars[$var], $this->{$var}), $this->{$var}
);
}
}
@ -474,7 +474,7 @@ class Controller extends Object {
foreach ($merge as $var) {
if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) {
if ($var === 'components') {
if ($var !== 'uses') {
$normal = Set::normalize($this->{$var});
$app = Set::normalize($appVars[$var]);
if ($app !== $normal) {
@ -482,7 +482,7 @@ class Controller extends Object {
}
} else {
$this->{$var} = Set::merge(
$this->{$var}, array_diff($appVars[$var], $this->{$var})
array_diff($appVars[$var], $this->{$var}), $this->{$var}
);
}
}

View file

@ -244,7 +244,7 @@ class Folder {
* @static
*/
function isWindowsPath($path) {
return (bool)preg_match('/^[A-Z]:\\\\/i', $path);
return (preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\');
}
/**
@ -256,7 +256,7 @@ class Folder {
* @static
*/
function isAbsolute($path) {
return !empty($path) && ($path[0] === '/' || preg_match('/^[A-Z]:\\\\/i', $path));
return !empty($path) && ($path[0] === '/' || preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\');
}
/**

View file

@ -1241,7 +1241,7 @@ class ControllerTest extends CakeTestCase {
? array_merge($appVars['uses'], $testVars['uses'])
: $testVars['uses'];
$this->assertEqual(count(array_diff($TestController->helpers, $helpers)), 0);
$this->assertEqual(count(array_diff_assoc(Set::normalize($TestController->helpers), Set::normalize($helpers))), 0);
$this->assertEqual(count(array_diff($TestController->uses, $uses)), 0);
$this->assertEqual(count(array_diff_assoc(Set::normalize($TestController->components), Set::normalize($components))), 0);

View file

@ -183,6 +183,25 @@ class ControllerMergeVarsTest extends CakeTestCase {
$this->assertEqual($Controller->helpers, $expected, 'Duplication of settings occured. %s');
}
/**
* Test that helpers declared in appcontroller come before those in the subclass
* orderwise
*
* @return void
*/
function testHelperOrderPrecedence() {
$Controller =& new MergeVariablesController();
$Controller->helpers = array('Custom', 'Foo' => array('something'));
$Controller->constructClasses();
$expected = array(
'MergeVar' => array('format' => 'html', 'terse'),
'Custom' => null,
'Foo' => array('something')
);
$this->assertIdentical($Controller->helpers, $expected, 'Order is incorrect. %s');
}
/**
* test merging of vars with plugin
*
@ -204,8 +223,8 @@ class ControllerMergeVarsTest extends CakeTestCase {
$this->assertEqual($Controller->components, $expected, 'Components are unexpected %s');
$expected = array(
'Javascript',
'MergeVar' => array('format' => 'html', 'terse')
'MergeVar' => array('format' => 'html', 'terse'),
'Javascript' => null
);
$this->assertEqual($Controller->helpers, $expected, 'Helpers are unexpected %s');

View file

@ -367,6 +367,7 @@ class FolderTest extends CakeTestCase {
$this->assertFalse(Folder::isWindowsPath('0:\\cake\\is\\awesome'));
$this->assertTrue(Folder::isWindowsPath('C:\\cake\\is\\awesome'));
$this->assertTrue(Folder::isWindowsPath('d:\\cake\\is\\awesome'));
$this->assertTrue(Folder::isWindowsPath('\\\\vmware-host\\Shared Folders\\file'));
}
/**
@ -388,6 +389,7 @@ class FolderTest extends CakeTestCase {
$this->assertTrue(Folder::isAbsolute('C:\\cake'));
$this->assertTrue(Folder::isAbsolute('C:\\path\\to\\file'));
$this->assertTrue(Folder::isAbsolute('d:\\path\\to\\file'));
$this->assertTrue(Folder::isAbsolute('\\\\vmware-host\\Shared Folders\\file'));
}
/**

View file

@ -2990,4 +2990,50 @@ class SetTest extends CakeTestCase {
);
$this->assertEqual($result, $expected);
}
/**
* test normalization
*
* @return void
*/
function testNormalizeStrings() {
$result = Set::normalize('one,two,three');
$expected = array('one' => null, 'two' => null, 'three' => null);
$this->assertEqual($expected, $result);
$result = Set::normalize('one two three', true, ' ');
$expected = array('one' => null, 'two' => null, 'three' => null);
$this->assertEqual($expected, $result);
$result = Set::normalize('one , two , three ', true, ',', true);
$expected = array('one' => null, 'two' => null, 'three' => null);
$this->assertEqual($expected, $result);
}
/**
* test normalizing arrays
*
* @return void
*/
function testNormalizeArrays() {
$result = Set::normalize(array('one', 'two', 'three'));
$expected = array('one' => null, 'two' => null, 'three' => null);
$this->assertEqual($expected, $result);
$result = Set::normalize(array('one', 'two', 'three'), false);
$expected = array('one', 'two', 'three');
$this->assertEqual($expected, $result);
$result = Set::normalize(array('one' => 1, 'two' => 2, 'three' => 3, 'four'), false);
$expected = array('one' => 1, 'two' => 2, 'three' => 3, 'four' => null);
$this->assertEqual($expected, $result);
$result = Set::normalize(array('one' => 1, 'two' => 2, 'three' => 3, 'four'));
$expected = array('one' => 1, 'two' => 2, 'three' => 3, 'four' => null);
$this->assertEqual($expected, $result);
$result = Set::normalize(array('one' => array('a', 'b', 'c' => 'cee'), 'two' => 2, 'three'));
$expected = array('one' => array('a', 'b', 'c' => 'cee'), 'two' => 2, 'three' => null);
$this->assertEqual($expected, $result);
}
}