public function CommentTypeTest::testCommentTypeEditing in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/comment/src/Tests/CommentTypeTest.php \Drupal\comment\Tests\CommentTypeTest::testCommentTypeEditing()
Tests editing a comment type using the UI.
File
- core/
modules/ comment/ src/ Tests/ CommentTypeTest.php, line 98 - Contains \Drupal\comment\Tests\CommentTypeTest.
Class
- CommentTypeTest
- Ensures that comment type functions work correctly.
Namespace
Drupal\comment\TestsCode
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 = array(
'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(\Drupal::url('entity.comment.field_ui_fields', [
'comment_type' => 'comment',
], [
'absolute' => TRUE,
]), [], 'Original machine name was used in URL.');
$this
->assertTrue($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', array(), t('Delete'));
// Resave the settings for this type.
$this
->drupalPostForm('admin/structure/comment/manage/comment', array(), t('Save'));
// Check that the body field doesn't exist.
$this
->drupalGet('admin/structure/comment/manage/comment/fields');
$this
->assertFalse($this
->cssSelect('tr#comment-body'), 'Body field does not exist.');
}