You are here

public function IntegrationTest::checkFieldAccessViewMode in Acquia Content Hub 8

Checks if the Test Field rendered at View Modes endpoint.

Parameters

\Drupal\node\NodeInterface $entity: The entity.

string $view_mode: The view mode.

bool $access: Expected result.

bool $field_access: Access to the field.

1 call to IntegrationTest::checkFieldAccessViewMode()
IntegrationTest::testFramework in tests/src/Functional/IntegrationTest.php
Tests various operations via the Acquia Content Hub admin UI.

File

tests/src/Functional/IntegrationTest.php, line 405

Class

IntegrationTest
Tests the overall functionality of the Acquia Content Hub module.

Namespace

Drupal\Tests\acquia_contenthub\Functional

Code

public function checkFieldAccessViewMode(NodeInterface $entity, $view_mode, $access = TRUE, $field_access = TRUE) {

  // Tell the test module to disable access to the field.
  \Drupal::state()
    ->set('field.test_boolean_field_access_field', $field_access ? '' : 'test_field_01');
  $this
    ->drupalGet("acquia-contenthub/display/node/{$entity->id()}/{$view_mode}");
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  if ($access) {
    $this
      ->assertText('field_test_01_on');
  }
  else {
    $this
      ->assertNoText('field_test_01_on');
  }
}