1 views_translatable.test public ViewsTranslatableTest::testTranslationKey()

Make sure that the different things have the right translation keys.

File

core/modules/views/tests/views_translatable.test, line 115
Definition of ViewsTranslatableTest.

Class

ViewsTranslatableTest
Tests Views pluggable translations.

Code

public function testTranslationKey() {
  $view = $this->viewUnpackTranslatable();
  $view->editing = TRUE;
  $view->init_display();

  // Don't run translation. We just want to get the right keys.
  foreach ($view->display as $display_id => $display) {
    $translatables = array();
    $display->handler->unpack_translatables($translatables);

    $this->string_keys = array(
      'Default1' => array('title'),
      'Apply1' => array('exposed_form', 'submit_button'),
      'Sort By1' => array('exposed_form', 'exposed_sorts_label'),
      'Asc1' => array('exposed_form', 'sort_asc_label'),
      'Desc1' => array('exposed_form', 'sort_desc_label'),
      'more1' => array('use_more_text'),
      'Reset1' => array('exposed_form', 'reset_button_label'),
      'Offset1' => array('pager', 'expose', 'offset_label'),
      'title1' => array('title'),
      'Tag first1' => array('pager', 'tags', 'first'),
      'Tag prev1' => array('pager', 'tags', 'previous'),
      'Tag next1' => array('pager', 'tags', 'next'),
      'Tag last1' => array('pager', 'tags', 'last'),
      'Items per page1' => array('pager', 'expose', 'items_per_page_label'),
      'fieldlabel1' => array('field', 'node', 'nid', 'label'),
      'filterlabel1' => array('filter', 'node', 'nid', 'expose', 'label'),
      '- All -' => array(
        'pager',
        'expose',
        'items_per_page_options_all_label',
      ),
      'Header1' => array('header', 'views', 'area', 'content'),
    );

    $formats = array(
      'Header1' => 'filtered_html',
    );

    foreach ($translatables as $translatable) {
      $this->assertEqual($translatable['keys'], $this->string_keys[$translatable['value']]);

      // Make sure the format is correct.
      if (isset($formats[$translatable['value']])) {
        $this->assertEqual($translatable['format'], $formats[$translatable['value']]);
      }
      else {
        $this->assertNull($translatable['format'], 'No format defined');
      }
    }
  }
}