class PathLanguageUITestCase
Tests the user interface for creating path aliases, with languages.
Hierarchy
- class \DrupalTestCase
- class \DrupalWebTestCase implements \DrupalTestCase
- class \PathLanguageUITestCase implements \DrupalWebTestCase
- class \DrupalWebTestCase implements \DrupalTestCase
Expanded class hierarchy of PathLanguageUITestCase
File
-
modules/
path/ path.test, line 483
View source
class PathLanguageUITestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Path aliases with languages',
'description' => 'Confirm that the Path module user interface works with languages.',
'group' => 'Path',
);
}
function setUp() {
parent::setUp('path', 'locale');
// Create and login user.
$web_user = $this->drupalCreateUser(array(
'edit any page content',
'create page content',
'administer url aliases',
'create url aliases',
'administer languages',
'access administration pages',
));
$this->drupalLogin($web_user);
// Enable French language.
$edit = array();
$edit['langcode'] = 'fr';
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
// Enable URL language detection and selection.
$edit = array(
'language[enabled][locale-url]' => 1,
);
$this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
}
/**
* Tests that a language-neutral URL alias works.
*/
function testLanguageNeutralURLs() {
$name = $this->randomName(8);
$edit = array();
$edit['source'] = 'admin/config/search/path';
$edit['alias'] = $name;
$this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
$this->drupalGet($name);
$this->assertText(t('Filter aliases'), 'Language-neutral URL alias works');
}
/**
* Tests that a default language URL alias works.
*/
function testDefaultLanguageURLs() {
$name = $this->randomName(8);
$edit = array();
$edit['source'] = 'admin/config/search/path';
$edit['alias'] = $name;
$edit['language'] = 'en';
$this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
$this->drupalGet($name);
$this->assertText(t('Filter aliases'), 'English URL alias works');
}
/**
* Tests that a non-default language URL alias works.
*/
function testNonDefaultURLs() {
$name = $this->randomName(8);
$edit = array();
$edit['source'] = 'admin/config/search/path';
$edit['alias'] = $name;
$edit['language'] = 'fr';
$this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
$this->drupalGet('fr/' . $name);
$this->assertText(t('Filter aliases'), 'Foreign URL alias works');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.