Skip to content
Snippets Groups Projects
Commit 2c1bb053 authored by Angie Byron's avatar Angie Byron
Browse files

#473080 by chx: Fix bug where switching themes would result in zero blocks...

#473080 by chx: Fix bug where switching themes would result in zero blocks (including content area). with tests.
parent 3876e6ac
Branches
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -483,7 +483,10 @@ function block_form_system_performance_settings_alter(&$form, &$form_state) {
* Implement hook_form_FORM_ID_alter().
*/
function block_form_system_themes_form_alter(&$form, &$form_state) {
$form['#submit'][] = 'block_system_themes_form_submit';
// This function needs to fire before the theme changes are recorded in the
// database, otherwise it will populate the default list of blocks from the
// new theme, which is empty.
array_unshift($form['#submit'], 'block_system_themes_form_submit');
}
/**
......
......@@ -192,6 +192,50 @@ class NonDefaultBlockAdmin extends DrupalWebTestCase {
}
}
/**
* Test blocks correctly initialized when picking a new default theme.
*/
class NewDefaultThemeBlocks extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => t('New default theme blocks'),
'description' => t('Checks that the new default theme gets blocks.'),
'group' => t('Block'),
);
}
/**
* Check the enabled Garland blocks are correctly copied over.
*/
function testNewDefaultThemeBlocks() {
// Create administrative user.
$admin_user = $this->drupalCreateUser(array('administer site configuration'));
$this->drupalLogin($admin_user);
// Ensure no other theme's blocks are in the block table yet.
$count = db_query_range("SELECT 1 FROM {block} WHERE theme != 'garland'", 0, 1)->fetchField();
$this->assertFalse($count, t('Only Garland has blocks.'));
// Populate list of all blocks for matching against new theme.
$blocks = array();
$result = db_query('SELECT * FROM {block}');
foreach ($result as $block) {
// $block->theme and $block->bid will not match, so remove them.
unset($block->theme, $block->bid);
$blocks[$block->module][$block->delta] = $block;
}
// Turn on the Stark theme and ensure that it contains all of the blocks
// that Garland did.
$this->drupalPost('admin/build/themes', array('theme_default' => 'stark'), t('Save configuration'));
$result = db_query("SELECT * FROM {block} WHERE theme='stark'");
foreach ($result as $block) {
unset($block->theme, $block->bid);
$this->assertEqual($blocks[$block->module][$block->delta], $block, t('Block matched'));
}
}
}
/**
* Test the block system with admin themes.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment