You are here

public function IntegrationTest::checkCdfFieldAccess in Acquia Content Hub 8

Ensures the test field is present or not in CDF output.

Parameters

\Drupal\node\NodeInterface $entity: The entity to be used.

bool $access: Expected result.

bool $field_access: Access to the test field.

1 call to IntegrationTest::checkCdfFieldAccess()
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 317

Class

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

Namespace

Drupal\Tests\acquia_contenthub\Functional

Code

public function checkCdfFieldAccess(NodeInterface $entity, $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');
  $output = $this
    ->drupalGetCdf('acquia-contenthub-cdf/' . $entity
    ->getEntityTypeId() . '/' . $entity
    ->id());
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  if ($access) {
    $this
      ->assertTrue(isset($output['entities']['0']['attributes']['test_field_01']), 'Test Field is present');
  }
  else {
    $this
      ->assertFalse(isset($output['entities']['0']['attributes']['test_field_01']), 'Test Field is not present');
  }
}