Adding tests for array_diff_key() in php4. Increasing test compatibility with php4

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8281 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mark_story 2009-08-03 19:24:38 +00:00
parent 57552c25fc
commit 72d90f2ce8
3 changed files with 34 additions and 4 deletions

View file

@ -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;
}
}

View file

@ -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'));

View file

@ -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';