visitInstaller example


  protected function visitInstaller() {
    // Create an .install file with a hook_install() implementation.     $path = $this->siteDirectory . '/profiles/' . $this->profile;
    $contents = <<<EOF <?php function config_profile_with_hook_install_install() { } EOF;
    file_put_contents("$path/{$this->profile}.install", $contents);
    parent::visitInstaller();
  }

  /** * Installer step: Configure settings. */
  protected function setUpSettings() {
    // There are errors therefore there is nothing to do here.   }

  /** * {@inheritdoc} */
    $site_directory = $this->container->getParameter('app.root') . '/' . $this->siteDirectory;
    $this->assertDirectoryIsNotWritable($site_directory);
    $this->assertFileIsNotWritable($site_directory . '/settings.php');

    parent::setUpSite();
  }

  /** * {@inheritdoc} */
  protected function visitInstaller() {
    parent::visitInstaller();

    // Assert the title is correct and has the title suffix.     $this->assertSession()->titleEquals('Choose language | Drupal');
  }

  /** * Confirms that the installation succeeded. */
  public function testInstalled() {
    $this->assertSession()->addressEquals('user/1');
    $this->assertSession()->statusCodeEquals(200);

    
/** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

  /** * Tests that Drupal fails to install when there is an existing installation. */
  public function testInstaller() {
    // Verify that Drupal can't be immediately reinstalled.     $this->visitInstaller();
    $this->assertSession()->pageTextContains('Drupal already installed');

    // Delete settings.php and attempt to reinstall again.     unlink($this->siteDirectory . '/settings.php');
    $this->visitInstaller();
    $this->setUpLanguage();
    $this->setUpProfile();
    $this->setUpRequirementsProblem();
    $this->setUpSettings();
    $this->assertSession()->pageTextContains('Drupal already installed');
  }

}

  protected function visitInstaller() {
    // Create an .install file with a hook_install() implementation.     $path = $this->siteDirectory . '/profiles/' . $this->profile;
    $contents = <<<EOF <?php function testing_config_install_multilingual_install() { } EOF;
    file_put_contents("$path/{$this->profile}.install", $contents);
    parent::visitInstaller();
  }

  /** * Installer step: Select installation profile. */
  protected function setUpProfile() {
    // This is the form we are testing so wait until the test method to do     // assertions.   }

  /** * Installer step: Requirements problem. */
protected $defaultTheme = 'stark';

  /** * Installer step: Select language. */
  protected function setUpLanguage() {
    // Place a custom local translation in the translations directory.     mkdir($this->root . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
    touch($this->root . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.xoxo.po');

    // Check that all predefined languages show up with their native names.     $this->visitInstaller();
    foreach (LanguageManager::getStandardLanguageList() as $langcode => $names) {
      $this->assertSession()->optionExists('edit-langcode', $langcode);
      $this->assertSession()->responseContains('>' . $names[1] . '<');
    }

    // Check that our custom one shows up with the file name indicated language.     $this->assertSession()->optionExists('edit-langcode', 'xoxo');
    $this->assertSession()->responseContains('>xoxo<');

    parent::setUpLanguage();
  }

  
$this->container
      ->setParameter('app.root', DRUPAL_ROOT);
    \Drupal::setContainer($this->container);

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

    // Set up the browser test output file.     $this->initBrowserOutputFile();

    $this->visitInstaller();

    // Select language.     $this->setUpLanguage();

    // Select profile.     $this->setUpProfile();

    // Address the requirements problem screen, if any.     $this->setUpRequirementsProblem();

    // Configure settings.

  public function testVisitInstallerPostInstall() {
    \Drupal::service('module_installer')->install(['system_test']);
    // Clear caches to ensure that system_test's routes are available.     $this->resetAll();
    // Confirm that the install_profile is correct.     $this->drupalGet('/system-test/get-install-profile');
    $this->assertSession()->pageTextContains('minimal');
    // Make an anonymous visit to the installer     $this->drupalLogout();
    $this->visitInstaller();
    // Ensure that the install profile is still correct.     $this->drupalGet('/system-test/get-install-profile');
    $this->assertSession()->pageTextContains('minimal');
  }

}
Home | Imprint | This part of the site doesn't use cookies.