From 688fab7beb2f232fb5db2a8d6b179edc410ea52f Mon Sep 17 00:00:00 2001 From: Dries <dries@buytaert.net> Date: Wed, 10 Dec 2014 15:08:40 -0500 Subject: [PATCH] =?UTF-8?q?Issue=20#2390445=20by=20G=C3=A1bor=20Hojtsy:=20?= =?UTF-8?q?System=20module=20tests=20don't=20pass=20config=20schema=20chec?= =?UTF-8?q?k?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/modules/rdf/src/Entity/RdfMapping.php | 12 ++++------ core/modules/shortcut/shortcut.install | 23 ++++++++++++++++++- core/modules/shortcut/shortcut.module | 13 +++++++++++ .../system/src/Form/ThemeSettingsForm.php | 6 ++--- .../system/src/Tests/Batch/PageTest.php | 9 ++++++++ .../Tests/Entity/EntityViewControllerTest.php | 9 ++++++++ .../src/Tests/Extension/ThemeHandlerTest.php | 9 ++++++++ .../system/src/Tests/Form/FormObjectTest.php | 9 ++++++++ .../system/src/Tests/Menu/BreadcrumbTest.php | 10 +++++++- .../system/src/Tests/Menu/MenuRouterTest.php | 9 ++++++++ .../system/src/Tests/System/PageTitleTest.php | 9 ++++++++ .../system/src/Tests/System/ThemeTest.php | 9 ++++++++ .../config/schema/form_test.schema.yml | 7 ++++++ .../seven/config/install/seven.settings.yml | 3 --- 14 files changed, 121 insertions(+), 16 deletions(-) create mode 100644 core/modules/system/tests/modules/form_test/config/schema/form_test.schema.yml delete mode 100644 core/themes/seven/config/install/seven.settings.yml diff --git a/core/modules/rdf/src/Entity/RdfMapping.php b/core/modules/rdf/src/Entity/RdfMapping.php index af4e30779def..577cbe7adced 100644 --- a/core/modules/rdf/src/Entity/RdfMapping.php +++ b/core/modules/rdf/src/Entity/RdfMapping.php @@ -51,31 +51,27 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface { * * @var array */ - protected $types; + protected $types = array(); /** * The mappings for fields on this bundle. * * @var array */ - protected $fieldMappings; + protected $fieldMappings = array(); /** * {@inheritdoc} */ public function getPreparedBundleMapping() { - $types = array(); - if (isset($this->types)) { - $types = $this->types; - } - return array('types' => $types); + return array('types' => $this->types); } /** * {@inheritdoc} */ public function getBundleMapping() { - if (isset($this->types)) { + if (!empty($this->types)) { return array('types' => $this->types); } return array(); diff --git a/core/modules/shortcut/shortcut.install b/core/modules/shortcut/shortcut.install index be6f8b279364..d716a0395ae0 100644 --- a/core/modules/shortcut/shortcut.install +++ b/core/modules/shortcut/shortcut.install @@ -12,7 +12,6 @@ * Implements hook_schema(). */ function shortcut_schema() { - $schema['shortcut_set_users'] = array( 'description' => 'Maps users to shortcut sets.', 'fields' => array( @@ -49,3 +48,25 @@ function shortcut_schema() { return $schema; } + +/** + * Implements hook_install(). + */ +function shortcut_install() { + // Theme settings are not configuration entities and cannot depend on modules + // so to set a module-specific setting, we need to set it with logic. + if (\Drupal::service('theme_handler')->themeExists('seven')) { + \Drupal::config('seven.settings')->set('third_party_settings.shortcut.module_link', TRUE)->save(); + } +} + +/** + * Implements hook_uninstall(). + */ +function shortcut_uninstall() { + // Theme settings are not configuration entities and cannot depend on modules + // so to unset a module-specific setting, we need to unset it with logic. + if (\Drupal::service('theme_handler')->themeExists('seven')) { + \Drupal::config('seven.settings')->clear('third_party_settings.shortcut.module_link')->save(); + } +} diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index cb67d4e307b2..696a3819401e 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -396,3 +396,16 @@ function shortcut_toolbar() { return $items; } + +/** + * Implements hook_themes_installed(). + */ +function shortcut_themes_installed($theme_list) { + if (in_array('seven', $theme_list)) { + // Theme settings are not configuration entities and cannot depend on modules + // so to set a module-specific setting, we need to set it with logic. + if (\Drupal::moduleHandler()->moduleExists('shortcut')) { + \Drupal::config('seven.settings')->set('third_party_settings.shortcut.module_link', TRUE)->save(); + } + } +} diff --git a/core/modules/system/src/Form/ThemeSettingsForm.php b/core/modules/system/src/Form/ThemeSettingsForm.php index 44649d243157..8e72246c75c0 100644 --- a/core/modules/system/src/Form/ThemeSettingsForm.php +++ b/core/modules/system/src/Form/ThemeSettingsForm.php @@ -182,7 +182,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $theme = ); } - if ((!$theme) || in_array('favicon', $features) && $this->moduleHandler->moduleExists('file')) { + if (((!$theme) || in_array('favicon', $features)) && $this->moduleHandler->moduleExists('file')) { $form['favicon'] = array( '#type' => 'details', '#title' => t('Shortcut icon settings'), @@ -390,19 +390,19 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // and use it in place of the default theme-provided file. if ($this->moduleHandler->moduleExists('file')) { if ($file = $values['logo_upload']) { - unset($values['logo_upload']); $filename = file_unmanaged_copy($file->getFileUri()); $values['default_logo'] = 0; $values['logo_path'] = $filename; $values['toggle_logo'] = 1; } if ($file = $values['favicon_upload']) { - unset($values['favicon_upload']); $filename = file_unmanaged_copy($file->getFileUri()); $values['default_favicon'] = 0; $values['favicon_path'] = $filename; $values['toggle_favicon'] = 1; } + unset($values['logo_upload']); + unset($values['favicon_upload']); // If the user entered a path relative to the system files directory for // a logo or favicon, store a public:// URI so the theme system can handle it. diff --git a/core/modules/system/src/Tests/Batch/PageTest.php b/core/modules/system/src/Tests/Batch/PageTest.php index 42800b76c703..c4b1b70141bb 100644 --- a/core/modules/system/src/Tests/Batch/PageTest.php +++ b/core/modules/system/src/Tests/Batch/PageTest.php @@ -16,6 +16,15 @@ */ class PageTest extends WebTestBase { + /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + /** * Modules to enable. * diff --git a/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php b/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php index aa2d800c8b47..93f75df658c8 100644 --- a/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php +++ b/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php @@ -16,6 +16,15 @@ */ class EntityViewControllerTest extends WebTestBase { + /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + /** * Modules to enable. * diff --git a/core/modules/system/src/Tests/Extension/ThemeHandlerTest.php b/core/modules/system/src/Tests/Extension/ThemeHandlerTest.php index 50d299c05dce..36c17d9aa997 100644 --- a/core/modules/system/src/Tests/Extension/ThemeHandlerTest.php +++ b/core/modules/system/src/Tests/Extension/ThemeHandlerTest.php @@ -18,6 +18,15 @@ */ class ThemeHandlerTest extends KernelTestBase { + /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + /** * Modules to enable. * diff --git a/core/modules/system/src/Tests/Form/FormObjectTest.php b/core/modules/system/src/Tests/Form/FormObjectTest.php index 237d9e74a4af..c41928a29387 100644 --- a/core/modules/system/src/Tests/Form/FormObjectTest.php +++ b/core/modules/system/src/Tests/Form/FormObjectTest.php @@ -17,6 +17,15 @@ */ class FormObjectTest extends SystemConfigFormTestBase { + /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + /** * Modules to enable. * diff --git a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php index ee54f3195d52..22a2f7da35c8 100644 --- a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php @@ -18,6 +18,15 @@ */ class BreadcrumbTest extends MenuTestBase { + /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + /** * Modules to enable. * @@ -41,7 +50,6 @@ protected function setUp() { // presence on the page, so we need to ensure that the Tools block will be // displayed in the admin theme. $this->drupalPlaceBlock('system_menu_block:tools', array( - 'machine' => 'system_menu_tools', 'region' => 'content', 'theme' => \Drupal::config('system.theme')->get('admin'), )); diff --git a/core/modules/system/src/Tests/Menu/MenuRouterTest.php b/core/modules/system/src/Tests/Menu/MenuRouterTest.php index 7de9006880ff..4dd2e19135d3 100644 --- a/core/modules/system/src/Tests/Menu/MenuRouterTest.php +++ b/core/modules/system/src/Tests/Menu/MenuRouterTest.php @@ -16,6 +16,15 @@ */ class MenuRouterTest extends WebTestBase { + /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + /** * Modules to enable. * diff --git a/core/modules/system/src/Tests/System/PageTitleTest.php b/core/modules/system/src/Tests/System/PageTitleTest.php index 98148cd06d50..31020c9dd25c 100644 --- a/core/modules/system/src/Tests/System/PageTitleTest.php +++ b/core/modules/system/src/Tests/System/PageTitleTest.php @@ -19,6 +19,15 @@ */ class PageTitleTest extends WebTestBase { + /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + /** * Modules to enable. * diff --git a/core/modules/system/src/Tests/System/ThemeTest.php b/core/modules/system/src/Tests/System/ThemeTest.php index 80d469ac0f67..8a7fd040aa17 100644 --- a/core/modules/system/src/Tests/System/ThemeTest.php +++ b/core/modules/system/src/Tests/System/ThemeTest.php @@ -18,6 +18,15 @@ */ class ThemeTest extends WebTestBase { + /** + * Set to TRUE to strict check all configuration saved. + * + * @see \Drupal\Core\Config\Testing\ConfigSchemaChecker + * + * @var bool + */ + protected $strictConfigSchema = TRUE; + /** * Modules to enable. * diff --git a/core/modules/system/tests/modules/form_test/config/schema/form_test.schema.yml b/core/modules/system/tests/modules/form_test/config/schema/form_test.schema.yml new file mode 100644 index 000000000000..3e38933008fd --- /dev/null +++ b/core/modules/system/tests/modules/form_test/config/schema/form_test.schema.yml @@ -0,0 +1,7 @@ +form_test.object: + type: mapping + label: 'Test form' + mapping: + bananas: + type: string + label: 'Bananas' diff --git a/core/themes/seven/config/install/seven.settings.yml b/core/themes/seven/config/install/seven.settings.yml deleted file mode 100644 index 6bba58bc7983..000000000000 --- a/core/themes/seven/config/install/seven.settings.yml +++ /dev/null @@ -1,3 +0,0 @@ -third_party_settings: - shortcut: - module_link: true -- GitLab