Issue #1938898 followup by brantwynn, tim.plunkett, Cottser: Fixed Convert block theme tables to table #type.

8.0.x
Alex Pott 2013-06-08 18:24:06 +01:00
parent e44d062a63
commit 1936dbc53d
2 changed files with 63 additions and 7 deletions

View File

@ -143,9 +143,12 @@ class BlockListController extends ConfigEntityListController implements FormInte
// Build blocks first for each region. // Build blocks first for each region.
foreach ($entities as $entity_id => $entity) { foreach ($entities as $entity_id => $entity) {
$info = $entity->getPlugin()->getDefinition(); $definition = $entity->getPlugin()->getDefinition();
$info['entity_id'] = $entity_id; $blocks[$entity->get('region')][$entity_id] = array(
$blocks[$entity->get('region')][] = $info; 'admin_label' => $definition['admin_label'],
'entity_id' => $entity_id,
'weight' => $entity->get('weight'),
);
} }
// Loop over each region and build blocks. // Loop over each region and build blocks.
@ -229,7 +232,7 @@ class BlockListController extends ConfigEntityListController implements FormInte
); );
$form['blocks'][$entity_id]['weight'] = array( $form['blocks'][$entity_id]['weight'] = array(
'#type' => 'weight', '#type' => 'weight',
'#default_value' => $entity->get('weight'), '#default_value' => $info['weight'],
'#delta' => $weight_delta, '#delta' => $weight_delta,
'#title_display' => 'invisible', '#title_display' => 'invisible',
'#title' => t('Weight for @block block', array('@block' => $info['admin_label'])), '#title' => t('Weight for @block block', array('@block' => $info['admin_label'])),

View File

@ -31,7 +31,7 @@ class BlockUiTest extends WebTestBase {
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'Block UI', 'name' => 'Block UI',
'description' => 'Checks that the block configuration UI stores data correctly.', 'description' => 'Checks that the block configuration UI exists and stores data correctly.',
'group' => 'Block', 'group' => 'Block',
); );
} }
@ -44,12 +44,65 @@ class BlockUiTest extends WebTestBase {
'access administration pages', 'access administration pages',
)); ));
$this->drupalLogin($this->adminUser); $this->drupalLogin($this->adminUser);
// Enable some test blocks.
$this->testBlocks = array(
array(
'label' => 'Tools',
'tr' => '5',
'plugin_id' => 'system_menu_block:menu-tools',
'settings' => array('region' => 'sidebar_second', 'machine_name' => 'tools'),
'test_weight' => '-1',
),
array(
'label' => 'Powered by Drupal',
'tr' => '12',
'plugin_id' => 'system_powered_by_block',
'settings' => array('region' => 'footer', 'machine_name' => 'powered'),
'test_weight' => '0',
),
);
foreach ($this->testBlocks as $values) {
$this->drupalPlaceBlock($values['plugin_id'], $values['settings']);
}
} }
/** /**
* Test block visibility. * Test block admin page exists and functions correctly.
*/ */
function testBlockVisibility() { function testBlockAdminUiPage() {
// Visit the blocks admin ui.
$this->drupalGet('admin/structure/block');
// Look for the blocks table.
$blocks_table = $this->xpath("//table[@id='blocks']");
$this->assertTrue(!empty($blocks_table), 'The blocks table is being rendered.');
// Look for test blocks in the table.
foreach ($this->testBlocks as $values) {
$element = $this->xpath('//*[@id="blocks"]/tbody/tr[' . $values['tr'] . ']/td[1]/text()');
$this->assertTrue((string)$element[0] == $values['label'], 'The "' . $values['label'] . '" block title is set inside the ' . $values['settings']['region'] . ' region.');
// Look for a test block region select form element.
$this->assertField('blocks[stark.' . $values['settings']['machine_name'] . '][region]', 'The block "' . $values['label'] . '" has a region assignment field.');
// Move the test block to the header region.
$edit['blocks[stark.' . $values['settings']['machine_name'] . '][region]'] = 'header';
// Look for a test block weight select form element.
$this->assertField('blocks[stark.' . $values['settings']['machine_name'] . '][weight]', 'The block "' . $values['label'] . '" has a weight assignment field.');
// Change the test block's weight.
$edit['blocks[stark.' . $values['settings']['machine_name'] . '][weight]'] = $values['test_weight'];
}
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
foreach ($this->testBlocks as $values) {
// Check if the region and weight settings changes have persisted.
$this->assertOptionSelected(
'edit-blocks-stark' . $values['settings']['machine_name'] . '-region',
'header',
'The block "' . $values['label'] . '" has the correct region assignment (header).'
);
$this->assertOptionSelected(
'edit-blocks-stark' . $values['settings']['machine_name'] . '-weight',
$values['test_weight'],
'The block "' . $values['label'] . '" has the correct weight assignment (' . $values['test_weight'] . ').'
);
}
} }
/** /**