Commit ec36b716 authored by webchick's avatar webchick

Issue #2097537 follow-up by olli: Fixed yet another random failure in...

Issue #2097537 follow-up by olli: Fixed yet another random failure in Drupal\block\Tests\Views\DisplayBlockTest->testBlockCategory().
parent 956781dc
......@@ -343,8 +343,9 @@ public function buildForm(array $form, array &$form_state) {
});
foreach ($plugins as $plugin_id => $plugin_definition) {
$category = String::checkPlain($plugin_definition['category']);
if (!isset($form['place_blocks']['list'][$category])) {
$form['place_blocks']['list'][$category] = array(
$category_key = 'category-' . $category;
if (!isset($form['place_blocks']['list'][$category_key])) {
$form['place_blocks']['list'][$category_key] = array(
'#type' => 'details',
'#title' => $category,
'content' => array(
......@@ -358,7 +359,7 @@ public function buildForm(array $form, array &$form_state) {
),
);
}
$form['place_blocks']['list'][$category]['content']['#links'][$plugin_id] = array(
$form['place_blocks']['list'][$category_key]['content']['#links'][$plugin_id] = array(
'title' => $plugin_definition['admin_label'],
'href' => 'admin/structure/block/add/' . $plugin_id . '/' . $this->theme,
'attributes' => array(
......
......@@ -117,7 +117,7 @@ public function testCandidateBlockList() {
);
$this->drupalGet('admin/structure/block');
$elements = $this->xpath('//details[@id="edit-block-test"]//ul[contains(@class, :ul_class)]/li[contains(@class, :li_class)]/a[contains(@href, :href) and text()=:text]', $arguments);
$elements = $this->xpath('//details[@id="edit-category-block-test"]//ul[contains(@class, :ul_class)]/li[contains(@class, :li_class)]/a[contains(@href, :href) and text()=:text]', $arguments);
$this->assertTrue(!empty($elements), 'The test block appears in the category for its module.');
// Trigger the custom category addition in block_test_block_alter().
......@@ -125,7 +125,7 @@ public function testCandidateBlockList() {
$this->container->get('plugin.manager.block')->clearCachedDefinitions();
$this->drupalGet('admin/structure/block');
$elements = $this->xpath('//details[@id="edit-custom-category"]//ul[contains(@class, :ul_class)]/li[contains(@class, :li_class)]/a[contains(@href, :href) and text()=:text]', $arguments);
$elements = $this->xpath('//details[@id="edit-category-custom-category"]//ul[contains(@class, :ul_class)]/li[contains(@class, :li_class)]/a[contains(@href, :href) and text()=:text]', $arguments);
$this->assertTrue(!empty($elements), 'The test block appears in a custom category controlled by block_test_block_alter().');
}
......
......@@ -66,7 +66,7 @@ public function testBlockCategory() {
// Test that the block was given a default category corresponding to its
// base table.
$arguments = array(
':id' => 'edit-views-test-data',
':id' => 'edit-category-views-test-data',
':li_class' => 'views-block' . drupal_html_class($edit['id']) . '-block-1',
':href' => url('admin/structure/block/add/views_block:' . $edit['id'] . '-block_1/stark'),
':text' => $edit['label'],
......@@ -95,14 +95,14 @@ public function testBlockCategory() {
$this->drupalPostForm(NULL, array(), t('Save'));
// Test that the blocks are listed under the correct categories.
$category_id = drupal_html_id('edit-' . String::checkPlain($category));
$category_id = drupal_html_id('edit-category-' . String::checkPlain($category));
$arguments[':id'] = $category_id;
$this->drupalGet('admin/structure/block');
$elements = $this->xpath('//details[@id=:id]//li[contains(@class, :li_class)]/a[contains(@href, :href) and text()=:text]', $arguments);
$this->assertTrue(!empty($elements), 'The test block appears in the custom category.');
$arguments = array(
':id' => 'edit-views-test-data',
':id' => 'edit-category-views-test-data',
':li_class' => 'views-block' . drupal_html_class($edit['id']) . '-block-2',
':href' => url('admin/structure/block/add/views_block:' . $edit['id'] . '-block_2/stark'),
':text' => $edit['label'],
......
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