function ForumUninstallValidatorTest::testValidateHasTermsForVocabularyNoAccess

Same name in other branches
  1. 9 core/modules/forum/tests/src/Unit/ForumUninstallValidatorTest.php \Drupal\Tests\forum\Unit\ForumUninstallValidatorTest::testValidateHasTermsForVocabularyNoAccess()
  2. 8.9.x core/modules/forum/tests/src/Unit/ForumUninstallValidatorTest.php \Drupal\Tests\forum\Unit\ForumUninstallValidatorTest::testValidateHasTermsForVocabularyNoAccess()
  3. 11.x core/modules/forum/tests/src/Unit/ForumUninstallValidatorTest.php \Drupal\Tests\forum\Unit\ForumUninstallValidatorTest::testValidateHasTermsForVocabularyNoAccess()

@covers ::validate

File

core/modules/forum/tests/src/Unit/ForumUninstallValidatorTest.php, line 211

Class

ForumUninstallValidatorTest
@coversDefaultClass \Drupal\forum\ForumUninstallValidator @group forum @group legacy

Namespace

Drupal\Tests\forum\Unit

Code

public function testValidateHasTermsForVocabularyNoAccess() : void {
    $this->forumUninstallValidator
        ->expects($this->once())
        ->method('hasForumNodes')
        ->willReturn(FALSE);
    $vocabulary = $this->createMock('Drupal\\taxonomy\\VocabularyInterface');
    $vocabulary->expects($this->once())
        ->method('label')
        ->willReturn('Vocabulary label');
    $vocabulary->expects($this->never())
        ->method('toUrl');
    $vocabulary->expects($this->once())
        ->method('access')
        ->willReturn(FALSE);
    $this->forumUninstallValidator
        ->expects($this->once())
        ->method('getForumVocabulary')
        ->willReturn($vocabulary);
    $this->forumUninstallValidator
        ->expects($this->once())
        ->method('hasTermsForVocabulary')
        ->willReturn(TRUE);
    $module = 'forum';
    $expected = [
        'To uninstall Forum, first delete all <em class="placeholder">Vocabulary label</em> terms',
    ];
    $reasons = $this->forumUninstallValidator
        ->validate($module);
    $this->assertEquals($expected, $reasons);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.