InstallerTest.php in Drupal 9
File
core/tests/Drupal/FunctionalTests/Installer/InstallerTest.php
View source
<?php
namespace Drupal\FunctionalTests\Installer;
use Drupal\Core\Routing\RoutingEvents;
use Drupal\Core\Test\PerformanceTestRecorder;
class InstallerTest extends InstallerTestBase {
protected $defaultTheme = 'stark';
public function testInstaller() {
$this
->assertNotNull(\Drupal::state()
->get('system.css_js_query_string'), 'The dummy query string should be set during install');
$this
->assertSession()
->addressEquals('user/1');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains($this->rootUser
->getAccountName());
require_once $this->root . '/core/includes/install.inc';
$this
->assertSession()
->pageTextContains('Congratulations, you installed Drupal!');
$this
->assertEquals('Australia/Sydney', $this
->config('system.date')
->get('timezone.default'));
$module_extension_list = \Drupal::service('extension.list.module');
$extensions = $module_extension_list
->getList();
$this
->assertArrayHasKey('testing', $extensions);
$this
->assertEquals(1000, $extensions['testing']->weight);
$this
->assertSame(1, \Drupal::service('core.performance.test.recorder')
->getCount('event', RoutingEvents::FINISHED));
}
protected function setUpLanguage() {
$this
->assertSession()
->responseContains("core/themes/seven/css/components/buttons.css");
$this
->assertSession()
->responseContains('<meta charset="utf-8" />');
$this
->assertEquals('Choose language', $this
->cssSelect('main h2')[0]
->getText());
parent::setUpLanguage();
}
protected function setUpProfile() {
$settings_services_file = DRUPAL_ROOT . '/sites/default/default.services.yml';
copy($settings_services_file, $this->siteDirectory . '/services.yml');
PerformanceTestRecorder::registerService($this->siteDirectory . '/services.yml', TRUE);
$this
->assertEquals('Select an installation profile', $this
->cssSelect('main h2')[0]
->getText());
$this
->assertSession()
->elementsCount('xpath', "//span[contains(@class, 'visually-hidden') and contains(text(), 'Select an installation profile')]", 1);
parent::setUpProfile();
}
protected function setUpSettings() {
$this
->assertEquals('Database configuration', $this
->cssSelect('main h2')[0]
->getText());
$this
->assertSession()
->elementTextEquals('xpath', '//label[@for="edit-driver-mysql"]', 'MySQL, MariaDB, Percona Server, or equivalent');
$this
->assertSession()
->elementTextEquals('xpath', '//label[@for="edit-driver-pgsql"]', 'PostgreSQL');
parent::setUpSettings();
}
protected function setUpSite() {
$this
->assertEquals('Configure site', $this
->cssSelect('main h2')[0]
->getText());
$site_directory = $this->container
->getParameter('app.root') . '/' . $this->siteDirectory;
$this
->assertDirectoryIsNotWritable($site_directory);
$this
->assertFileIsNotWritable($site_directory . '/settings.php');
parent::setUpSite();
}
protected function visitInstaller() {
parent::visitInstaller();
$this
->assertSession()
->titleEquals('Choose language | Drupal');
}
}