class CommentApproveLinkTest
Same name and namespace in other branches
- 11.x core/modules/comment/tests/src/Functional/Views/CommentApproveLinkTest.php \Drupal\Tests\comment\Functional\Views\CommentApproveLinkTest
Test the "approve_comment" views field for approving comments.
@group comment
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Functional\ViewTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\comment\Functional\Views\CommentTestBase uses \Drupal\comment\Tests\CommentTestTrait implements \Drupal\Tests\views\Functional\ViewTestBase
- class \Drupal\Tests\comment\Functional\Views\CommentApproveLinkTest implements \Drupal\Tests\comment\Functional\Views\CommentTestBase
- class \Drupal\Tests\comment\Functional\Views\CommentTestBase uses \Drupal\comment\Tests\CommentTestTrait implements \Drupal\Tests\views\Functional\ViewTestBase
- class \Drupal\Tests\views\Functional\ViewTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of CommentApproveLinkTest
File
-
core/
modules/ comment/ tests/ src/ Functional/ Views/ CommentApproveLinkTest.php, line 10
Namespace
Drupal\Tests\comment\Functional\ViewsView source
class CommentApproveLinkTest extends CommentTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'comment',
'comment_test_views',
'system',
'views',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = [
'test_comment_schema',
];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE, $modules = [
'comment_test_views',
]) : void {
parent::setUp($import_test_views, $modules);
}
/**
* Tests that "approve comment" link exists and works as expected.
*/
public function testCommentApproveLink() {
$this->drupalLogin($this->drupalCreateUser([
'administer comments',
]));
// Set the comment status to unpublished.
$this->comment
->setUnpublished();
$this->comment
->save();
$this->drupalGet('/admin/moderate-comments');
$this->assertSession()
->pageTextContains($this->comment
->getSubject());
$this->assertSession()
->linkExists('Approve');
$this->clickLink('Approve');
$this->drupalGet('/admin/moderate-comments');
$this->assertSession()
->linkNotExists('Approve');
// Ensure that "published" column in table is marked as yes.
$this->assertSession()
->elementTextContains('xpath', "//table/tbody/tr/td[3]", 'Yes');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.