Ejemplo n.º 1
0
 /**
  * @covers ::validate
  */
 public function testValidateHasTermsForVocabularyNoAccess()
 {
     $this->forumUninstallValidator->expects($this->once())->method('hasForumNodes')->willReturn(FALSE);
     $vocabulary = $this->getMock('Drupal\\taxonomy\\VocabularyInterface');
     $vocabulary->expects($this->once())->method('label')->willReturn('Vocabulary label');
     $vocabulary->expects($this->never())->method('url');
     $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->assertSame($expected, $this->castSafeStrings($reasons));
 }
Ejemplo n.º 2
0
 /**
  * @covers ::validate
  */
 public function testValidateHasTermsForVocabularyNoAccess()
 {
     $this->forumUninstallValidator->expects($this->once())->method('hasForumNodes')->willReturn(FALSE);
     $vocabulary = $this->getMock('Drupal\\taxonomy\\VocabularyInterface');
     $vocabulary->expects($this->once())->method('label')->willReturn('Vocabulary label');
     $vocabulary->expects($this->never())->method('url');
     $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 = [SafeMarkup::format('To uninstall Forum, first delete all %vocabulary terms', ['%vocabulary' => 'Vocabulary label'])];
     $reasons = $this->forumUninstallValidator->validate($module);
     $this->assertSame($expected, $reasons);
 }