Chris@16: info = [ Chris@16: 'type' => 'profile', Chris@16: 'core' => \Drupal::CORE_COMPATIBILITY, Chris@16: 'name' => 'Distribution profile', Chris@16: 'distribution' => [ Chris@16: 'name' => 'My Distribution', Chris@16: 'install' => [ Chris@16: 'theme' => 'bartik', Chris@16: ], Chris@16: ], Chris@16: ]; Chris@16: // File API functions are not available yet. Chris@16: $path = $this->siteDirectory . '/profiles/mydistro'; Chris@16: mkdir($path, 0777, TRUE); Chris@16: file_put_contents("$path/mydistro.info.yml", Yaml::encode($this->info)); Chris@16: Chris@16: // Pre-configure hash salt. Chris@16: // Any string is valid, so simply use the class name of this test. Chris@16: $this->settings['settings']['hash_salt'] = (object) [ Chris@16: 'value' => __CLASS__, Chris@16: 'required' => TRUE, Chris@16: ]; Chris@16: Chris@16: // Pre-configure database credentials. Chris@16: $connection_info = Database::getConnectionInfo(); Chris@16: unset($connection_info['default']['pdo']); Chris@16: unset($connection_info['default']['init_commands']); Chris@16: Chris@16: $this->settings['databases']['default'] = (object) [ Chris@16: 'value' => $connection_info, Chris@16: 'required' => TRUE, Chris@16: ]; Chris@16: Chris@16: // Use the kernel to find the site path because the site.path service should Chris@16: // not be available at this point in the install process. Chris@16: $site_path = DrupalKernel::findSitePath(Request::createFromGlobals()); Chris@16: // Pre-configure config directories. Chris@16: $this->settings['config_directories'] = [ Chris@16: CONFIG_SYNC_DIRECTORY => (object) [ Chris@16: 'value' => $site_path . '/files/config_staging', Chris@16: 'required' => TRUE, Chris@16: ], Chris@16: ]; Chris@16: mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE); Chris@16: } Chris@16: Chris@16: /** Chris@16: * {@inheritdoc} Chris@16: */ Chris@16: protected function setUpLanguage() { Chris@16: // Make settings file not writable. Chris@16: $filename = $this->siteDirectory . '/settings.php'; Chris@16: // Make the settings file read-only. Chris@16: // Not using File API; a potential error must trigger a PHP warning. Chris@16: chmod($filename, 0444); Chris@16: Chris@16: // Verify that the distribution name appears. Chris@16: $this->assertRaw($this->info['distribution']['name']); Chris@16: // Verify that the requested theme is used. Chris@16: $this->assertRaw($this->info['distribution']['install']['theme']); Chris@16: // Verify that the "Choose profile" step does not appear. Chris@16: $this->assertNoText('profile'); Chris@16: Chris@16: parent::setUpLanguage(); Chris@16: } Chris@16: Chris@16: /** Chris@16: * {@inheritdoc} Chris@16: */ Chris@16: protected function setUpProfile() { Chris@16: // This step is skipped, because there is a distribution profile. Chris@16: } Chris@16: Chris@16: /** Chris@16: * {@inheritdoc} Chris@16: */ Chris@16: protected function setUpSettings() { Chris@16: // This step should not appear, since settings.php is fully configured Chris@16: // already. Chris@16: } Chris@16: Chris@16: /** Chris@16: * Confirms that the installation succeeded. Chris@16: */ Chris@16: public function testInstalled() { Chris@16: $this->assertUrl('user/1'); Chris@16: $this->assertResponse(200); Chris@16: // Confirm that we are logged-in after installation. Chris@18: $this->assertText($this->rootUser->getAccountName()); Chris@16: Chris@16: // Confirm that Drupal recognizes this distribution as the current profile. Chris@16: $this->assertEqual(\Drupal::installProfile(), 'mydistro'); Chris@17: $this->assertArrayNotHasKey('install_profile', Settings::getAll(), 'The install profile has not been written to settings.php.'); Chris@16: $this->assertEqual($this->config('core.extension')->get('profile'), 'mydistro', 'The install profile has been written to core.extension configuration.'); Chris@16: Chris@16: $this->rebuildContainer(); Chris@16: $this->pass('Container can be rebuilt even though distribution is not written to settings.php.'); Chris@16: $this->assertEqual(\Drupal::installProfile(), 'mydistro'); Chris@16: } Chris@16: Chris@16: }