Mercurial > hg > cmmr2012-drupal-site
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\comment\Functional; | |
4 | |
5 use Drupal\comment\Entity\Comment; | |
6 use Drupal\field\Entity\FieldConfig; | |
7 use Drupal\field\Entity\FieldStorageConfig; | |
8 | |
9 /** | |
10 * Tests that comments behave correctly when the node is changed. | |
11 * | |
12 * @group comment | |
13 */ | |
14 class CommentNodeChangesTest extends CommentTestBase { | |
15 | |
16 /** | |
17 * Tests that comments are deleted with the node. | |
18 */ | |
19 public function testNodeDeletion() { | |
20 $this->drupalLogin($this->webUser); | |
21 $comment = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName()); | |
22 $this->assertTrue($comment->id(), 'The comment could be loaded.'); | |
23 $this->node->delete(); | |
24 $this->assertFalse(Comment::load($comment->id()), 'The comment could not be loaded after the node was deleted.'); | |
25 // Make sure the comment field storage and all its fields are deleted when | |
26 // the node type is deleted. | |
27 $this->assertNotNull(FieldStorageConfig::load('node.comment'), 'Comment field storage exists'); | |
28 $this->assertNotNull(FieldConfig::load('node.article.comment'), 'Comment field exists'); | |
29 // Delete the node type. | |
30 entity_delete_multiple('node_type', [$this->node->bundle()]); | |
31 $this->assertNull(FieldStorageConfig::load('node.comment'), 'Comment field storage deleted'); | |
32 $this->assertNull(FieldConfig::load('node.article.comment'), 'Comment field deleted'); | |
33 } | |
34 | |
35 } |