public function LinkPathPrefixesTest::setUpLanguage in Link 7
Enables and configured language related stuff.
1 call to LinkPathPrefixesTest::setUpLanguage()
- LinkPathPrefixesTest::testLanguagePrefixedPaths in tests/
LinkPathPrefixesTest.test - Creates a link field, fills it, then uses a loaded node to test paths.
File
- tests/
LinkPathPrefixesTest.test, line 39 - Tests that exercise the relative / absolute output of the link module.
Class
- LinkPathPrefixesTest
- Testing that absolute / relative outputs match the expected format.
Code
public function setUpLanguage() {
global $language_url;
$this
->drupalGet('admin/config/regional/language');
// Enable the path prefix for the default language: this way any un-prefixed
// URL must have a valid fallback value.
$edit = array(
'prefix' => 'en',
);
$this
->drupalPost('admin/config/regional/language/edit/en', $edit, t('Save language'));
$language_url->prefix = $language_url->language;
// Add custom language - as we need more than 1 language to be multilingual.
// Code for the language.
$langcode = 'xx';
// The English name for the language.
$name = $this
->randomName(16);
// The native name for the language.
$native = $this
->randomName(16);
$edit = array(
'langcode' => $langcode,
'name' => $name,
'native' => $native,
'prefix' => $langcode,
'direction' => '0',
);
$this
->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
variable_set('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX);
// Enable URL language detection and selection.
$edit = array(
'language[enabled][locale-url]' => 1,
);
$this
->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
language_negotiation_set(LANGUAGE_TYPE_INTERFACE, array(
LOCALE_LANGUAGE_NEGOTIATION_URL,
));
// Reset static caching.
drupal_static_reset('language_list');
drupal_static_reset('locale_url_outbound_alter');
drupal_static_reset('locale_language_url_rewrite_url');
}