You are here

protected function CommentAlterTestBase::assertAlterableField in Comment Alter 8

Asserts that alterable field is present on the comment form as expected.

Checks if the alterable field is re-orderable and is present on the comment forms.

Parameters

string $field_name: Field added to the entity_test_bundle.

6 calls to CommentAlterTestBase::assertAlterableField()
CommentAlterListStringTest::testOptionsSelectMultiple in tests/src/Functional/CommentAlterListStringTest.php
Tests for multi-valued List (string) fields comment altering.
CommentAlterListStringTest::testOptionsSelectSingle in tests/src/Functional/CommentAlterListStringTest.php
Tests for single valued List (string) fields comment altering.
CommentAlterNodeReferenceTest::testEntityReferenceFieldMultiple in tests/src/Functional/CommentAlterNodeReferenceTest.php
Tests for multi-valued node reference field comment altering.
CommentAlterNodeReferenceTest::testEntityReferenceFieldSingle in tests/src/Functional/CommentAlterNodeReferenceTest.php
Tests for single valued node reference field comment altering.
CommentAlterTextTest::testTextFieldMultiple in tests/src/Functional/CommentAlterTextTest.php
Tests for multi-valued text field comment altering.

... See full list

File

tests/src/Functional/CommentAlterTestBase.php, line 168

Class

CommentAlterTestBase
Base class for Comment Alter test cases.

Namespace

Drupal\Tests\comment_alter\Functional

Code

protected function assertAlterableField($field_name) {
  $this
    ->drupalGet('comment/reply/' . $this->entityType . '/' . $this->entity
    ->id() . '/comment');
  $comment_display_form = entity_get_form_display('comment', 'comment', 'default');
  $comment_field = $this->entityType . '_' . $this->bundle . '_comment_alter_' . $field_name;
  $this
    ->assertSession()
    ->fieldExists($field_name);

  // To make sure that site builder can reorder the fields from the UI.
  $this
    ->assertTrue($comment_display_form
    ->getComponent($comment_field), 'Alterable fields is present in the comment form display.');
}