Commit bb925230 authored by webchick's avatar webchick

Issue #2094797 by dawehner, Gábor Hojtsy, webflo: Fixed Config entities upcast...

Issue #2094797 by dawehner, Gábor Hojtsy, webflo: Fixed Config entities upcast from the request always get default language context.
parent b3b073ea
...@@ -134,7 +134,9 @@ public function getLocaleConfigName($name, Language $language) { ...@@ -134,7 +134,9 @@ public function getLocaleConfigName($name, Language $language) {
static function getSubscribedEvents() { static function getSubscribedEvents() {
$events['config.context'][] = array('configContext', 20); $events['config.context'][] = array('configContext', 20);
$events['config.load'][] = array('configLoad', 20); $events['config.load'][] = array('configLoad', 20);
$events[KernelEvents::REQUEST][] = array('onKernelRequestSetDefaultConfigContextLocale', 20); // Set the priority above the one from the RouteListener (priority 32)
// so ensure that the context is cleared before the routing system steps in.
$events[KernelEvents::REQUEST][] = array('onKernelRequestSetDefaultConfigContextLocale', 48);
return $events; return $events;
} }
} }
...@@ -21,7 +21,7 @@ class LocaleConfigTranslationTest extends WebTestBase { ...@@ -21,7 +21,7 @@ class LocaleConfigTranslationTest extends WebTestBase {
* *
* @var array * @var array
*/ */
public static $modules = array('locale'); public static $modules = array('locale', 'contact');
public static function getInfo() { public static function getInfo() {
return array( return array(
...@@ -43,7 +43,7 @@ public function setUp() { ...@@ -43,7 +43,7 @@ public function setUp() {
function testConfigTranslation() { function testConfigTranslation() {
// Add custom language. // Add custom language.
$langcode = 'xx'; $langcode = 'xx';
$admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'translate interface', 'administer modules')); $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'translate interface', 'administer modules', 'access site-wide contact form'));
$this->drupalLogin($admin_user); $this->drupalLogin($admin_user);
$name = $this->randomName(16); $name = $this->randomName(16);
$edit = array( $edit = array(
...@@ -144,6 +144,27 @@ function testConfigTranslation() { ...@@ -144,6 +144,27 @@ function testConfigTranslation() {
// Ensure that the translated configuration has been removed. // Ensure that the translated configuration has been removed.
$this->assertFalse(\Drupal::config('locale.config.xx.image.style.medium')->get('label'), 'Translated configuration for image module removed.'); $this->assertFalse(\Drupal::config('locale.config.xx.image.style.medium')->get('label'), 'Translated configuration for image module removed.');
// Translate default category using the UI so configuration is refreshed.
$category_label = $this->randomName(20);
$search = array(
'string' => 'Website feedback',
'langcode' => $langcode,
'translation' => 'all',
);
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
$edit = array(
$lid => $category_label,
);
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
// Check if this category displayed in this language will use the
// translation. This test ensures the entity loaded from the request
// upcasting will already work.
$this->drupalGet($langcode . '/contact/feedback');
$this->assertText($category_label);
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment