You are here

protected function FeedsParaMapperWebTestCase::createBundle in Feeds Paragraphs 7

Creates a paragraph bundle.

Parameters

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

1 call to FeedsParaMapperWebTestCase::createBundle()
FeedsParaMapperWebTestCase::createBundles in tests/FeedsParaMapperWebTestCase.test
Creates the needed Paragraphs bundles in a loop.

File

tests/FeedsParaMapperWebTestCase.test, line 157
Common functionality for all Paragraphs Mapper tests.

Class

FeedsParaMapperWebTestCase
Test basic functionality via DrupalWebTestCase.

Code

protected function createBundle(array $bundle) {
  $this
    ->drupalGet('admin/structure/paragraphs/add');
  $edit = array(
    'name' => $bundle['name'],
    'bundle' => $bundle['name'],
  );
  $this
    ->drupalPost(NULL, $edit, t('Save Paragraph bundle'));
  $message = format_string("Created the paragraph bundle @name.", array(
    '@name' => $bundle['name'],
  ));
  $text = t("The paragraph bundle @name has been added.", array(
    '@name' => $bundle['name'],
  ));
  $this
    ->assertText($text, $message, 'Setup');

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