class CommentNodeChangesTest
Same name and namespace in other branches
- 11.x core/modules/comment/tests/src/Functional/CommentNodeChangesTest.php \Drupal\Tests\comment\Functional\CommentNodeChangesTest
Tests that comments behave correctly when the node is changed.
@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\comment\Functional\CommentTestBase uses \Drupal\comment\Tests\CommentTestTrait implements \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\comment\Functional\CommentNodeChangesTest implements \Drupal\Tests\comment\Functional\CommentTestBase
- class \Drupal\Tests\comment\Functional\CommentTestBase uses \Drupal\comment\Tests\CommentTestTrait implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of CommentNodeChangesTest
File
-
core/
modules/ comment/ tests/ src/ Functional/ CommentNodeChangesTest.php, line 14
Namespace
Drupal\Tests\comment\FunctionalView source
class CommentNodeChangesTest extends CommentTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests that comments are deleted with the node.
*/
public function testNodeDeletion() {
$this->drupalLogin($this->webUser);
$comment = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName());
$this->assertInstanceOf(Comment::class, $comment);
$this->node
->delete();
$this->assertNull(Comment::load($comment->id()), 'The comment could not be loaded after the node was deleted.');
// Make sure the comment field storage and all its fields are deleted when
// the node type is deleted.
$this->assertNotNull(FieldStorageConfig::load('node.comment'), 'Comment field storage exists');
$this->assertNotNull(FieldConfig::load('node.article.comment'), 'Comment field exists');
// Delete the node type.
$this->node
->get('type')->entity
->delete();
$this->assertNull(FieldStorageConfig::load('node.comment'), 'Comment field storage deleted');
$this->assertNull(FieldConfig::load('node.article.comment'), 'Comment field deleted');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.