Check the translations of the cached plugin definitions.
public function testCacheDecoratorLanguage() {
$languages = $this->languages;
$this
->drupalGet('plugin_definition_test');
foreach ($this->mockBlockExpectedDefinitions as $plugin_id => $definition) {
// Find our source text.
$this
->assertText($definition['label']);
}
foreach ($languages as $langcode) {
$url = $langcode . '/plugin_definition_test';
// For each language visit the language specific version of the page again.
$this
->drupalGet($url);
foreach ($this->mockBlockExpectedDefinitions as $plugin_id => $definition) {
// Find our provided translations.
$label = $langcode . ' ' . $definition['label'];
$this
->assertText($label);
}
}
// Manually check that the expected cache keys are present.
$languages[] = 'en';
foreach ($languages as $langcode) {
$cache = cache()
->get('mock_block:' . $langcode);
$this
->assertEqual($cache->cid, 'mock_block:' . $langcode, format_string('The !cache cache exists.', array(
'!cache' => 'mock_block:' . $langcode,
)));
$this
->assertEqual($cache->expire, 1542646800, format_string('The cache expiration was properly set.'));
}
// Clear the plugin definitions.
$manager = new CachedMockBlockManager();
$manager
->clearCachedDefinitions();
foreach ($languages as $langcode) {
$cache = cache()
->get('mock_block:' . $langcode);
$this
->assertFalse($cache, format_string('The !cache cache was properly cleared through the cache::deleteTags() method.', array(
'!cache' => 'mock_block:' . $langcode,
)));
}
// Change the translations for the german language and recheck strings.
$custom_strings = array();
foreach ($this->mockBlockExpectedDefinitions as $plugin_id => $definition) {
$custom_strings[$definition['label']] = $definition['label'] . ' de';
}
variable_set('locale_custom_strings_de', array(
'' => $custom_strings,
));
$this
->drupalGet('de/plugin_definition_test');
foreach ($this->mockBlockExpectedDefinitions as $plugin_id => $definition) {
// Find our provided translations.
$label = $definition['label'] . ' de';
$this
->assertText($label);
}
}