You are here

public function ConfigDifferTest::sameProvider in Configuration Update Manager 8

Data provider for self:testSame().

File

tests/src/Unit/ConfigDifferTest.php, line 41

Class

ConfigDifferTest
Tests the \Drupal\config_update\ConfigDiffer class.

Namespace

Drupal\Tests\config_update\Unit

Code

public function sameProvider() {
  $base = [
    'uuid' => 'bar',
    'a' => 'a',
    'b' => 0,
    'c' => [
      'd' => TRUE,
      'e' => FALSE,
      'empty' => [],
    ],
  ];
  return [
    [
      $base,
      $base,
      TRUE,
    ],
    // Add _core, omit uuid at top level. Should match, as both are removed
    // in normalization process.
    [
      $base,
      [
        '_core' => 'foo',
        'a' => 'a',
        'b' => 0,
        'c' => [
          'd' => TRUE,
          'e' => FALSE,
          'empty' => [],
        ],
      ],
      TRUE,
    ],
    // Change order in top and deep level. Should match.
    [
      $base,
      [
        'uuid' => 'bar',
        'b' => 0,
        'a' => 'a',
        'c' => [
          'e' => FALSE,
          'empty' => [],
          'd' => TRUE,
        ],
      ],
      TRUE,
    ],
    // Add _core in deeper level. Should not match, as this is removed
    // only at the top level during normalization.
    [
      $base,
      [
        'uuid' => 'bar',
        'a' => 'a',
        'b' => 0,
        'c' => [
          '_core' => 'do-not-use-this-key',
          'd' => TRUE,
          'e' => FALSE,
          'empty' => [],
        ],
      ],
      FALSE,
    ],
    // Add uuid in deeper level. Should not match, as this is removed
    // only at the top level during normalization.
    [
      $base,
      [
        'uuid' => 'bar',
        'a' => 'a',
        'b' => 0,
        'c' => [
          'd' => TRUE,
          'e' => FALSE,
          'uuid' => 'important',
          'empty' => [],
        ],
      ],
      FALSE,
    ],
    // Omit a component. Should not match.
    [
      $base,
      [
        'uuid' => 'bar',
        'a' => 'a',
        'c' => [
          'd' => TRUE,
          'e' => FALSE,
          'empty' => [],
        ],
      ],
      FALSE,
    ],
    // Add a component. Should not match.
    [
      $base,
      [
        'uuid' => 'bar',
        'a' => 'a',
        'b' => 0,
        'c' => [
          'd' => TRUE,
          'e' => FALSE,
          'empty' => [],
        ],
        'f' => 'f',
      ],
      FALSE,
    ],
    // 0 should not match a string.
    [
      $base,
      [
        '_core' => 'foo',
        'uuid' => 'bar',
        'a' => 'a',
        'b' => 'b',
        'c' => [
          'd' => TRUE,
          'e' => FALSE,
          'empty' => [],
        ],
      ],
      FALSE,
    ],
    // 0 should not match NULL.
    [
      $base,
      [
        '_core' => 'foo',
        'uuid' => 'bar',
        'a' => 'a',
        'b' => NULL,
        'c' => [
          'd' => TRUE,
          'e' => FALSE,
          'empty' => [],
        ],
      ],
      FALSE,
    ],
    // FALSE should not match a string.
    [
      $base,
      [
        '_core' => 'foo',
        'uuid' => 'bar',
        'a' => 'a',
        'b' => 0,
        'c' => [
          'd' => TRUE,
          'e' => 'e',
          'empty' => [],
        ],
      ],
      FALSE,
    ],
    // TRUE should not match a string.
    [
      $base,
      [
        '_core' => 'foo',
        'uuid' => 'bar',
        'a' => 'a',
        'b' => 0,
        'c' => [
          'd' => 'd',
          'e' => FALSE,
          'empty' => [],
        ],
      ],
      FALSE,
    ],
    // Add an empty array at top, and remove at lower level. Should still
    // match.
    [
      $base,
      [
        '_core' => 'foo',
        'uuid' => 'bar',
        'a' => 'a',
        'b' => 0,
        'c' => [
          'd' => TRUE,
          'e' => FALSE,
        ],
        'empty_two' => [],
      ],
      TRUE,
    ],
  ];
}