annotate core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php @ 19:fa3358dc1485 tip

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