| 7 translation.test | TranslationTestCase::setUp() |
| 8 translation.test | TranslationTestCase::setUp() |
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix. A temporary files directory is created with the same name as the database prefix.
Parameters
...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.
Overrides DrupalWebTestCase::setUp
File
- modules/
translation/ translation.test, line 22 - Tests for the Translation module.
Code
function setUp() {
parent::setUp('locale', 'translation', 'translation_test');
// Setup users.
$this->admin_user = $this->drupalCreateUser(array('bypass node access', 'administer nodes', 'administer languages', 'administer content types', 'administer blocks', 'access administration pages', 'translate content'));
$this->translator = $this->drupalCreateUser(array('create page content', 'edit own page content', 'translate content'));
$this->drupalLogin($this->admin_user);
// Add languages.
$this->addLanguage('en');
$this->addLanguage('es');
$this->addLanguage('it');
// Disable Italian to test the translation behavior with disabled languages.
$edit = array('enabled[it]' => FALSE);
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
// Set "Basic page" content type to use multilingual support with
// translation.
$this->drupalGet('admin/structure/types/manage/page');
$edit = array();
$edit['language_content_type'] = 2;
$this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type'));
$this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), t('Basic page content type has been updated.'));
// Enable the language switcher block.
$language_type = LANGUAGE_TYPE_INTERFACE;
$edit = array("blocks[locale_$language_type][region]" => 'sidebar_first');
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
// Enable URL language detection and selection to make the language switcher
// block appear.
$edit = array('language[enabled][locale-url]' => TRUE);
$this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
$this->assertRaw(t('Language negotiation configuration saved.'), t('URL language detection enabled.'));
$this->resetCaches();
$this->drupalLogin($this->translator);
}
Login or register to post comments