annotate core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php @ 5:12f9dff5fda9 tip

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