You are here

protected function EckTestHelper::setupLocales in Entity Construction Kit (ECK) 7.2

Set up a basic starting point for the locales.

This assumes the Locale module is enabled. This also must be done before other user accounts are logged in.

Parameters

array $locales: A list of locales to be enabled, in langcode format.

1 call to EckTestHelper::setupLocales()
EckEntityTranslationTest::setUp in tests/EckEntityTranslationTest.test
Sets up a Drupal site for running functional and integration tests.

File

tests/EckTestHelper.test, line 215
The EckTestHelper class.

Class

EckTestHelper
Helper logic for the other ECK tests.

Code

protected function setupLocales(array $locales = array()) {

  // If no locales were requested, add Spanish and French.
  if (empty($locales)) {
    $locales[] = 'es';
    $locales[] = 'fr';
  }

  // Identify the site's default language.
  $default_language = language_default('language');

  // Add the locales.
  foreach ($locales as $langcode) {

    // Don't create the default language, it's already present.
    if ($langcode != $default_language) {
      $this
        ->addSiteLanguage($langcode);
    }
  }

  // Enable URL language detection and selection.
  $this
    ->drupalGet('admin/config/regional/language/configure');
  $this
    ->assertResponse(200);
  $edit = array(
    'language[enabled][locale-url]' => TRUE,
    'language_content[enabled][locale-url]' => TRUE,
  );
  $this
    ->drupalPost(NULL, $edit, t('Save settings'));
  $this
    ->assertResponse(200);
}