You are here

public function SelectProfileFormTest::setUp in Drupal 8

Overrides BrowserTestBase::setUp

File

core/tests/Drupal/FunctionalJavascriptTests/Core/Installer/Form/SelectProfileFormTest.php, line 25

Class

SelectProfileFormTest
Tests the select profile form.

Namespace

Drupal\FunctionalJavascriptTests\Core\Installer\Form

Code

public function setUp() {
  $this
    ->setupBaseUrl();
  $this
    ->prepareDatabasePrefix();

  // Install Drupal test site.
  $this
    ->prepareEnvironment();

  // Define information about the user 1 account.
  $this->rootUser = new UserSession([
    'uid' => 1,
    'name' => 'admin',
    'mail' => 'admin@example.com',
    'pass_raw' => $this
      ->randomMachineName(),
  ]);

  // If any $settings are defined for this test, copy and prepare an actual
  // settings.php, so as to resemble a regular installation.
  if (!empty($this->settings)) {

    // Not using File API; a potential error must trigger a PHP warning.
    copy(DRUPAL_ROOT . '/sites/default/default.settings.php', DRUPAL_ROOT . '/' . $this->siteDirectory . '/settings.php');
    $this
      ->writeSettings($this->settings);
  }

  // Note that FunctionalTestSetupTrait::installParameters() returns form
  // input values suitable for a programmed
  // \Drupal::formBuilder()->submitForm().
  // @see InstallerTestBase::translatePostValues()
  $this->parameters = $this
    ->installParameters();

  // Set up a minimal container (required by BrowserTestBase). Set cookie and
  // server information so that XDebug works.
  // @see install_begin_request()
  $request = Request::create($GLOBALS['base_url'] . '/core/install.php', 'GET', [], $_COOKIE, [], $_SERVER);
  $this->container = new ContainerBuilder();
  $request_stack = new RequestStack();
  $request_stack
    ->push($request);
  $this->container
    ->set('request_stack', $request_stack);
  $this->container
    ->setParameter('language.default_values', Language::$defaultValues);
  $this->container
    ->register('language.default', 'Drupal\\Core\\Language\\LanguageDefault')
    ->addArgument('%language.default_values%');
  $this->container
    ->register('string_translation', 'Drupal\\Core\\StringTranslation\\TranslationManager')
    ->addArgument(new Reference('language.default'));
  $this->container
    ->register('http_client', 'GuzzleHttp\\Client')
    ->setFactory('http_client_factory:fromOptions');
  $this->container
    ->register('http_client_factory', 'Drupal\\Core\\Http\\ClientFactory')
    ->setArguments([
    new Reference('http_handler_stack'),
  ]);
  $handler_stack = HandlerStack::create();
  $test_http_client_middleware = new TestHttpClientMiddleware();
  $handler_stack
    ->push($test_http_client_middleware(), 'test.http_client.middleware');
  $this->container
    ->set('http_handler_stack', $handler_stack);
  $this->container
    ->set('app.root', DRUPAL_ROOT);
  \Drupal::setContainer($this->container);

  // Setup Mink.
  $this
    ->initMink();
}