protected function CommentLinkBuilderTest::setUp in Drupal 10
Same name and namespace in other branches
- 8 core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php \Drupal\Tests\comment\Unit\CommentLinkBuilderTest::setUp()
- 9 core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php \Drupal\Tests\comment\Unit\CommentLinkBuilderTest::setUp()
Prepares mocks for the test.
File
- core/
modules/ comment/ tests/ src/ Unit/ CommentLinkBuilderTest.php, line 71
Class
- CommentLinkBuilderTest
- @coversDefaultClass \Drupal\comment\CommentLinkBuilder @group comment
Namespace
Drupal\Tests\comment\UnitCode
protected function setUp() : void {
$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->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);
}