You are here

public function JsTestWebTestCase::testInternationalization in JS Callback Handler 7

Test Internationalization.

File

tests/js_test.test, line 85
Testing for the bam template module

Class

JsTestWebTestCase
@file Testing for the bam template module

Code

public function testInternationalization() {

  // Add Dutch locale (just any other language).
  locale_add_language('nl', 'Dutch', 'Nederlands');

  // Add url language negotiation directly in the settings.
  variable_set('language_negotiation_language', array(
    'locale-url' => array(
      'callbacks' => array(
        'language' => 'locale_language_from_url',
        'switcher' => 'locale_language_switcher_url',
        'url_rewrite' => 'locale_language_url_rewrite_url',
      ),
      'file' => 'includes/locale.inc',
    ),
    'language-default' => array(
      'callbacks' => array(
        'language' => 'language_from_default',
      ),
    ),
  ));
  $this
    ->verbose(print_r(variable_get('language_negotiation_language'), true));

  // Via clean url (rewrite).
  $out = $this
    ->drupalGet('nl/js/js_test/test_basic');
  $out = drupal_json_decode($out);
  $this
    ->assertEqual($out['filename'], 'js.php', 'Call was routed through js.php.');
  $this
    ->assertEqual($out['response'], 'ok', 'The response to the basic test was ok.');
  $this
    ->assertEqual($out['language']['language'], 'nl', 'The active language should be dutch.');

  // Test Page arguments.
  $out = $this
    ->drupalGet('nl/js/js_test/test_arguments/value1/value2/value3');
  $out = drupal_json_decode($out);
  $this
    ->assertEqual($out['response']['argument_1'], 'value1', 'Page argument 1 should be value1.');
  $this
    ->assertEqual($out['response']['argument_2'], 'value3', 'Page argument 2 should be value3.');
}