function CommentTypeTest::testCommentTypeEditing
Same name in other branches
- 9 core/modules/comment/tests/src/Functional/CommentTypeTest.php \Drupal\Tests\comment\Functional\CommentTypeTest::testCommentTypeEditing()
- 10 core/modules/comment/tests/src/Functional/CommentTypeTest.php \Drupal\Tests\comment\Functional\CommentTypeTest::testCommentTypeEditing()
- 11.x core/modules/comment/tests/src/Functional/CommentTypeTest.php \Drupal\Tests\comment\Functional\CommentTypeTest::testCommentTypeEditing()
Tests editing a comment type using the UI.
File
-
core/
modules/ comment/ tests/ src/ Functional/ CommentTypeTest.php, line 101
Class
- CommentTypeTest
- Ensures that comment type functions work correctly.
Namespace
Drupal\Tests\comment\FunctionalCode
public function testCommentTypeEditing() {
$this->drupalLogin($this->adminUser);
$field = FieldConfig::loadByName('comment', 'comment', 'comment_body');
$this->assertEqual($field->getLabel(), 'Comment', 'Comment body field was found.');
// Change the comment type name.
$this->drupalGet('admin/structure/comment');
$edit = [
'label' => 'Bar',
];
$this->drupalPostForm('admin/structure/comment/manage/comment', $edit, t('Save'));
$this->drupalGet('admin/structure/comment');
$this->assertRaw('Bar', 'New name was displayed.');
$this->clickLink('Manage fields');
$this->assertUrl(Url::fromRoute('entity.comment.field_ui_fields', [
'comment_type' => 'comment',
], [
'absolute' => TRUE,
])->toString(), [], 'Original machine name was used in URL.');
$this->assertCount(1, $this->cssSelect('tr#comment-body'), 'Body field exists.');
// Remove the body field.
$this->drupalPostForm('admin/structure/comment/manage/comment/fields/comment.comment.comment_body/delete', [], t('Delete'));
// Resave the settings for this type.
$this->drupalPostForm('admin/structure/comment/manage/comment', [], t('Save'));
// Check that the body field doesn't exist.
$this->drupalGet('admin/structure/comment/manage/comment/fields');
$this->assertCount(0, $this->cssSelect('tr#comment-body'), 'Body field does not exist.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.