Skip to content
Snippets Groups Projects
Commit ed23b897 authored by catch's avatar catch
Browse files

Issue #3412283 by mathilde_dumond, acbramley, Berdir, smustgrave, BramDriesen,...

Issue #3412283 by mathilde_dumond, acbramley, Berdir, smustgrave, BramDriesen, larowlan: Editing a block_content entity no longer redirects to the overview

(cherry picked from commit b46fb5e6)
parent a9b2d321
No related branches found
No related tags found
7 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words
Pipeline #111537 passed with warnings
Pipeline: drupal

#111581

    Pipeline: drupal

    #111566

      Pipeline: drupal

      #111554

        +1
        ...@@ -108,20 +108,18 @@ public function save(array $form, FormStateInterface $form_state) { ...@@ -108,20 +108,18 @@ public function save(array $form, FormStateInterface $form_state) {
        if ($block->id()) { if ($block->id()) {
        $form_state->setValue('id', $block->id()); $form_state->setValue('id', $block->id());
        $form_state->set('id', $block->id()); $form_state->set('id', $block->id());
        if ($insert) { $theme = $block->getTheme();
        $theme = $block->getTheme(); if ($insert && $theme) {
        if ($theme) { $form_state->setRedirect(
        $form_state->setRedirect( 'block.admin_add',
        'block.admin_add', [
        [ 'plugin_id' => 'block_content:' . $block->uuid(),
        'plugin_id' => 'block_content:' . $block->uuid(), 'theme' => $theme,
        'theme' => $theme, ]
        ] );
        ); }
        } else {
        else { $form_state->setRedirectUrl($block->toUrl('collection'));
        $form_state->setRedirectUrl($block->toUrl('collection'));
        }
        } }
        } }
        else { else {
        ......
        ...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
        namespace Drupal\Tests\block_content\Functional; namespace Drupal\Tests\block_content\Functional;
        use Drupal\block_content\BlockContentInterface;
        use Drupal\block_content\Entity\BlockContent; use Drupal\block_content\Entity\BlockContent;
        use Drupal\Core\Database\Database; use Drupal\Core\Database\Database;
        ...@@ -67,10 +68,7 @@ public function testBlockContentCreation() { ...@@ -67,10 +68,7 @@ public function testBlockContentCreation() {
        $this->assertSession()->fieldNotExists('settings[view_mode]'); $this->assertSession()->fieldNotExists('settings[view_mode]');
        // Check that the block exists in the database. // Check that the block exists in the database.
        $blocks = \Drupal::entityTypeManager() $block = $this->getBlockByLabel($edit['info[0][value]']);
        ->getStorage('block_content')
        ->loadByProperties(['info' => $edit['info[0][value]']]);
        $block = reset($blocks);
        $this->assertNotEmpty($block, 'Content Block found in database.'); $this->assertNotEmpty($block, 'Content Block found in database.');
        } }
        ...@@ -133,10 +131,7 @@ public function testBlockContentCreationMultipleViewModes() { ...@@ -133,10 +131,7 @@ public function testBlockContentCreationMultipleViewModes() {
        $this->assertSession()->fieldValueEquals('settings[view_mode]', 'test_view_mode'); $this->assertSession()->fieldValueEquals('settings[view_mode]', 'test_view_mode');
        // Check that the block exists in the database. // Check that the block exists in the database.
        $blocks = \Drupal::entityTypeManager() $block = $this->getBlockByLabel($edit['info[0][value]']);
        ->getStorage('block_content')
        ->loadByProperties(['info' => $edit['info[0][value]']]);
        $block = reset($blocks);
        $this->assertNotEmpty($block, 'Content Block found in database.'); $this->assertNotEmpty($block, 'Content Block found in database.');
        } }
        ...@@ -175,6 +170,14 @@ public function testBlockContentFormSubmitHandlers() { ...@@ -175,6 +170,14 @@ public function testBlockContentFormSubmitHandlers() {
        $this->assertSession()->pageTextContains('basic ' . $edit['info[0][value]'] . ' has been created.'); $this->assertSession()->pageTextContains('basic ' . $edit['info[0][value]'] . ' has been created.');
        $this->assertSession()->addressEquals('/admin/content/block'); $this->assertSession()->addressEquals('/admin/content/block');
        // Check that the user is redirected to the block library on edit.
        $block = $this->getBlockByLabel($edit['info[0][value]']);
        $this->drupalGet($block->toUrl('edit-form'));
        $this->submitForm([
        'info[0][value]' => 'Test Block Updated',
        ], 'Save');
        $this->assertSession()->addressEquals('admin/content/block');
        // Test with user who doesn't have permission to place a block. // Test with user who doesn't have permission to place a block.
        $this->drupalLogin($this->drupalCreateUser(['administer block content'])); $this->drupalLogin($this->drupalCreateUser(['administer block content']));
        $this->drupalGet('block/add/basic'); $this->drupalGet('block/add/basic');
        ...@@ -200,10 +203,7 @@ public function testDefaultBlockContentCreation() { ...@@ -200,10 +203,7 @@ public function testDefaultBlockContentCreation() {
        $this->assertSession()->pageTextContains('basic ' . $edit['info[0][value]'] . ' has been created.'); $this->assertSession()->pageTextContains('basic ' . $edit['info[0][value]'] . ' has been created.');
        // Check that the block exists in the database. // Check that the block exists in the database.
        $blocks = \Drupal::entityTypeManager() $block = $this->getBlockByLabel($edit['info[0][value]']);
        ->getStorage('block_content')
        ->loadByProperties(['info' => $edit['info[0][value]']]);
        $block = reset($blocks);
        $this->assertNotEmpty($block, 'Default Content Block found in database.'); $this->assertNotEmpty($block, 'Default Content Block found in database.');
        } }
        ...@@ -316,4 +316,17 @@ public function testConfigDependencies() { ...@@ -316,4 +316,17 @@ public function testConfigDependencies() {
        $this->assertEquals($block_placement_id, $block_placement->id(), "The block placement config entity has a dependency on the block content entity."); $this->assertEquals($block_placement_id, $block_placement->id(), "The block placement config entity has a dependency on the block content entity.");
        } }
        /**
        * Load a block based on the label.
        */
        private function getBlockByLabel(string $label): ?BlockContentInterface {
        $blocks = \Drupal::entityTypeManager()
        ->getStorage('block_content')
        ->loadByProperties(['info' => $label]);
        if (empty($blocks)) {
        return NULL;
        }
        return reset($blocks);
        }
        } }
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment