diff options
author | David Rothstein <drothstein@gmail.com> | 2013-06-23 17:17:12 -0400 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2013-06-23 17:17:12 -0400 |
commit | f083e0f782cf424c3b93b4c3cbacd51bfb635e5f (patch) | |
tree | 29b90b556496afa1dad3b156dee62c1bf212968e /modules | |
parent | 3201287ba449a71ea01c2159b59b71a020617ea5 (diff) | |
download | brdo-f083e0f782cf424c3b93b4c3cbacd51bfb635e5f.tar.gz brdo-f083e0f782cf424c3b93b4c3cbacd51bfb635e5f.tar.bz2 |
Issue #1850798 by damiankloip, ACF, geerlingguy, pfrenssen, David_Rothstein | mvc: Add a recursive version of array_diff_assoc().
Diffstat (limited to 'modules')
-rw-r--r-- | modules/simpletest/tests/common.test | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index 82e3055d2..97916e46b 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -2630,3 +2630,75 @@ class FeedIconTest extends DrupalWebTestCase { } } + +/** + * Test array diff functions. + */ +class ArrayDiffUnitTest extends DrupalUnitTestCase { + + /** + * Array to use for testing. + * + * @var array + */ + protected $array1; + + /** + * Array to use for testing. + * + * @var array + */ + protected $array2; + + public static function getInfo() { + return array( + 'name' => 'Array differences', + 'description' => 'Performs tests on drupal_array_diff_assoc_recursive().', + 'group' => 'System', + ); + } + + function setUp() { + parent::setUp(); + + $this->array1 = array( + 'same' => 'yes', + 'different' => 'no', + 'array_empty_diff' => array(), + 'null' => NULL, + 'int_diff' => 1, + 'array_diff' => array('same' => 'same', 'array' => array('same' => 'same')), + 'array_compared_to_string' => array('value'), + 'string_compared_to_array' => 'value', + 'new' => 'new', + ); + $this->array2 = array( + 'same' => 'yes', + 'different' => 'yes', + 'array_empty_diff' => array(), + 'null' => NULL, + 'int_diff' => '1', + 'array_diff' => array('same' => 'different', 'array' => array('same' => 'same')), + 'array_compared_to_string' => 'value', + 'string_compared_to_array' => array('value'), + ); + } + + + /** + * Tests drupal_array_diff_assoc_recursive(). + */ + public function testArrayDiffAssocRecursive() { + $expected = array( + 'different' => 'no', + 'int_diff' => 1, + // The 'array' key should not be returned, as it's the same. + 'array_diff' => array('same' => 'same'), + 'array_compared_to_string' => array('value'), + 'string_compared_to_array' => 'value', + 'new' => 'new', + ); + + $this->assertIdentical(drupal_array_diff_assoc_recursive($this->array1, $this->array2), $expected); + } +} |