Commit 1936dbc5 authored by alexpott's avatar alexpott
Browse files

Issue #1938898 followup by brantwynn, tim.plunkett, Cottser: Fixed Convert...

Issue #1938898 followup by brantwynn, tim.plunkett, Cottser: Fixed Convert block theme tables to table #type.
parent e44d062a
......@@ -143,9 +143,12 @@ public function buildForm(array $form, array &$form_state) {
// Build blocks first for each region.
foreach ($entities as $entity_id => $entity) {
$info = $entity->getPlugin()->getDefinition();
$info['entity_id'] = $entity_id;
$blocks[$entity->get('region')][] = $info;
$definition = $entity->getPlugin()->getDefinition();
$blocks[$entity->get('region')][$entity_id] = array(
'admin_label' => $definition['admin_label'],
'entity_id' => $entity_id,
'weight' => $entity->get('weight'),
);
}
// Loop over each region and build blocks.
......@@ -229,7 +232,7 @@ public function buildForm(array $form, array &$form_state) {
);
$form['blocks'][$entity_id]['weight'] = array(
'#type' => 'weight',
'#default_value' => $entity->get('weight'),
'#default_value' => $info['weight'],
'#delta' => $weight_delta,
'#title_display' => 'invisible',
'#title' => t('Weight for @block block', array('@block' => $info['admin_label'])),
......
......@@ -31,7 +31,7 @@ class BlockUiTest extends WebTestBase {
public static function getInfo() {
return array(
'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',
);
}
......@@ -44,12 +44,65 @@ function setUp() {
'access administration pages',
));
$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'] . ').'
);
}
}
/**
......
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