3 namespace Drupal\FunctionalTests\Installer;
5 use Drupal\Core\Serialization\Yaml;
8 * Tests distribution profile support.
12 class DistributionProfileTest extends InstallerTestBase {
15 * The distribution profile info.
21 protected function prepareEnvironment() {
22 parent::prepareEnvironment();
25 'core' => \Drupal::CORE_COMPATIBILITY,
26 'name' => 'Distribution profile',
28 'name' => 'My Distribution',
31 'finish_url' => '/myrootuser',
35 // File API functions are not available yet.
36 $path = $this->siteDirectory . '/profiles/mydistro';
37 mkdir($path, 0777, TRUE);
38 file_put_contents("$path/mydistro.info.yml", Yaml::encode($this->info));
39 file_put_contents("$path/mydistro.install", "<?php function mydistro_install() {\Drupal::service('path.alias_storage')->save('/user/1', '/myrootuser');}");
45 protected function setUpLanguage() {
46 // Verify that the distribution name appears.
47 $this->assertRaw($this->info['distribution']['name']);
48 // Verify that the distribution name is used in the site title.
49 $this->assertTitle('Choose language | ' . $this->info['distribution']['name']);
50 // Verify that the requested theme is used.
51 $this->assertRaw($this->info['distribution']['install']['theme']);
52 // Verify that the "Choose profile" step does not appear.
53 $this->assertNoText('profile');
55 parent::setUpLanguage();
61 protected function setUpProfile() {
62 // This step is skipped, because there is a distribution profile.
66 * Confirms that the installation succeeded.
68 public function testInstalled() {
69 $this->assertUrl('myrootuser');
70 $this->assertResponse(200);
71 // Confirm that we are logged-in after installation.
72 $this->assertText($this->rootUser->getUsername());
74 // Confirm that Drupal recognizes this distribution as the current profile.
75 $this->assertEqual(\Drupal::installProfile(), 'mydistro');
76 $this->assertEqual($this->config('core.extension')->get('profile'), 'mydistro', 'The install profile has been written to core.extension configuration.');