diff --git a/core/modules/comment/src/Tests/CommentNonNodeTest.php b/core/modules/comment/src/Tests/CommentNonNodeTest.php index b597dcc..3224510 100644 --- a/core/modules/comment/src/Tests/CommentNonNodeTest.php +++ b/core/modules/comment/src/Tests/CommentNonNodeTest.php @@ -426,19 +426,42 @@ function testCommentFunctionality() { $this->assertEqual($field_storage->getCardinality(), 1); // Test the new entity commenting inherits default. + $this->drupalGet('entity_test/add'); + $this->assertFieldChecked('edit-comment-0-status-1'); + $this->assertNoFieldChecked('edit-comment-0-status-2'); + $this->assertNoField('edit-comment-0-status-0'); + + // Create new entity in user interface. + $random_label = $this->randomMachineName(); + $edit = array( + 'name[0][value]' => $random_label, + ); + $this->drupalPostForm(NULL, $edit, t('Save')); + preg_match('|entity_test/manage/(\d+)|', $this->url, $match); + $id = $match[1]; + + $this->drupalGet('comment/reply/entity_test/' . $id . '/comment'); + $this->assertResponse(200); + $this->assertNoFieldByXPath('//form[contains(@class, "comment-comment-form")]//input[@name="subject[0][value]"]', '', 'Subject field not found.'); + $this->assertNoFieldByXPath('//form[contains(@class, "comment-comment-form")]//textarea[@name="comment_body[0][value]"]', '', 'Comment field not found.'); + + // Create new entity programmatically. $random_label = $this->randomMachineName(); $data = array('bundle' => 'entity_test', 'name' => $random_label); $new_entity = entity_create('entity_test', $data); $new_entity->save(); $this->drupalGet('entity_test/manage/' . $new_entity->id()); - $this->assertfieldChecked('edit-field-foobar-0-status-1'); - $this->assertNoFieldChecked('edit-field-foobar-0-status-2'); + $this->assertFieldChecked('edit-comment-0-status-1'); + $this->assertNoFieldChecked('edit-comment-0-status-2'); + $this->assertNoField('edit-comment-0-status-0'); + $this->assertNoFieldChecked('edit-field-foobar-0-status-1'); + $this->assertFieldChecked('edit-field-foobar-0-status-2'); $this->assertNoField('edit-field-foobar-0-status-0'); $this->drupalGet('comment/reply/entity_test/' . $new_entity->id() . '/comment'); $this->assertResponse(200); - $this->assertNoFieldById('edit-subject-0-value', 'Subject field not found.'); - $this->assertNoFieldById('edit-comment-body-0-value', 'Comment field not found.'); + $this->assertNoFieldByXPath('//form[contains(@class, "comment-comment-form")]//input[@name="subject[0][value]"]', '', 'Subject field not found.'); + $this->assertNoFieldByXPath('//form[contains(@class, "comment-comment-form")]//textarea[@name="comment_body[0][value]"]', '', 'Comment field not found.'); } /**