You are here

public function ParagraphsTest::testParagraphsCdf in Acquia Content Hub 8

Tests acquia_contenthub_cdf format for paragraphs entities inside a node.

File

tests/src/Functional/ParagraphsTest.php, line 85

Class

ParagraphsTest
Tests paragraphs support in Acquia Content Hub module.

Namespace

Drupal\Tests\acquia_contenthub\Functional

Code

public function testParagraphsCdf() {
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('node/add/ch_node_with_paragraphs');
  $this
    ->getSession()
    ->getPage()
    ->findButton('field_client_data_client_data_add_more')
    ->press();
  $this
    ->getSession()
    ->getPage()
    ->find('named', [
    'name' => 'field_client_data_0_subform_field_client_location_addresses_add_more',
  ])
    ->press();
  $this
    ->getSession()
    ->getPage()
    ->find('named', [
    'name' => 'field_client_data_0_subform_field_client_location_addresses_add_more',
  ])
    ->press();
  $title = 'Page_title';
  $edit = [
    'title[0][value]' => $title,
    'field_client_data[0][subform][field_client_name][0][value]' => 'Client Name',
    'field_client_data[0][subform][field_client_tags][0][target_id]' => 'test_term',
    'field_client_data[0][subform][field_client_email][0][value]' => 'test@test.com',
    'field_client_data[0][subform][field_client_location][0][subform][field_address_type]' => 'Work Address',
    'field_client_data[0][subform][field_client_location][0][subform][field_address][0][value]' => 'Test Address',
    'field_client_data[0][subform][field_client_location][1][subform][field_address_type]' => 'Shipping Address',
    'field_client_data[0][subform][field_client_location][1][subform][field_address][0][value]' => 'Another Test Address',
  ];

  // 8.3 has the label 'Save and publish'.
  if (floatval(\Drupal::VERSION) <= 8.300000000000001) {
    $this
      ->submitForm($edit, $this
      ->t('Save and publish'));
  }
  else {
    $this
      ->submitForm($edit, $this
      ->t('Save'));
  }
  $this->node = $this
    ->getNodeByTitle($title);

  // Check format acquia_contenthub_cdf.
  $this
    ->setContentHubEntitySettings();
  $this
    ->checkCdfOutput();
}