Commit d2bf0de1 authored by catch's avatar catch
Browse files

Issue #2469545 by yogeshmpawar, willzyx, umarzaffer, lauriii, idebr,...

Issue #2469545 by yogeshmpawar, willzyx, umarzaffer, lauriii, idebr, ranjith_kumar_k_u, smustgrave, jibran: Vocabulary listing missing delete operation for vocabularies
parent 9d3193a8
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -109,6 +109,9 @@ public function getDefaultOperations(EntityInterface $entity) {
    if (isset($operations['edit'])) {
      $operations['edit']['title'] = t('Edit vocabulary');
    }
    if (isset($operations['delete'])) {
      $operations['delete']['title'] = $this->t('Delete vocabulary');
    }

    if ($entity->access('access taxonomy overview')) {
      $operations['list'] = [
@@ -127,8 +130,6 @@ public function getDefaultOperations(EntityInterface $entity) {
      ];
    }

    unset($operations['delete']);

    return $operations;
  }

+16 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\Tests\taxonomy\Functional;

use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Url;
use Drupal\taxonomy\Entity\Vocabulary;

@@ -88,6 +89,21 @@ public function testVocabularyInterface() {

    $site_name = $this->config('system.site')->get('name');
    $this->assertSession()->titleEquals("Don't Panic | $site_name");

    // Delete the vocabulary.
    $this->drupalGet('admin/structure/taxonomy');
    $href = Url::fromRoute('entity.taxonomy_vocabulary.delete_form', ['taxonomy_vocabulary' => $edit['vid']])->toString();
    $xpath = $this->assertSession()->buildXPathQuery('//a[contains(@href, :href)]', [':href' => $href]);
    $link = $this->assertSession()->elementExists('xpath', $xpath);
    $this->assertEquals('Delete vocabulary', $link->getText());
    $link->click();

    // Confirm deletion.
    $this->assertSession()->responseContains(new FormattableMarkup('Are you sure you want to delete the vocabulary %name?', ['%name' => $edit['name']]));
    $this->submitForm([], 'Delete');
    $this->assertSession()->responseContains(new FormattableMarkup('Deleted vocabulary %name.', ['%name' => $edit['name']]));
    $this->container->get('entity_type.manager')->getStorage('taxonomy_vocabulary')->resetCache();
    $this->assertNull(Vocabulary::load($edit['vid']), 'Vocabulary not found.');
  }

  /**