CommentNodeChangesTest.php in Zircon Profile 8.0        
                          
                  
                        
  
  
  
File
  core/modules/comment/src/Tests/CommentNodeChangesTest.php
  
    View source  
  <?php
namespace Drupal\comment\Tests;
use Drupal\comment\Entity\Comment;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
class CommentNodeChangesTest extends CommentTestBase {
  
  function testNodeDeletion() {
    $this
      ->drupalLogin($this->webUser);
    $comment = $this
      ->postComment($this->node, $this
      ->randomMachineName(), $this
      ->randomMachineName());
    $this
      ->assertTrue($comment
      ->id(), 'The comment could be loaded.');
    $this->node
      ->delete();
    $this
      ->assertFalse(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');
    
    entity_delete_multiple('node_type', array(
      $this->node
        ->bundle(),
    ));
    $this
      ->assertNull(FieldStorageConfig::load('node.comment'), 'Comment field storage deleted');
    $this
      ->assertNull(FieldConfig::load('node.article.comment'), 'Comment field deleted');
  }
}