You are here

function i18nAccessTestCase::setLanguagePermissions in Translation Access 7

Same name and namespace in other branches
  1. 6 i18n_access.test \i18nAccessTestCase::setLanguagePermissions()

Sets the language permission for the specified user. Must be logged in as an 'administer users' privileged user before calling this.

Parameters

$account: The user account to modify

$languages: An array of language codes to give permission for

1 call to i18nAccessTestCase::setLanguagePermissions()
i18nAccessTestCase::setUp in ./i18n_access.test
Implementation of setUp().

File

./i18n_access.test, line 82
Test suite for i18n_access.module

Class

i18nAccessTestCase
@file Test suite for i18n_access.module

Code

function setLanguagePermissions($account, $languages = array()) {
  $this
    ->assertTrue(user_access('administer users'), t('User has permission to administer users'));
  foreach ($languages as $langcode) {
    $key = 'i18n_access[' . $langcode . ']';
    $edit[$key] = $langcode;
    $expected[$langcode] = $langcode;
  }
  $this
    ->drupalPost('user/' . $account->uid . '/edit', $edit, t('Save'));
  $actual = i18n_access_load_permissions($account->uid);
  $this
    ->assertEqual($expected, $actual, t('Language permissions set correctly.'), 'i18n_access');
}