CommentNodeChangesTest.php in Drupal 10
File
core/modules/comment/tests/src/Functional/CommentNodeChangesTest.php
View source
<?php
namespace Drupal\Tests\comment\Functional;
use Drupal\comment\Entity\Comment;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
class CommentNodeChangesTest extends CommentTestBase {
protected $defaultTheme = 'stark';
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.');
$this
->assertNotNull(FieldStorageConfig::load('node.comment'), 'Comment field storage exists');
$this
->assertNotNull(FieldConfig::load('node.article.comment'), 'Comment field exists');
$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');
}
}