class DistributionProfileTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php \Drupal\FunctionalTests\Installer\DistributionProfileTest
Tests distribution profile support.
@group Installer
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\FunctionalTests\Installer\InstallerTestBase uses \Drupal\Tests\RequirementsPageTrait implements \Drupal\Tests\BrowserTestBase
- class \Drupal\FunctionalTests\Installer\DistributionProfileTest implements \Drupal\FunctionalTests\Installer\InstallerTestBase
- class \Drupal\FunctionalTests\Installer\InstallerTestBase uses \Drupal\Tests\RequirementsPageTrait implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of DistributionProfileTest
File
-
core/
tests/ Drupal/ FunctionalTests/ Installer/ DistributionProfileTest.php, line 12
Namespace
Drupal\FunctionalTests\InstallerView source
class DistributionProfileTest extends InstallerTestBase {
/**
* The distribution profile info.
*
* @var array
*/
protected $info;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
protected function prepareEnvironment() {
parent::prepareEnvironment();
$this->info = [
'type' => 'profile',
'core_version_requirement' => '*',
'name' => 'Distribution profile',
'distribution' => [
'name' => 'My Distribution',
'install' => [
'theme' => 'claro',
'finish_url' => '/root-user',
],
],
];
// File API functions are not available yet.
$path = $this->siteDirectory . '/profiles/my_distro';
mkdir($path, 0777, TRUE);
file_put_contents("{$path}/my_distro.info.yml", Yaml::encode($this->info));
file_put_contents("{$path}/my_distro.install", "<?php function my_distro_install() {\\Drupal::entityTypeManager()->getStorage('path_alias')->create(['path' => '/user/1', 'alias' => '/root-user'])->save();}");
}
/**
* {@inheritdoc}
*/
protected function setUpLanguage() {
// Verify that the distribution name appears.
$this->assertSession()
->pageTextContains($this->info['distribution']['name']);
// Verify that the distribution name is used in the site title.
$this->assertSession()
->titleEquals('Choose language | ' . $this->info['distribution']['name']);
// Verify that the requested theme is used.
$this->assertSession()
->responseContains($this->info['distribution']['install']['theme']);
// Verify that the "Choose profile" step does not appear.
$this->assertSession()
->pageTextNotContains('profile');
parent::setUpLanguage();
}
/**
* {@inheritdoc}
*/
protected function setUpProfile() {
// This step is skipped, because there is a distribution profile.
}
/**
* Confirms that the installation succeeded.
*/
public function testInstalled() {
$this->assertSession()
->addressEquals('root-user');
$this->assertSession()
->statusCodeEquals(200);
// Confirm that we are logged-in after installation.
$this->assertSession()
->pageTextContains($this->rootUser
->getAccountName());
// Confirm that Drupal recognizes this distribution as the current profile.
$this->assertEquals('my_distro', \Drupal::installProfile());
$this->assertEquals('my_distro', $this->config('core.extension')
->get('profile'), 'The install profile has been written to core.extension configuration.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.