setUpLanguage example


  protected function setUpLanguage() {
    // Verify that the distribution name appears.     $this->assertSession()->pageTextContains($this->info['distribution']['name']);
    // Verify that the distribution name is used in the site title.     $this->assertSession()->titleEquals('Choose language | ' . $this->info['distribution']['name']);
    // Verify that the requested theme is used.     $this->assertSession()->responseContains($this->info['distribution']['install']['theme']);
    // Verify that the "Choose profile" step does not appear.     $this->assertSession()->pageTextNotContains('profile');

    parent::setUpLanguage();
  }

  /** * {@inheritdoc} */
  protected function setUpProfile() {
    // This step is skipped, because there is a distribution profile.   }

  /** * Confirms that the installation succeeded. */

  protected $langcode = 'ar';

  /** * {@inheritdoc} */
  protected function setUpLanguage() {
    // Place a custom local translation in the translations directory.     mkdir($this->root . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
    file_put_contents($this->root . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.ar.po', "msgid \"\"\nmsgstr \"\"\nmsgid \"Save and continue\"\nmsgstr \"Save and continue Arabic\"");

    parent::setUpLanguage();
    // After selecting a different language than English, all following screens     // should be translated already.     $this->assertSession()->buttonExists('Save and continue Arabic');
    $this->translations['Save and continue'] = 'Save and continue Arabic';

    // Verify that language direction is right-to-left.     $this->assertSession()->elementTextEquals('xpath', '/@dir', 'rtl');
  }

  /** * Confirms that the installation succeeded. */
// Make the settings file read-only.     // Not using File API; a potential error must trigger a PHP warning.     chmod($filename, 0444);

    // Verify that the distribution name appears.     $this->assertSession()->pageTextContains($this->info['distribution']['name']);
    // Verify that the requested theme is used.     $this->assertSession()->responseContains($this->info['distribution']['install']['theme']);
    // Verify that the "Choose profile" step does not appear.     $this->assertSession()->pageTextNotContains('profile');

    parent::setUpLanguage();
  }

  /** * {@inheritdoc} */
  protected function setUpProfile() {
    // This step is skipped, because there is a distribution profile.   }

  /** * {@inheritdoc} */
\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.     $this->setUpSettings();

    // @todo Allow test classes based on this class to act on further installer
/** * 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 setUpLanguage() {
    // Place custom local translations in the translations directory.     mkdir(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
    $po_contents = <<<ENDPO msgid "" msgstr "" ENDPO;
    // Create a misnamed translation file that     // \Drupal\Core\StringTranslation\Translator\FileTranslation::findTranslationFiles()     // will not find.     file_put_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0-DEV.xx-lolspeak.po', $po_contents);
    parent::setUpLanguage();
  }

  /** * {@inheritdoc} */
  protected function setUpProfile() {
    // Do nothing, because this test only tests the language installation     // step's results.   }

  /** * {@inheritdoc} */
/** * Overrides the language code in which to install Drupal. * * @var string */
  protected $langcode = 'de';

  /** * {@inheritdoc} */
  protected function setUpLanguage() {
    parent::setUpLanguage();
    $this->translations['Save and continue'] = 'Save and continue de';
  }

}
protected $profile = 'testing_multilingual';

  /** * {@inheritdoc} */
  protected function setUpLanguage() {
    // Place custom local translations in the translations directory.     mkdir(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
    file_put_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', $this->getPo('de'));
    file_put_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.es.po', $this->getPo('es'));

    parent::setUpLanguage();
  }

  /** * Returns the string for the test .po file. * * @param string $langcode * The language code. * * @return string * Contents for the test .po file. */
  


  /** * {@inheritdoc} */
  protected function setUpLanguage() {
    // Place custom local translations in the translations directory to avoid     // getting translations from localize.drupal.org.     mkdir(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
    file_put_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.es.po', $this->getPo('es'));

    parent::setUpLanguage();
  }

  /** * Returns the string for the test .po file. * * @param string $langcode * The language code. * * @return string * Contents for the test .po file. */
  

  protected function setUpLanguage() {
    // Test that \Drupal\Core\Render\BareHtmlPageRenderer adds assets and     // metatags as expected to the first page of the installer.     $this->assertSession()->responseContains("css/components/button.css");
    $this->assertSession()->responseContains('<meta charset="utf-8" />');

    // Assert that the expected title is present.     $this->assertEquals('Choose language', $this->cssSelect('main h2')[0]->getText());

    parent::setUpLanguage();
  }

  /** * {@inheritdoc} */
  protected function setUpProfile() {
    $settings_services_file = DRUPAL_ROOT . '/sites/default/default.services.yml';
    // Copy the testing-specific service overrides in place.     copy($settings_services_file$this->siteDirectory . '/services.yml');
    PerformanceTestRecorder::registerService($this->siteDirectory . '/services.yml', TRUE);
    // Assert that the expected title is present.

class InstallerExistingConfigTest extends InstallerExistingConfigTestBase {

  /** * {@inheritdoc} */
  protected function setUpLanguage() {
    // Place a custom local translation in the translations directory.     mkdir($this->root . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
    file_put_contents($this->root . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.fr.po', "msgid \"\"\nmsgstr \"\"\nmsgid \"Save and continue\"\nmsgstr \"Enregistrer et continuer\"");
    parent::setUpLanguage();
  }

  /** * {@inheritdoc} */
  public function setUpSettings() {
    // The configuration is from a site installed in French.     // So after selecting the profile the installer detects that the site must     // be installed in French, thus we change the button translation.     $this->translations['Save and continue'] = 'Enregistrer et continuer';
    parent::setUpSettings();
  }

  protected $profile = 'standard';

  /** * {@inheritdoc} */
  protected function setUpLanguage() {
    // Place custom local translations in the translations directory.     mkdir(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
    file_put_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.eo.po', $this->getPo('eo'));

    parent::setUpLanguage();

    $this->translations['Save and continue'] = 'Save and continue eo';
  }

  /** * Returns the string for the test .po file. * * @param string $langcode * The language code. * * @return string * Contents for the test .po file. */
/** * {@inheritdoc} */
  protected function setUpLanguage() {
    // Verify that the distribution name appears.     $this->assertSession()->pageTextContains('distribution_one');
    // Verify that the requested theme is used.     $this->assertSession()->responseContains('claro');
    // Verify that the "Choose profile" step does not appear.     $this->assertSession()->pageTextNotContains('profile');

    parent::setUpLanguage();
  }

  /** * {@inheritdoc} */
  protected function setUpProfile() {
    // This step is skipped, because there is a distribution profile.   }

  /** * Confirms that the installation succeeded. */
// 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();
  }

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

}

  protected $langcode = 'de';

  /** * {@inheritdoc} */
  protected function setUpLanguage() {
    // Place a custom local translation in the translations directory.     mkdir($this->root . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
    file_put_contents($this->root . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.de.po', $this->getPo('de'));

    parent::setUpLanguage();

    // After selecting a different language than English, all following screens     // should be translated already.     $this->assertSession()->buttonExists('Save and continue de');
    $this->translations['Save and continue'] = 'Save and continue de';

    // Check the language direction.     $this->assertSession()->elementTextEquals('xpath', '/@dir', 'ltr');
  }

  /** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.