ImportTest.php in Configuration Synchronizer 8.2
File
tests/src/Functional/ImportTest.php
View source
<?php
namespace Drupal\Tests\config_sync\Functional;
use Drupal\config_snapshot\Entity\ConfigSnapshot;
use Drupal\config_sync\ConfigSyncSnapshotterInterface;
use Drupal\node\Entity\NodeType;
use Drupal\Core\Config\StorageComparer;
use Drupal\Tests\BrowserTestBase;
class ImportTest extends BrowserTestBase {
public static $modules = [
'config_sync',
'config_sync_test',
];
public function testImportAfterChange() {
$admin_account = $this
->createUser([
'synchronize distro configuration',
]);
$this
->drupalLogin($admin_account);
$this
->drupalGet('/admin/config/development/configuration/distro');
$this
->assertSession()
->pageTextContains('There are no configuration changes to import.');
$this
->assertSession()
->pageTextNotContains('Config sync tests');
$test_module_config = ConfigSnapshot::load(ConfigSyncSnapshotterInterface::CONFIG_SNAPSHOT_SET . '.module.config_sync_test');
$items = $test_module_config
->getItems();
$node_type = NodeType::load('config_sync_test_1');
$provided_name = $items[0]['data']['name'];
$prior_name = 'Prior name';
$items[0]['data']['name'] = $prior_name;
$test_module_config
->setItems($items)
->save();
$node_type
->set('name', $prior_name)
->save();
$this
->drupalGet('/admin/config/development/configuration/distro');
$this
->assertSession()
->pageTextContains('Config sync tests');
$this
->assertSession()
->pageTextContains('View differences');
$this
->assertSession()
->responseContains('Import');
$this
->assertSession()
->pageTextNotContains('There are no configuration changes to import.');
$this
->drupalPostForm('admin/config/development/configuration/distro', [], t('Import'));
$this
->assertIdentical($this
->configImporter()
->getErrors(), []);
$storage_comparer = new StorageComparer($this->container
->get('config_distro.storage.distro'), $this->container
->get('config.storage'), $this->container
->get('config.manager'));
$this
->assertIdentical($storage_comparer
->createChangelist()
->getChangelist(), $storage_comparer
->getEmptyChangelist());
$this
->drupalGet('/admin/config/development/configuration/distro');
$this
->assertSession()
->pageTextContains('There are no configuration changes to import.');
$this
->assertSession()
->pageTextNotContains('Config sync tests');
$node_type = NodeType::load('config_sync_test_1');
$this
->assertIdentical($node_type
->get('name'), $provided_name);
$test_module_config = ConfigSnapshot::load(ConfigSyncSnapshotterInterface::CONFIG_SNAPSHOT_SET . '.module.config_sync_test');
$items = $test_module_config
->getItems();
$this
->assertIdentical($items[0]['data']['name'], $provided_name);
}
}
Classes
Name |
Description |
ImportTest |
Test importing configuration changes in the UI. |