You are here

public function ForumUninstallValidatorTest::testValidateHasTermsForVocabularyAccess in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/forum/tests/src/Unit/ForumUninstallValidatorTest.php \Drupal\Tests\forum\Unit\ForumUninstallValidatorTest::testValidateHasTermsForVocabularyAccess()

@covers ::validate

File

core/modules/forum/tests/src/Unit/ForumUninstallValidatorTest.php, line 175
Contains \Drupal\Tests\forum\Unit\ForumUninstallValidatorTest.

Class

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

Namespace

Drupal\Tests\forum\Unit

Code

public function testValidateHasTermsForVocabularyAccess() {
  $this->forumUninstallValidator
    ->expects($this
    ->once())
    ->method('hasForumNodes')
    ->willReturn(FALSE);
  $vocabulary = $this
    ->getMock('Drupal\\taxonomy\\VocabularyInterface');
  $vocabulary
    ->expects($this
    ->once())
    ->method('url')
    ->willReturn('/path/to/vocabulary/overview');
  $vocabulary
    ->expects($this
    ->once())
    ->method('label')
    ->willReturn('Vocabulary label');
  $vocabulary
    ->expects($this
    ->once())
    ->method('access')
    ->willReturn(TRUE);
  $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 <a href="/path/to/vocabulary/overview"><em class="placeholder">Vocabulary label</em></a> terms',
  ];
  $reasons = $this->forumUninstallValidator
    ->validate($module);
  $this
    ->assertSame($expected, $this
    ->castSafeStrings($reasons));
}