annotate core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php @ 16:c2387f117808

Routine composer update
author Chris Cannam
date Tue, 10 Jul 2018 15:07:59 +0100
parents
children 129ea1e6d783
rev   line source
Chris@16 1 <?php
Chris@16 2
Chris@16 3 namespace Drupal\FunctionalTests\Installer;
Chris@16 4
Chris@16 5 use Drupal\Component\Serialization\Yaml;
Chris@16 6 use Drupal\Core\Site\Settings;
Chris@16 7
Chris@16 8 /**
Chris@16 9 * Tests multiple distribution profile support.
Chris@16 10 *
Chris@16 11 * @group Installer
Chris@16 12 */
Chris@16 13 class MultipleDistributionsProfileTest extends InstallerTestBase {
Chris@16 14
Chris@16 15 /**
Chris@16 16 * The distribution profile info.
Chris@16 17 *
Chris@16 18 * @var array
Chris@16 19 */
Chris@16 20 protected $info;
Chris@16 21
Chris@16 22 /**
Chris@16 23 * {@inheritdoc}
Chris@16 24 */
Chris@16 25 protected function prepareEnvironment() {
Chris@16 26 parent::prepareEnvironment();
Chris@16 27 // Create two distributions.
Chris@16 28 foreach (['distribution_one', 'distribution_two'] as $name) {
Chris@16 29 $info = [
Chris@16 30 'type' => 'profile',
Chris@16 31 'core' => \Drupal::CORE_COMPATIBILITY,
Chris@16 32 'name' => $name . ' profile',
Chris@16 33 'distribution' => [
Chris@16 34 'name' => $name,
Chris@16 35 'install' => [
Chris@16 36 'theme' => 'bartik',
Chris@16 37 ],
Chris@16 38 ],
Chris@16 39 ];
Chris@16 40 // File API functions are not available yet.
Chris@16 41 $path = $this->root . DIRECTORY_SEPARATOR . $this->siteDirectory . '/profiles/' . $name;
Chris@16 42 mkdir($path, 0777, TRUE);
Chris@16 43 file_put_contents("$path/$name.info.yml", Yaml::encode($info));
Chris@16 44 }
Chris@16 45 // Install the first distribution.
Chris@16 46 $this->profile = 'distribution_one';
Chris@16 47 }
Chris@16 48
Chris@16 49 /**
Chris@16 50 * {@inheritdoc}
Chris@16 51 */
Chris@16 52 protected function setUpLanguage() {
Chris@16 53 // Verify that the distribution name appears.
Chris@16 54 $this->assertRaw('distribution_one');
Chris@16 55 // Verify that the requested theme is used.
Chris@16 56 $this->assertRaw('bartik');
Chris@16 57 // Verify that the "Choose profile" step does not appear.
Chris@16 58 $this->assertNoText('profile');
Chris@16 59
Chris@16 60 parent::setUpLanguage();
Chris@16 61 }
Chris@16 62
Chris@16 63 /**
Chris@16 64 * {@inheritdoc}
Chris@16 65 */
Chris@16 66 protected function setUpProfile() {
Chris@16 67 // This step is skipped, because there is a distribution profile.
Chris@16 68 }
Chris@16 69
Chris@16 70 /**
Chris@16 71 * Confirms that the installation succeeded.
Chris@16 72 */
Chris@16 73 public function testInstalled() {
Chris@16 74 $this->assertUrl('user/1');
Chris@16 75 $this->assertResponse(200);
Chris@16 76 // Confirm that we are logged-in after installation.
Chris@16 77 $this->assertText($this->rootUser->getUsername());
Chris@16 78
Chris@16 79 // Confirm that Drupal recognizes this distribution as the current profile.
Chris@16 80 $this->assertEqual(\Drupal::installProfile(), 'distribution_one');
Chris@16 81 $this->assertEqual(Settings::get('install_profile'), 'distribution_one', 'The install profile has been written to settings.php.');
Chris@16 82 $this->assertEqual($this->config('core.extension')->get('profile'), 'distribution_one', 'The install profile has been written to core.extension configuration.');
Chris@16 83
Chris@16 84 $this->rebuildContainer();
Chris@16 85 $this->pass('Container can be rebuilt as distribution is written to configuration.');
Chris@16 86 $this->assertEqual(\Drupal::installProfile(), 'distribution_one');
Chris@16 87 }
Chris@16 88
Chris@16 89 }