You are here

protected function FeedsParaMapperTestBase::createBundle in Feeds Paragraphs 8

Creates a paragraph bundle.

Parameters

array $bundle: Includes the bundle name and the field details.

1 call to FeedsParaMapperTestBase::createBundle()
FeedsParaMapperTestBase::createBundles in tests/src/Functional/FeedsParaMapperTestBase.php
Creates the needed Paragraphs bundles in a loop.

File

tests/src/Functional/FeedsParaMapperTestBase.php, line 202

Class

FeedsParaMapperTestBase
Test basic functionality via BrowserTestBase. @todo: tests are failing because some dependencies modules use PrivateTempStore, see https://www.drupal.org/project/feeds/issues/3012342 @todo: for now we applied the patch in the issue, waiting for module…

Namespace

Drupal\Tests\feeds_para_mapper\Functional

Code

protected function createBundle(array $bundle) {
  $this
    ->drupalGet('admin/structure/paragraphs_type/add');
  $edit = array(
    'label' => $bundle['name'],
    'id' => $bundle['name'],
  );
  $this
    ->drupalPostForm(NULL, $edit, t('Save and manage fields'));

  #$message = format_string("Created the paragraph bundle @name.", array('@name' => $bundle['name']));
  $text = t("Saved the @name Paragraphs type.", array(
    '@name' => $bundle['name'],
  ));
  $this
    ->assertSession()
    ->pageTextContains($text);

  // Add A field to the bundle:
  $fields = $bundle['fields'];
  foreach ($fields as $field) {
    $allowed_bundles = array();
    if (isset($field['allowed_bundles'])) {
      $allowed_bundles = $field['allowed_bundles'];
    }
    $path = "admin/structure/paragraphs_type/{$bundle['name']}/fields/add-field";
    $this
      ->createField($path, $field['name'], $field['cardinality'], $field['type'], $field['widget'], $allowed_bundles);
  }
}