improvements-2.x-dev/modules/improvements_comment/tests/src/Functional/ImprovementsCommentTest.php
modules/improvements_comment/tests/src/Functional/ImprovementsCommentTest.php
<?php namespace Drupal\Tests\improvements_comment\Functional; use Drupal\comment\Tests\CommentTestTrait; use Drupal\Tests\BrowserTestBase; use Drupal\Tests\improvements\Traits\ImprovementsTestTrait; use Drupal\Tests\node\Traits\NodeCreationTrait; class ImprovementsCommentTest extends BrowserTestBase { use CommentTestTrait; use ImprovementsTestTrait; use NodeCreationTrait; /** * {@inheritDoc} */ protected $defaultTheme = 'stark'; /** * {@inheritDoc} */ protected static $modules = ['improvements_comment', 'node']; /** * {@inheritDoc} */ protected function setUp(): void { parent::setUp(); $this->createContentType(['type' => 'page', 'name' => 'Page']); $this->addDefaultCommentField('node', 'page'); } /** * Test remove commented entity on comment form. * * @covers ::improvements_comment_page_comment_reply_result_alter() */ public function testRemoveCommentedEntityOnCommentForm(): void { $this->installModule('improvements'); $node = $this->createNode([ 'title' => 'Node for test ' . __FUNCTION__, 'body' => 'Test node content', ]); $this->drupalLoginAsRoot(); $this->drupalGet('/comment/reply/node/' . $node->id() . '/comment'); $this->dontSeeErrorMessage(); $web_assert = $this->assertSession(); $web_assert->elementExists('css', '.comment-comment-form'); $web_assert->elementNotExists('css', 'article'); } /** * Test comment display fields "uid" and "created". * * @covers ::improvements_entity_base_field_info_alter() */ public function testCommentShowAuthorAndDateFields(): void { $this->setFieldFormatterSettings('comment', 'comment', 'uid', ['type' => 'author']); $this->setFieldFormatterSettings('comment', 'comment', 'created', ['type' => 'timestamp']); $node = $this->createNode([ 'title' => 'Node for test ' . __FUNCTION__, 'body' => 'Test node content', ]); $comment = $this->createComment($node); $this->drupalLoginAsRoot(); $this->drupalGetEntityPage($node); $this->dontSeeErrorMessage(); $web_assert = $this->assertSession(); $web_assert->elementTextContains('css', '#comment-' . $comment->id(), 'User ID'); $web_assert->elementTextContains('css', '#comment-' . $comment->id(), 'Date of creation'); } }