3 namespace Drupal\system\Tests\Installer;
5 use Drupal\Core\Serialization\Yaml;
6 use Drupal\Core\Site\Settings;
7 use Drupal\simpletest\InstallerTestBase;
10 * Tests distribution profile support.
14 class DistributionProfileTest extends InstallerTestBase {
17 * The distribution profile info.
23 protected function setUp() {
26 'core' => \Drupal::CORE_COMPATIBILITY,
27 'name' => 'Distribution profile',
29 'name' => 'My Distribution',
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));
46 protected function setUpLanguage() {
47 // Verify that the distribution name appears.
48 $this->assertRaw($this->info['distribution']['name']);
49 // Verify that the distribution name is used in the site title.
50 $this->assertTitle('Choose language | ' . $this->info['distribution']['name']);
51 // Verify that the requested theme is used.
52 $this->assertRaw($this->info['distribution']['install']['theme']);
53 // Verify that the "Choose profile" step does not appear.
54 $this->assertNoText('profile');
56 parent::setUpLanguage();
62 protected function setUpProfile() {
63 // This step is skipped, because there is a distribution profile.
67 * Confirms that the installation succeeded.
69 public function testInstalled() {
70 $this->assertUrl('user/1');
71 $this->assertResponse(200);
72 // Confirm that we are logged-in after installation.
73 $this->assertText($this->rootUser->getUsername());
75 // Confirm that Drupal recognizes this distribution as the current profile.
76 $this->assertEqual(\Drupal::installProfile(), 'mydistro');
77 $this->assertEqual(Settings::get('install_profile'), 'mydistro', 'The install profile has been written to settings.php.');
78 $this->assertEqual($this->config('core.extension')->get('profile'), 'mydistro', 'The install profile has been written to core.extension configuration.');