You are here

protected function FieldPermissionsCommentTest::checkBaseCommentFieldFunctionality in Field Permissions 8.2

Same name and namespace in other branches
  1. 8 tests/src/Functional/FieldPermissionsCommentTest.php \Drupal\Tests\field_permissions\Functional\FieldPermissionsCommentTest::checkBaseCommentFieldFunctionality()

Ensures basic field functionality is working without field permissions.

1 call to FieldPermissionsCommentTest::checkBaseCommentFieldFunctionality()
FieldPermissionsCommentTest::testFieldPermissionComment in tests/src/Functional/FieldPermissionsCommentTest.php
Test field permissions on comments.

File

tests/src/Functional/FieldPermissionsCommentTest.php, line 189

Class

FieldPermissionsCommentTest
Test field permissions with the comment module and fields.

Namespace

Drupal\Tests\field_permissions\Functional

Code

protected function checkBaseCommentFieldFunctionality() {
  $edit = [];
  $this
    ->drupalLogin($this->adminUser);

  // Node add.
  $this
    ->drupalGet('node/add/article');
  $this->node = $this
    ->drupalCreateNode([
    'type' => 'article',
    'uid' => $this->limitedUser
      ->id(),
  ]);
  $this
    ->drupalGet('node/' . $this->node
    ->id());

  // Add comment to node.
  $edit['subject[0][value]'] = $this->commentSubject;
  $edit[$this->fieldName . '[0][value]'] = $this->fieldText;
  $this
    ->submitForm($edit, 'Save');
  $this
    ->drupalGet('node/' . $this->node
    ->id());
  $this
    ->assertSession()
    ->assertEscaped($this->fieldText);
  $this
    ->assertSession()
    ->assertEscaped($this->commentSubject);
  $this
    ->drupalLogout();
  $this
    ->drupalLogin($this->limitedUser);

  // Test visibility first comment by admin.
  $this
    ->drupalGet('node/' . $this->node
    ->id());
  $this
    ->assertSession()
    ->assertEscaped($this->fieldText);
  $this
    ->assertSession()
    ->pageTextContains($this->commentSubject);

  // Add second comment to node.
  $edit = [];
  $edit['subject[0][value]'] = 'Limit User comment subject';
  $edit[$this->fieldName . '[0][value]'] = 'Limit User comment body';
  $this
    ->submitForm($edit, 'Save');
  $this
    ->drupalGet('node/' . $this->node
    ->id());

  // Test visibility second comment by limituser..
  $this
    ->assertSession()
    ->pageTextContains('Limit User comment subject');
  $this
    ->assertSession()
    ->pageTextContains('Limit User comment body');
  $this
    ->drupalLogout();
}