Commit 8391e273 authored by webchick's avatar webchick

Issue #2318429 by janoka: Fixed Language condition / block language visibility...

Issue #2318429 by janoka: Fixed Language condition / block language visibility includes useless options.
parent 1dd9406b
...@@ -31,7 +31,7 @@ class Language extends ConditionPluginBase { ...@@ -31,7 +31,7 @@ class Language extends ConditionPluginBase {
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
if (\Drupal::languageManager()->isMultilingual()) { if (\Drupal::languageManager()->isMultilingual()) {
// Fetch languages. // Fetch languages.
$languages = language_list(LanguageInterface::STATE_ALL); $languages = language_list(LanguageInterface::STATE_CONFIGURABLE);
$langcodes_options = array(); $langcodes_options = array();
foreach ($languages as $language) { foreach ($languages as $language) {
$langcodes_options[$language->id] = $language->getName(); $langcodes_options[$language->id] = $language->getName();
......
<?php
/**
* @file
* Contains \Drupal\language\src\Tests\LanguageBlockSettingsVisibilityTest.
*/
namespace Drupal\language\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Tests that the language settings on block config appears correctly.
*
* @group language
*/
class LanguageBlockSettingsVisibilityTest extends WebTestBase {
public static $modules = array('block', 'language');
public function testUnnecessaryLanguageSettingsVisibility() {
$admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'administer blocks'));
$this->drupalLogin($admin_user);
$this->drupalPostForm('admin/config/regional/language/add', array('predefined_langcode' => 'hu'), t('Add language'));
$this->drupalGet('admin/structure/block/add/system_menu_block:admin/stark');
$this->assertNoFieldByXPath('//input[@id="edit-settings-visibility-language-langcodes-und"]', NULL, '\'Not specified\' option does not appear at block config, language settings section.');
$this->assertNoFieldByXpath('//input[@id="edit-settings-visibility-language-langcodes-zxx"]', NULL, '\'Not applicable\' option does not appear at block config, language settings section.');
$this->assertFieldByXPath('//input[@id="edit-settings-visibility-language-langcodes-en"]', NULL, '\'English\' option appears at block config, language settings section.');
$this->assertFieldByXpath('//input[@id="edit-settings-visibility-language-langcodes-hu"]', NULL, '\'Hungarian\' option appears at block config, language settings section.');
}
}
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