annotate core/modules/system/src/Tests/Installer/DistributionProfileTest.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\system\Tests\Installer;
Chris@0 4
Chris@0 5 use Drupal\Core\Serialization\Yaml;
Chris@0 6 use Drupal\Core\Site\Settings;
Chris@0 7 use Drupal\simpletest\InstallerTestBase;
Chris@0 8
Chris@0 9 /**
Chris@0 10 * Tests distribution profile support.
Chris@0 11 *
Chris@0 12 * @group Installer
Chris@0 13 */
Chris@0 14 class DistributionProfileTest extends InstallerTestBase {
Chris@0 15
Chris@0 16 /**
Chris@0 17 * The distribution profile info.
Chris@0 18 *
Chris@0 19 * @var array
Chris@0 20 */
Chris@0 21 protected $info;
Chris@0 22
Chris@0 23 protected function setUp() {
Chris@0 24 $this->info = [
Chris@0 25 'type' => 'profile',
Chris@0 26 'core' => \Drupal::CORE_COMPATIBILITY,
Chris@0 27 'name' => 'Distribution profile',
Chris@0 28 'distribution' => [
Chris@0 29 'name' => 'My Distribution',
Chris@0 30 'install' => [
Chris@0 31 'theme' => 'bartik',
Chris@0 32 ],
Chris@0 33 ],
Chris@0 34 ];
Chris@0 35 // File API functions are not available yet.
Chris@0 36 $path = $this->siteDirectory . '/profiles/mydistro';
Chris@0 37 mkdir($path, 0777, TRUE);
Chris@0 38 file_put_contents("$path/mydistro.info.yml", Yaml::encode($this->info));
Chris@0 39
Chris@0 40 parent::setUp();
Chris@0 41 }
Chris@0 42
Chris@0 43 /**
Chris@0 44 * {@inheritdoc}
Chris@0 45 */
Chris@0 46 protected function setUpLanguage() {
Chris@0 47 // Verify that the distribution name appears.
Chris@0 48 $this->assertRaw($this->info['distribution']['name']);
Chris@12 49 // Verify that the distribution name is used in the site title.
Chris@12 50 $this->assertTitle('Choose language | ' . $this->info['distribution']['name']);
Chris@0 51 // Verify that the requested theme is used.
Chris@0 52 $this->assertRaw($this->info['distribution']['install']['theme']);
Chris@0 53 // Verify that the "Choose profile" step does not appear.
Chris@0 54 $this->assertNoText('profile');
Chris@0 55
Chris@0 56 parent::setUpLanguage();
Chris@0 57 }
Chris@0 58
Chris@0 59 /**
Chris@0 60 * {@inheritdoc}
Chris@0 61 */
Chris@0 62 protected function setUpProfile() {
Chris@0 63 // This step is skipped, because there is a distribution profile.
Chris@0 64 }
Chris@0 65
Chris@0 66 /**
Chris@0 67 * Confirms that the installation succeeded.
Chris@0 68 */
Chris@0 69 public function testInstalled() {
Chris@0 70 $this->assertUrl('user/1');
Chris@0 71 $this->assertResponse(200);
Chris@0 72 // Confirm that we are logged-in after installation.
Chris@0 73 $this->assertText($this->rootUser->getUsername());
Chris@0 74
Chris@0 75 // Confirm that Drupal recognizes this distribution as the current profile.
Chris@0 76 $this->assertEqual(\Drupal::installProfile(), 'mydistro');
Chris@0 77 $this->assertEqual(Settings::get('install_profile'), 'mydistro', 'The install profile has been written to settings.php.');
Chris@0 78 $this->assertEqual($this->config('core.extension')->get('profile'), 'mydistro', 'The install profile has been written to core.extension configuration.');
Chris@0 79 }
Chris@0 80
Chris@0 81 }