function PagerTest::testPagerLocale
Same name in other branches
- 9 core/modules/views/tests/src/Functional/Plugin/PagerTest.php \Drupal\Tests\views\Functional\Plugin\PagerTest::testPagerLocale()
- 10 core/modules/views/tests/src/Functional/Plugin/PagerTest.php \Drupal\Tests\views\Functional\Plugin\PagerTest::testPagerLocale()
- 11.x core/modules/views/tests/src/Functional/Plugin/PagerTest.php \Drupal\Tests\views\Functional\Plugin\PagerTest::testPagerLocale()
Tests translating the pager using locale.
File
-
core/
modules/ views/ tests/ src/ Functional/ Plugin/ PagerTest.php, line 438
Class
- PagerTest
- Tests the pluggable pager system.
Namespace
Drupal\Tests\views\Functional\PluginCode
public function testPagerLocale() {
// Enable locale and language module.
$this->container
->get('module_installer')
->install([
'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 = [
'« First' => '« Eerste',
'‹ Previous' => '‹ Vorige',
'Next ›' => 'Volgende ›',
'Last »' => 'Laatste »',
];
foreach ($labels as $label => $translation) {
// Create source string.
$source = $this->localeStorage
->createString([
'source' => $label,
]);
$source->save();
$this->createTranslation($source, $translation, $langcode);
}
// We create 11 nodes, this will give us 3 pages.
$this->drupalCreateContentType([
'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', [
'query' => [
'page' => 1,
],
]);
foreach ($labels as $label => $translation) {
// Check if we can find the translation.
$this->assertRaw($translation);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.