You are here

protected function ConfigInstallerSyncTest::setUpSyncForm in Configuration installer 8

Submit the config_installer_sync_configure_form.

Overrides ConfigInstallerTestBase::setUpSyncForm

See also

\Drupal\config_installer\Form\SyncConfigureForm

File

tests/src/Functional/ConfigInstallerSyncTest.php, line 45

Class

ConfigInstallerSyncTest
Tests the config installer profile by having files in a sync directory.

Namespace

Drupal\Tests\config_installer\Functional

Code

protected function setUpSyncForm() {

  // Create a new sync directory.
  drupal_mkdir($this->syncDir);

  // Extract the tarball into the sync directory.
  $this
    ->extractTarball($this
    ->getTarball(), $this->syncDir);

  // Change the user.settings::register so that we can test that
  // standard_install() does not override it.
  $sync = new FileStorage($this->syncDir);
  $user_settings = $sync
    ->read('user.settings');
  $user_settings['register'] = USER_REGISTER_ADMINISTRATORS_ONLY;
  $sync
    ->write('user.settings', $user_settings);

  // Create config for a module that will not be enabled.
  $sync
    ->write('foo.bar', []);
  $this
    ->drupalPostForm(NULL, [
    'sync_directory' => drupal_realpath($this->syncDir),
  ], 'Save and continue');
  $this
    ->assertText('The configuration cannot be imported because it failed validation for the following reasons:');
  $this
    ->assertText('Configuration foo.bar depends on the foo extension that will not be installed after import.');

  // Remove incorrect config and continue on.
  $sync
    ->delete('foo.bar');
  $this
    ->drupalPostForm(NULL, [
    'sync_directory' => drupal_realpath($this->syncDir),
  ], 'Save and continue');
}