MultipleDistributionsProfileTest.php in Drupal 9
File
core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php
View source
<?php
namespace Drupal\FunctionalTests\Installer;
use Drupal\Component\Serialization\Yaml;
class MultipleDistributionsProfileTest extends InstallerTestBase {
protected $info;
protected $defaultTheme = 'stark';
protected function prepareEnvironment() {
parent::prepareEnvironment();
foreach ([
'distribution_one',
'distribution_two',
] as $name) {
$info = [
'type' => 'profile',
'core_version_requirement' => '*',
'name' => $name . ' profile',
'distribution' => [
'name' => $name,
'install' => [
'theme' => 'bartik',
],
],
];
$path = $this->root . DIRECTORY_SEPARATOR . $this->siteDirectory . '/profiles/' . $name;
mkdir($path, 0777, TRUE);
file_put_contents("{$path}/{$name}.info.yml", Yaml::encode($info));
}
$this->profile = 'distribution_one';
}
protected function setUpLanguage() {
$this
->assertSession()
->pageTextContains('distribution_one');
$this
->assertSession()
->responseContains('bartik');
$this
->assertSession()
->pageTextNotContains('profile');
parent::setUpLanguage();
}
protected function setUpProfile() {
}
public function testInstalled() {
$this
->assertSession()
->addressEquals('user/1');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains($this->rootUser
->getAccountName());
$this
->assertEquals('distribution_one', \Drupal::installProfile());
$this
->assertEquals('distribution_one', $this
->config('core.extension')
->get('profile'), 'The install profile has been written to core.extension configuration.');
$this
->rebuildContainer();
$this
->assertEquals('distribution_one', \Drupal::installProfile());
}
}