Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding tests for array_diff_key() in php4. Increasing test compatibil…

…ity with php4

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8281 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit 72d90f2ce82a2c1c4ca33d141e07f8d80026adc6 1 parent 57552c2
Mark Story markstory authored
2  cake/basics.php
View
@@ -810,7 +810,7 @@ function array_diff_key() {
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;
}
}
34 cake/tests/cases/basics.test.php
View
@@ -55,6 +55,36 @@ function tearDown() {
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
*
* @return void
@@ -110,10 +140,10 @@ function testEnv() {
$_SERVER['HTTPS'] = 'off';
$this->assertFalse(env('HTTPS'));
-
+
$_SERVER['HTTPS'] = false;
$this->assertFalse(env('HTTPS'));
-
+
$_SERVER['HTTPS'] = '';
$this->assertFalse(env('HTTPS'));
2  cake/tests/cases/libs/view/helpers/paginator.test.php
View
@@ -291,7 +291,7 @@ function testSortDir() {
$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';
Please sign in to comment.
Something went wrong with that request. Please try again.