diff --git a/cake/basics.php b/cake/basics.php index 1c1dd61d1..d82fa49d0 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -810,7 +810,7 @@ if (!function_exists('file_put_contents')) { foreach ($args[0] as $valueKey => $valueData) { for ($i = 1; $i < $argc; $i++) { - if (isset($args[$i][$valueKey])) { + if (array_key_exists($valueKey, $args[$i])) { continue 2; } } diff --git a/cake/tests/cases/basics.test.php b/cake/tests/cases/basics.test.php index a320bc075..7baeeb60f 100644 --- a/cake/tests/cases/basics.test.php +++ b/cake/tests/cases/basics.test.php @@ -54,6 +54,36 @@ class BasicsTest extends CakeTestCase { Configure::write('localePaths', $this->_localePaths); Configure::write('Config.language', $this->_language); } +/** + * test the array_diff_key compatibility function. + * + * @return void + **/ + function testArrayDiffKey() { + $one = array('one' => 1, 'two' => 2, 'three' => 3); + $two = array('one' => 'one', 'two' => 'two'); + $result = array_diff_key($one, $two); + $expected = array('three' => 3); + $this->assertEqual($result, $expected); + + $one = array('one' => array('value', 'value-two'), 'two' => 2, 'three' => 3); + $two = array('two' => 'two'); + $result = array_diff_key($one, $two); + $expected = array('one' => array('value', 'value-two'), 'three' => 3); + $this->assertEqual($result, $expected); + + $one = array('one' => null, 'two' => 2, 'three' => '', 'four' => 0); + $two = array('two' => 'two'); + $result = array_diff_key($one, $two); + $expected = array('one' => null, 'three' => '', 'four' => 0); + $this->assertEqual($result, $expected); + + $one = array('minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true); + $two = array('minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true); + $result = array_diff_key($one, $two); + $this->assertEqual($result, array()); + + } /** * testHttpBase method * @@ -110,10 +140,10 @@ class BasicsTest extends CakeTestCase { $_SERVER['HTTPS'] = 'off'; $this->assertFalse(env('HTTPS')); - + $_SERVER['HTTPS'] = false; $this->assertFalse(env('HTTPS')); - + $_SERVER['HTTPS'] = ''; $this->assertFalse(env('HTTPS')); diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index d3145596c..3b8817ab8 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -291,7 +291,7 @@ class PaginatorHelperTest extends CakeTestCase { $this->assertEqual($result, $expected); - unset($this->paginator->params['paging']['article']['options']); + unset($this->Paginator->params['paging']['Article']['options']); $this->Paginator->params['paging']['Article']['options']['direction'] = 'desc'; $result = $this->Paginator->sortDir(); $expected = 'desc';