Chris@17: getConfigTarball(), 'gz'); Chris@17: Chris@17: if ($this->profile === NULL) { Chris@17: $core_extension = Yaml::decode($archiver->extractInString('core.extension.yml')); Chris@17: $this->profile = $core_extension['profile']; Chris@17: } Chris@17: Chris@17: // Create a profile for testing. Chris@17: $info = [ Chris@17: 'type' => 'profile', Chris@17: 'core' => \Drupal::CORE_COMPATIBILITY, Chris@17: 'name' => 'Configuration installation test profile (' . $this->profile . ')', Chris@17: ]; Chris@17: Chris@17: // File API functions are not available yet. Chris@17: $path = $this->siteDirectory . '/profiles/' . $this->profile; Chris@17: if ($this->existingSyncDirectory) { Chris@17: $config_sync_directory = $this->siteDirectory . '/config/sync'; Chris@17: $this->settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) [ Chris@17: 'value' => $config_sync_directory, Chris@17: 'required' => TRUE, Chris@17: ]; Chris@17: } Chris@17: else { Chris@17: // Put the sync directory inside the profile. Chris@17: $config_sync_directory = $path . '/config/sync'; Chris@17: } Chris@17: Chris@17: mkdir($path, 0777, TRUE); Chris@17: file_put_contents("$path/{$this->profile}.info.yml", Yaml::encode($info)); Chris@17: Chris@17: // Create config/sync directory and extract tarball contents to it. Chris@17: mkdir($config_sync_directory, 0777, TRUE); Chris@17: $files = []; Chris@17: $list = $archiver->listContent(); Chris@17: if (is_array($list)) { Chris@17: /** @var array $list */ Chris@17: foreach ($list as $file) { Chris@17: $files[] = $file['filename']; Chris@17: } Chris@17: $archiver->extractList($files, $config_sync_directory); Chris@17: } Chris@17: } Chris@17: Chris@17: /** Chris@17: * Gets the filepath to the configuration tarball. Chris@17: * Chris@17: * The tarball will be extracted to the install profile's config/sync Chris@17: * directory for testing. Chris@17: * Chris@17: * @return string Chris@17: * The filepath to the configuration tarball. Chris@17: */ Chris@17: abstract protected function getConfigTarball(); Chris@17: Chris@17: /** Chris@17: * {@inheritdoc} Chris@17: */ Chris@17: protected function installParameters() { Chris@17: $parameters = parent::installParameters(); Chris@17: Chris@17: // The options that change configuration are disabled when installing from Chris@17: // existing configuration. Chris@17: unset($parameters['forms']['install_configure_form']['site_name']); Chris@17: unset($parameters['forms']['install_configure_form']['site_mail']); Chris@17: unset($parameters['forms']['install_configure_form']['update_status_module']); Chris@17: Chris@17: return $parameters; Chris@17: } Chris@17: Chris@17: /** Chris@17: * Confirms that the installation installed the configuration correctly. Chris@17: */ Chris@17: public function testConfigSync() { Chris@17: // After installation there is no snapshot and nothing to import. Chris@17: $change_list = $this->configImporter()->getStorageComparer()->getChangelist(); Chris@17: $expected = [ Chris@17: 'create' => [], Chris@17: // The system.mail is changed configuration because the test system Chris@17: // changes it to ensure that mails are not sent. Chris@17: 'update' => ['system.mail'], Chris@17: 'delete' => [], Chris@17: 'rename' => [], Chris@17: ]; Chris@17: $this->assertEqual($expected, $change_list); Chris@17: } Chris@17: Chris@17: /** Chris@17: * Installer step: Select installation profile. Chris@17: */ Chris@17: protected function setUpProfile() { Chris@17: if ($this->existingSyncDirectory) { Chris@17: $edit = [ Chris@17: 'profile' => SelectProfileForm::CONFIG_INSTALL_PROFILE_KEY, Chris@17: ]; Chris@17: $this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']); Chris@17: } Chris@17: else { Chris@17: parent::setUpProfile(); Chris@17: } Chris@17: } Chris@17: Chris@17: }