You are here

protected function CommentLinkBuilderTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php \Drupal\Tests\comment\Unit\CommentLinkBuilderTest::setUp()

Prepares mocks for the test.

Overrides UnitTestCase::setUp

File

core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php, line 73
Contains \Drupal\Tests\comment\Unit\CommentLinkBuilderTest.

Class

CommentLinkBuilderTest
@coversDefaultClass \Drupal\comment\CommentLinkBuilder @group comment

Namespace

Drupal\Tests\comment\Unit

Code

protected function setUp() {
  $this->commentManager = $this
    ->getMock('\\Drupal\\comment\\CommentManagerInterface');
  $this->stringTranslation = $this
    ->getStringTranslationStub();
  $this->entityManager = $this
    ->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
  $this->moduleHandler = $this
    ->getMock('\\Drupal\\Core\\Extension\\ModuleHandlerInterface');
  $this->currentUser = $this
    ->getMock('\\Drupal\\Core\\Session\\AccountProxyInterface');
  $this->commentLinkBuilder = new CommentLinkBuilder($this->currentUser, $this->commentManager, $this->moduleHandler, $this->stringTranslation, $this->entityManager);
  $this->commentManager
    ->expects($this
    ->any())
    ->method('getFields')
    ->with('node')
    ->willReturn(array(
    'comment' => array(),
  ));
  $this->commentManager
    ->expects($this
    ->any())
    ->method('forbiddenMessage')
    ->willReturn("Can't let you do that Dave.");
  $this->stringTranslation
    ->expects($this
    ->any())
    ->method('formatPlural')
    ->willReturnArgument(1);
}