public function ConfigSyncMergerTest::statesProvider in Configuration Synchronizer 8
Provides data to ::testMergeConfigItemStates().
File
- tests/
src/ Unit/ ConfigSyncMergerTest.php, line 46
Class
- ConfigSyncMergerTest
- @coversDefaultClass \Drupal\config_sync\ConfigSyncMerger @group config_sync
Namespace
Drupal\Tests\config_sync\UnitCode
public function statesProvider() {
$data = [];
// Test the case that there is no change between previous and current.
list($previous, $current, $active) = $this
->getStates();
// If there is no difference between previous and current, no changes should be
// made to active.
$expected = $active;
$data['no difference'] = [
$previous,
$current,
$active,
$expected,
];
// Test additions.
list($previous, $current, $active) = $this
->getStates();
$current['second'][] = 'three';
$current['third']['third'] = 'three';
$current['another'] = 'test';
// Additions should be merged into active.
$expected = $active;
$expected['second'][] = 'three';
$expected['third']['third'] = 'three';
$expected['another'] = 'test';
$data['additions'] = [
$previous,
$current,
$active,
$expected,
];
// Test deletions.
list($previous, $current, $active) = $this
->getStates();
unset($current['first']);
unset($current['second'][array_search('two', $current['second'])]);
unset($current['third']['one']);
// Deletions should be made to active.
$expected = $active;
unset($expected['first']);
unset($expected['second'][array_search('two', $expected['second'])]);
unset($expected['third']['one']);
$data['deletions'] = [
$previous,
$current,
$active,
$expected,
];
// Test deletions when the value has been customized.
// Expected is unchanged because a customized value should not be
// deleted.
$active['fifth'] = 'customized';
unset($current['fifth']);
$expected['fifth'] = 'customized';
$data['deletions with customization'] = [
$previous,
$current,
$active,
$expected,
];
// Test changes.
list($previous, $current, $active) = $this
->getStates();
$current['third']['one'] = 'change';
$current['fourth'] = 'change';
$expected = $active;
$expected['third']['one'] = 'change';
$expected['fourth'] = 'change';
$data['changes'] = [
$previous,
$current,
$active,
$expected,
];
// Test changes with customization.
// In this case, the active value should be retained despite the
// availability of an update.
$active['third']['one'] = 'active';
$expected['third']['one'] = 'active';
$data['changes with customization'] = [
$previous,
$current,
$active,
$expected,
];
return $data;
}