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