3 namespace Drupal\Tests\Core\Common;
5 use Drupal\Component\Utility\DiffArray;
6 use Drupal\Tests\UnitTestCase;
9 * Tests the DiffArray helper class.
13 class DiffArrayTest extends UnitTestCase {
16 * Array to use for testing.
23 * Array to use for testing.
29 protected function setUp() {
35 'array_empty_diff' => [],
38 'array_diff' => ['same' => 'same', 'array' => ['same' => 'same']],
39 'array_compared_to_string' => ['value'],
40 'string_compared_to_array' => 'value',
46 'array_empty_diff' => [],
49 'array_diff' => ['same' => 'different', 'array' => ['same' => 'same']],
50 'array_compared_to_string' => 'value',
51 'string_compared_to_array' => ['value'],
56 * Tests DiffArray::diffAssocRecursive().
58 public function testDiffAssocRecursive() {
62 // The 'array' key should not be returned, as it's the same.
63 'array_diff' => ['same' => 'same'],
64 'array_compared_to_string' => ['value'],
65 'string_compared_to_array' => 'value',
69 $this->assertSame($expected, DiffArray::diffAssocRecursive($this->array1, $this->array2));