diff --git a/core/modules/views/src/Tests/Plugin/PagerTest.php b/core/modules/views/src/Tests/Plugin/PagerTest.php index 46e75bc..bbe0e01 100644 --- a/core/modules/views/src/Tests/Plugin/PagerTest.php +++ b/core/modules/views/src/Tests/Plugin/PagerTest.php @@ -8,6 +8,7 @@ namespace Drupal\views\Tests\Plugin; use Drupal\views\Views; +use Drupal\language\Entity\ConfigurableLanguage; /** * Tests the pluggable pager system. @@ -31,6 +32,13 @@ class PagerTest extends PluginTestBase { public static $modules = array('node', 'views_ui'); /** + * String translation storage object. + * + * @var \Drupal\locale\StringStorageInterface + */ + protected $localeStorage; + + /** * Pagers was sometimes not stored. * * @see http://drupal.org/node/652712 @@ -323,4 +331,60 @@ function testPagerApi() { $this->assertEqual($view->getCurrentPage(), 0, 'Make sure setCurrentPage always sets a valid page number.'); } + /** + * Test the pager in a different language. + */ + public function testPagerMultilingual() { + // Enable locale and language module. + $this->container->get('module_installer')->install(array('locale', 'language')); + $this->resetAll(); + $langcode = 'nl'; + + // Add a default locale storage for this test. + $this->localeStorage = $this->container->get('locale.storage'); + + // Add Dutch language programmatically. + ConfigurableLanguage::createFromLangcode($langcode)->save(); + + // Labels that need translations. + $labels = array( + '« first' => '« eerste', + '‹ previous' => '‹ vorige', + 'next ›' => 'volgende ›', + 'last »' => 'laatste »', + ); + foreach ($labels as $label => $translation) { + // Create source string. + $source = $this->localeStorage->createString(array( + 'source' => $label + )); + $source->save(); + $this->createTranslation($source, $translation, $langcode); + } + + // We create 11 nodes, this will give us 3 pages. + $this->drupalCreateContentType(array('type' => 'page')); + for ($i = 0; $i < 11; $i++) { + $this->drupalCreateNode(); + } + + // Go to the second page so we see both previous and next buttons. + $this->drupalGet('nl/test_pager_full', array('query' => array('page' => 1))); + foreach ($labels as $label => $translation) { + // Check if we can find the translation. + $this->assertRaw($translation); + } + } + + /** + * Creates single translation for source string. + */ + protected function createTranslation($source, $translation, $langcode) { + $values = array( + 'lid' => $source->lid, + 'language' => $langcode, + 'translation' => $translation, + ); + return $this->localeStorage->createTranslation($values)->save(); + } } diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_pager_full.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_pager_full.yml index a347a76..e17e1a4 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_pager_full.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_pager_full.yml @@ -34,3 +34,11 @@ display: display_title: Master id: default position: 0 + page_1: + display_plugin: page + id: page_1 + display_title: Page + position: 1 + display_options: + display_extenders: { } + path: test_pager_full