function HistoryCommentLinkBuilderTest::setUp

Prepares mocks for the test.

Overrides UnitTestCase::setUp

File

core/modules/history/tests/src/Unit/HistoryCommentLinkBuilderTest.php, line 88

Class

HistoryCommentLinkBuilderTest
This is duplicated from CommentLinkBuilderTest with history additions.

Namespace

Drupal\Tests\history\Unit

Code

protected function setUp() : void {
  parent::setUp();
  $this->commentManager = $this->createMock('\\Drupal\\comment\\CommentManagerInterface');
  $this->stringTranslation = $this->getStringTranslationStub();
  $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
  $this->moduleHandler = $this->createMock('\\Drupal\\Core\\Extension\\ModuleHandlerInterface');
  $this->currentUser = $this->createMock('\\Drupal\\Core\\Session\\AccountProxyInterface');
  $this->commentLinkBuilder = new CommentLinkBuilder($this->currentUser, $this->commentManager, $this->moduleHandler, $this->stringTranslation, $this->entityTypeManager);
  $this->decoratedCommentLinkBuilder = new HistoryCommentLinkBuilder($this->commentLinkBuilder, $this->commentManager, $this->currentUser, $this->entityTypeManager);
  $this->commentManager
    ->expects($this->any())
    ->method('getFields')
    ->with('node')
    ->willReturn([
    'comment' => [],
  ]);
  $this->commentManager
    ->expects($this->any())
    ->method('forbiddenMessage')
    ->willReturn("Can't let you do that Dave.");
  $this->stringTranslation
    ->expects($this->any())
    ->method('formatPlural')
    ->willReturnArgument(1);
}

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