Mercurial > hg > cmmr2012-drupal-site
annotate core/modules/comment/tests/src/Functional/CommentNodeChangesTest.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\Tests\comment\Functional; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\comment\Entity\Comment; |
Chris@0 | 6 use Drupal\field\Entity\FieldConfig; |
Chris@0 | 7 use Drupal\field\Entity\FieldStorageConfig; |
Chris@0 | 8 |
Chris@0 | 9 /** |
Chris@0 | 10 * Tests that comments behave correctly when the node is changed. |
Chris@0 | 11 * |
Chris@0 | 12 * @group comment |
Chris@0 | 13 */ |
Chris@0 | 14 class CommentNodeChangesTest extends CommentTestBase { |
Chris@0 | 15 |
Chris@0 | 16 /** |
Chris@0 | 17 * Tests that comments are deleted with the node. |
Chris@0 | 18 */ |
Chris@0 | 19 public function testNodeDeletion() { |
Chris@0 | 20 $this->drupalLogin($this->webUser); |
Chris@0 | 21 $comment = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName()); |
Chris@0 | 22 $this->assertTrue($comment->id(), 'The comment could be loaded.'); |
Chris@0 | 23 $this->node->delete(); |
Chris@0 | 24 $this->assertFalse(Comment::load($comment->id()), 'The comment could not be loaded after the node was deleted.'); |
Chris@0 | 25 // Make sure the comment field storage and all its fields are deleted when |
Chris@0 | 26 // the node type is deleted. |
Chris@0 | 27 $this->assertNotNull(FieldStorageConfig::load('node.comment'), 'Comment field storage exists'); |
Chris@0 | 28 $this->assertNotNull(FieldConfig::load('node.article.comment'), 'Comment field exists'); |
Chris@0 | 29 // Delete the node type. |
Chris@0 | 30 entity_delete_multiple('node_type', [$this->node->bundle()]); |
Chris@0 | 31 $this->assertNull(FieldStorageConfig::load('node.comment'), 'Comment field storage deleted'); |
Chris@0 | 32 $this->assertNull(FieldConfig::load('node.article.comment'), 'Comment field deleted'); |
Chris@0 | 33 } |
Chris@0 | 34 |
Chris@0 | 35 } |