Test block admin page exists and functions correctly.
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'] . ').');
}
}