Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improving tests for Set::diff

  • Loading branch information...
commit aadf62de6eaac39db632abb7e58fa3b0b84398ec 1 parent a89d9e4
@lorenzo lorenzo authored
Showing with 42 additions and 1 deletion.
  1. +42 −1 cake/tests/cases/libs/set.test.php
View
43 cake/tests/cases/libs/set.test.php
@@ -1032,7 +1032,7 @@ function testExtract() {
/**
* testExtractWithArrays method
- *
+ *
* @access public
* @return void
*/
@@ -1456,6 +1456,47 @@ function testDiff() {
0 => array('name' => 'main')
);
$this->assertIdentical($result, $expected);
+
+ $a = array();
+ $b = array('name' => 'bob', 'address' => 'home');
+ $result = Set::diff($a, $b);
+ $this->assertIdentical($result, $b);
+
+
+ $a = array('name' => 'bob', 'address' => 'home');
+ $b = array();
+ $result = Set::diff($a, $b);
+ $this->assertIdentical($result, $a);
+
+ $a = array('key' => true, 'another' => false, 'name' => 'me');
+ $b = array('key' => 1, 'another' => 0);
+ $expected = array('name' => 'me');
+ $result = Set::diff($a, $b);
+ $this->assertIdentical($result, $expected);
+
+ $a = array('key' => 'value', 'another' => null, 'name' => 'me');
+ $b = array('key' => 'differentValue', 'another' => null);
+ $expected = array('key' => 'value', 'name' => 'me');
+ $result = Set::diff($a, $b);
+ $this->assertIdentical($result, $expected);
+
+ $a = array('key' => 'value', 'another' => null, 'name' => 'me');
+ $b = array('key' => 'differentValue', 'another' => 'value');
+ $expected = array('key' => 'value', 'another' => null, 'name' => 'me');
+ $result = Set::diff($a, $b);
+ $this->assertIdentical($result, $expected);
+
+ $a = array('key' => 'value', 'another' => null, 'name' => 'me');
+ $b = array('key' => 'differentValue', 'another' => 'value');
+ $expected = array('key' => 'differentValue', 'another' => 'value', 'name' => 'me');
+ $result = Set::diff($b, $a);
+ $this->assertIdentical($result, $expected);
+
+ $a = array('key' => 'value', 'another' => null, 'name' => 'me');
+ $b = array(0 => 'differentValue', 1 => 'value');
+ $expected = $a + $b;
+ $result = Set::diff($a, $b);
+ $this->assertIdentical($result, $expected);
}
/**

0 comments on commit aadf62d

Please sign in to comment.
Something went wrong with that request. Please try again.