You are here

public function MetatagTestBase::addSiteLanguage in Metatag 7

Add a locale to the site.

This assumes the Locale module is enabled.

Parameters

string $langcode: The language code to add.

2 calls to MetatagTestBase::addSiteLanguage()
MetatagHreflangTagsTest::setUp in metatag_hreflang/tests/MetatagHreflangTagsTest.test
Sets up a Drupal site for running functional and integration tests.
MetatagTestBase::setupLocales in tests/MetatagTestBase.test
Set up a basic starting point for the locales.

File

tests/MetatagTestBase.test, line 265
A base class for the Metatag tests, provides shared methods.

Class

MetatagTestBase
A base class for the Metatag tests, provides shared methods.

Code

public function addSiteLanguage($langcode) {

  // Load the language-add page.
  $this
    ->drupalGet('admin/config/regional/language/add');
  $this
    ->assertResponse(200, 'Loaded the language-add admin page.');

  // Submit the language-add form.
  $args = array(
    'langcode' => $langcode,
  );
  $this
    ->drupalPost(NULL, $args, t('Add language'));
  $this
    ->assertResponse(200);

  // Verify that the browser was returned to the main languages admin page.
  $this
    ->assertEqual($this
    ->getUrl(), url('admin/config/regional/language', array(
    'absolute' => TRUE,
  )), 'Redirected back to the main languages admin page.');

  // Clear the language list cache so it can be reloaded.
  drupal_static_reset('language_list');

  // Get all language definitions.
  $languages = language_list();
  $language = $languages[$langcode]->name;
  $this
    ->assertText(strip_tags(t('The language %language has been created and can now be used. More information is available on the <a href="@locale-help">help screen</a>.', array(
    '%language' => t($language),
    '@locale-help' => url('admin/help/locale'),
  ))), 'A new language has been added.');
}