public function ConfigReverterTest::testImport in Configuration Update Manager 8
@covers \Drupal\config_update\ConfigReverter::import @dataProvider importProvider
File
- tests/
src/ Unit/ ConfigReverterTest.php, line 107
Class
- ConfigReverterTest
- Tests the \Drupal\config_update\ConfigReverter class.
Namespace
Drupal\Tests\config_update\UnitCode
public function testImport($type, $name, $config_name, $expected, $config_before, $config_after) {
// Clear dispatch log and set pre-config.
$this->dispatchedEvents = [];
if ($config_name) {
$this->configStorage[$config_name] = $config_before;
}
$save_config = $this->configStorage;
// Call the importer and test the Boolean result.
$result = $this->configReverter
->import($type, $name);
$this
->assertEquals($result, $expected);
if ($result) {
// Verify that the config is correct after import, and logging worked.
$this
->assertEquals($this->configStorage[$config_name], $config_after);
$this
->assertEquals(count($this->dispatchedEvents), 1);
$this
->assertEquals($this->dispatchedEvents[0][0], ConfigRevertInterface::IMPORT);
}
else {
// Verify that the config didn't change and no events were logged.
$this
->assertEquals($this->configStorage, $save_config);
$this
->assertEquals(count($this->dispatchedEvents), 0);
}
}