diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index bfe4c7fc1..5e37c8dfb 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -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} ); } } diff --git a/cake/libs/folder.php b/cake/libs/folder.php index 8a470cbd5..36cba374b 100644 --- a/cake/libs/folder.php +++ b/cake/libs/folder.php @@ -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) == '\\\\'); } /** diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 4a8860a2f..02260dcb5 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -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); diff --git a/cake/tests/cases/libs/controller/controller_merge_vars.test.php b/cake/tests/cases/libs/controller/controller_merge_vars.test.php index c09392908..3f16bd7cd 100644 --- a/cake/tests/cases/libs/controller/controller_merge_vars.test.php +++ b/cake/tests/cases/libs/controller/controller_merge_vars.test.php @@ -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'); diff --git a/cake/tests/cases/libs/folder.test.php b/cake/tests/cases/libs/folder.test.php index 68d2c706c..428520610 100644 --- a/cake/tests/cases/libs/folder.test.php +++ b/cake/tests/cases/libs/folder.test.php @@ -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')); } /** diff --git a/cake/tests/cases/libs/set.test.php b/cake/tests/cases/libs/set.test.php index 9d0d1b08b..9fbc4086b 100644 --- a/cake/tests/cases/libs/set.test.php +++ b/cake/tests/cases/libs/set.test.php @@ -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); + } }