Commit 969e670e authored by catch's avatar catch

Issue #1546752 by Gábor Hojtsy, erno, xjm: Move negotiation tests to language module.

parent 9e2223c5
This diff is collapsed.
name = "Locale Test"
description = "Support module for the locale layer tests."
name = "Language test"
description = "Support module for the language layer tests."
core = 8.x
package = Testing
version = VERSION
......
......@@ -2,7 +2,7 @@
/**
* @file
* Mock module for locale layer tests.
* Mock module for language layer tests.
*/
/**
......@@ -11,17 +11,17 @@
* For testing domain language negotiation, we fake it by setting
* the HTTP_HOST here
*/
function locale_test_boot() {
if (variable_get('locale_test_domain')) {
$_SERVER['HTTP_HOST'] = variable_get('locale_test_domain');
function language_test_boot() {
if (variable_get('language_test_domain')) {
$_SERVER['HTTP_HOST'] = variable_get('language_test_domain');
}
}
/**
* Implements hook_init().
*/
function locale_test_init() {
locale_test_store_language_negotiation();
function language_test_init() {
language_test_store_language_negotiation();
if (isset(drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->langcode) && isset(drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->method_id)) {
drupal_set_message(t('Language negotiation method: @name', array('@name' => drupal_container()->get(LANGUAGE_TYPE_INTERFACE)->method_id)));
}
......@@ -30,8 +30,8 @@ function locale_test_init() {
/**
* Implements hook_language_types_info().
*/
function locale_test_language_types_info() {
if (variable_get('locale_test_language_types', FALSE)) {
function language_test_language_types_info() {
if (variable_get('language_test_language_types', FALSE)) {
return array(
'test_language_type' => array(
'name' => t('Test'),
......@@ -47,8 +47,8 @@ function locale_test_language_types_info() {
/**
* Implements hook_language_types_info_alter().
*/
function locale_test_language_types_info_alter(array &$language_types) {
if (variable_get('locale_test_content_language_type', FALSE)) {
function language_test_language_types_info_alter(array &$language_types) {
if (variable_get('language_test_content_language_type', FALSE)) {
unset($language_types[LANGUAGE_TYPE_CONTENT]['fixed']);
}
}
......@@ -56,13 +56,13 @@ function locale_test_language_types_info_alter(array &$language_types) {
/**
* Implements hook_language_negotiation_info().
*/
function locale_test_language_negotiation_info() {
if (variable_get('locale_test_language_negotiation_info', FALSE)) {
function language_test_language_negotiation_info() {
if (variable_get('language_test_language_negotiation_info', FALSE)) {
$info = array(
'callbacks' => array(
'negotiation' => 'locale_test_language_negotiation_method',
'negotiation' => 'language_test_language_negotiation_method',
),
'file' => drupal_get_path('module', 'locale_test') .'/locale_test.module',
'file' => drupal_get_path('module', 'language_test') .'/language_test.module',
'weight' => -10,
'description' => t('This is a test language negotiation method.'),
);
......@@ -83,8 +83,8 @@ function locale_test_language_negotiation_info() {
/**
* Implements hook_language_negotiation_info_alter().
*/
function locale_test_language_negotiation_info_alter(array &$negotiation_info) {
if (variable_get('locale_test_language_negotiation_info_alter', FALSE)) {
function language_test_language_negotiation_info_alter(array &$negotiation_info) {
if (variable_get('language_test_language_negotiation_info_alter', FALSE)) {
unset($negotiation_info[LANGUAGE_NEGOTIATION_INTERFACE]);
}
}
......@@ -92,17 +92,17 @@ function locale_test_language_negotiation_info_alter(array &$negotiation_info) {
/**
* Store the last negotiated languages.
*/
function locale_test_store_language_negotiation() {
function language_test_store_language_negotiation() {
$last = array();
foreach (language_types_get_all() as $type) {
$last[$type] = $GLOBALS[$type]->langcode;
}
variable_set('locale_test_language_negotiation_last', $last);
variable_set('language_test_language_negotiation_last', $last);
}
/**
* Provides a test language negotiation method.
*/
function locale_test_language_negotiation_method($languages) {
function language_test_language_negotiation_method($languages) {
return 'it';
}
This diff is collapsed.
......@@ -517,63 +517,3 @@ class PathLanguageUITestCase extends PathTestCase {
}
}
/**
* Tests that paths are not prefixed on a monolingual site.
*/
class PathMonolingualTestCase extends PathTestCase {
public static function getInfo() {
return array(
'name' => 'Paths on non-English monolingual sites',
'description' => 'Confirm that paths are not changed on monolingual non-English sites',
'group' => 'Path',
);
}
function setUp() {
parent::setUp('path', 'locale', 'translation');
// Create and login user.
$web_user = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
$this->drupalLogin($web_user);
// Enable French language.
$edit = array();
$edit['predefined_langcode'] = 'fr';
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
// Make French the default language.
$edit = array('site_default' => 'fr');
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
// Delete English.
$this->drupalPost('admin/config/regional/language/delete/en', array(), t('Delete'));
// Verify that French is the only language.
$this->assertFalse(language_multilingual(), t('Site is mono-lingual'));
$this->assertEqual(language_default()->langcode, 'fr', t('French is the default language'));
// Set language detection to URL.
$edit = array('language_interface[enabled][language-url]' => TRUE);
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
// Force languages to be initialized.
drupal_language_initialize();
}
/**
* Verifies that links do not have language prefixes in them.
*/
function testPageLinks() {
// Navigate to 'admin/config' path.
$this->drupalGet('admin/config');
// Verify that links in this page do not have a 'fr/' prefix.
$this->assertNoLinkByHref('/fr/', 'Links do not contain language prefix');
// Verify that links in this page can be followed and work.
$this->clickLink(t('Languages'));
$this->assertResponse(200, 'Clicked link results in a valid page');
$this->assertText(t('Add language'), 'Page contains the add language text');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment