You are here

protected function LanguagePathMonolingualTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/language/src/Tests/LanguagePathMonolingualTest.php \Drupal\language\Tests\LanguagePathMonolingualTest::setUp()

Sets up a Drupal site for running functional and integration tests.

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Overrides WebTestBase::setUp

File

core/modules/language/src/Tests/LanguagePathMonolingualTest.php, line 26
Contains \Drupal\language\Tests\LanguagePathMonolingualTest.

Class

LanguagePathMonolingualTest
Confirm that paths are not changed on monolingual non-English sites.

Namespace

Drupal\language\Tests

Code

protected function setUp() {
  parent::setUp();

  // Create and login user.
  $web_user = $this
    ->drupalCreateUser(array(
    'administer languages',
    'access administration pages',
    'administer site configuration',
  ));
  $this
    ->drupalLogin($web_user);

  // Enable French language.
  $edit = array();
  $edit['predefined_langcode'] = 'fr';
  $this
    ->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));

  // Make French the default language.
  $edit = array(
    'site_default_language' => 'fr',
  );
  $this
    ->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration'));

  // Delete English.
  $this
    ->drupalPostForm('admin/config/regional/language/delete/en', array(), t('Delete'));

  // Changing the default language causes a container rebuild. Therefore need
  // to rebuild the container in the test environment.
  $this
    ->rebuildContainer();

  // Verify that French is the only language.
  $this->container
    ->get('language_manager')
    ->reset();
  $this
    ->assertFalse(\Drupal::languageManager()
    ->isMultilingual(), 'Site is mono-lingual');
  $this
    ->assertEqual(\Drupal::languageManager()
    ->getDefaultLanguage()
    ->getId(), 'fr', 'French is the default language');

  // Set language detection to URL.
  $edit = array(
    'language_interface[enabled][language-url]' => TRUE,
  );
  $this
    ->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
  $this
    ->drupalPlaceBlock('local_actions_block');
}