You are here

public function IntegrationTest::checkCdfOutput in Acquia Content Hub 8

Ensures the CDF output is what we expect it to be.

Parameters

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

string|null $view_mode: The view mode to check in the CDF.

1 call to IntegrationTest::checkCdfOutput()
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 349

Class

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

Namespace

Drupal\Tests\acquia_contenthub\Functional

Code

public function checkCdfOutput(NodeInterface $entity, $view_mode = NULL) {
  $output = $this
    ->drupalGetCdf('acquia-contenthub-cdf/' . $entity
    ->getEntityTypeId() . '/' . $entity
    ->id());
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  if (!empty($view_mode)) {
    $this
      ->assertTrue(isset($output['entities']['0']['metadata']), 'Metadata is present');
    $this
      ->assertTrue(isset($output['entities']['0']['metadata']['view_modes'][$view_mode]), $this
      ->t('View mode %view_mode is present', [
      '%view_mode' => $view_mode,
    ]));
  }
  else {
    $this
      ->assertFalse(isset($output['entities']['0']['metadata']), 'Metadata is not present');
  }
}