3 namespace Drupal\FunctionalJavascriptTests\Core\Installer\Form;
5 use Drupal\Core\DependencyInjection\ContainerBuilder;
6 use Drupal\Core\Language\Language;
7 use Drupal\Core\Session\UserSession;
8 use Drupal\Core\Test\HttpClientMiddleware\TestHttpClientMiddleware;
9 use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
10 use GuzzleHttp\HandlerStack;
11 use Symfony\Component\DependencyInjection\Reference;
12 use Symfony\Component\HttpFoundation\Request;
13 use Symfony\Component\HttpFoundation\RequestStack;
16 * Tests the select profile form.
20 class SelectProfileFormTest extends JavascriptTestBase {
25 public function setUp() {
26 $this->setupBaseUrl();
28 $this->prepareDatabasePrefix();
30 // Install Drupal test site.
31 $this->prepareEnvironment();
33 // Define information about the user 1 account.
34 $this->rootUser = new UserSession([
37 'mail' => 'admin@example.com',
38 'pass_raw' => $this->randomMachineName(),
41 // If any $settings are defined for this test, copy and prepare an actual
42 // settings.php, so as to resemble a regular installation.
43 if (!empty($this->settings)) {
44 // Not using File API; a potential error must trigger a PHP warning.
45 copy(DRUPAL_ROOT . '/sites/default/default.settings.php', DRUPAL_ROOT . '/' . $this->siteDirectory . '/settings.php');
46 $this->writeSettings($this->settings);
49 // Note that FunctionalTestSetupTrait::installParameters() returns form
50 // input values suitable for a programmed
51 // \Drupal::formBuilder()->submitForm().
52 // @see InstallerTestBase::translatePostValues()
53 $this->parameters = $this->installParameters();
55 // Set up a minimal container (required by BrowserTestBase). Set cookie and
56 // server information so that XDebug works.
57 // @see install_begin_request()
58 $request = Request::create($GLOBALS['base_url'] . '/core/install.php', 'GET', [], $_COOKIE, [], $_SERVER);
59 $this->container = new ContainerBuilder();
60 $request_stack = new RequestStack();
61 $request_stack->push($request);
63 ->set('request_stack', $request_stack);
65 ->setParameter('language.default_values', Language::$defaultValues);
67 ->register('language.default', 'Drupal\Core\Language\LanguageDefault')
68 ->addArgument('%language.default_values%');
70 ->register('string_translation', 'Drupal\Core\StringTranslation\TranslationManager')
71 ->addArgument(new Reference('language.default'));
73 ->register('http_client', 'GuzzleHttp\Client')
74 ->setFactory('http_client_factory:fromOptions');
76 ->register('http_client_factory', 'Drupal\Core\Http\ClientFactory')
77 ->setArguments([new Reference('http_handler_stack')]);
78 $handler_stack = HandlerStack::create();
79 $test_http_client_middleware = new TestHttpClientMiddleware();
80 $handler_stack->push($test_http_client_middleware(), 'test.http_client.middleware');
82 ->set('http_handler_stack', $handler_stack);
85 ->set('app.root', DRUPAL_ROOT);
86 \Drupal::setContainer($this->container);
95 protected function initMink() {
96 // The temporary files directory doesn't exist yet, as install_base_system()
97 // has not run. We need to create the template cache directory recursively.
98 $path = $this->tempFilesDirectory . DIRECTORY_SEPARATOR . 'browsertestbase-templatecache';
99 if (!file_exists($path)) {
100 mkdir($path, 0777, TRUE);
109 * BrowserTestBase::refreshVariables() tries to operate on persistent storage,
110 * which is only available after the installer completed.
112 protected function refreshVariables() {
113 // Intentionally empty as the site is not yet installed.
117 * Tests a warning message is displayed when the Umami profile is selected.
119 public function testUmamiProfileWarningMessage() {
120 $this->drupalGet($GLOBALS['base_url'] . '/core/install.php');
124 $this->drupalPostForm(NULL, $edit, 'Save and continue');
125 $page = $this->getSession()->getPage();
126 $warning_message = $page->find('css', '.description .messages--warning');
127 $this->assertFalse($warning_message->isVisible());
128 $page->selectFieldOption('profile', 'demo_umami');
129 $this->assertTrue($warning_message->isVisible());