You are here

protected function FunctionalTestBase::createEntityBundle in Entity Construction Kit (ECK) 8

Adds a bundle for a given entity type.

Parameters

string $entity_type: The entity type to add the bundle for.

string $label: The bundle label.

array $title_overrides: A key / value array of title overrides.

Return value

array The machine name and label of the new bundle.

Throws

\Behat\Mink\Exception\ExpectationException

21 calls to FunctionalTestBase::createEntityBundle()
AccessTest::setUp in tests/src/Functional/AccessTest.php
BundleCRUDTest::identicallyNamedBundleCreation in tests/src/Functional/BundleCRUDTest.php
Tests identically named bundle creation.
BundleCRUDTest::multipleBundleCreation in tests/src/Functional/BundleCRUDTest.php
Tests multiple bundle creation.
BundleCRUDTest::singleBundleCreation in tests/src/Functional/BundleCRUDTest.php
Tests single bundle creation.
BundleCRUDTest::singleBundleCreationWithOverrides in tests/src/Functional/BundleCRUDTest.php
Tests single bundle creation with title overrides.

... See full list

File

tests/src/Functional/FunctionalTestBase.php, line 118

Class

FunctionalTestBase
Provides common functionality for ECK functional tests.

Namespace

Drupal\Tests\eck\Functional

Code

protected function createEntityBundle($entity_type, $label = '', $title_overrides = []) {
  if (empty($label)) {
    $label = $this
      ->randomMachineName();
  }
  $bundle = strtolower($label);
  $edit = [
    'name' => $label,
    'type' => $bundle,
  ];
  foreach ($title_overrides as $field => $title_override) {
    $edit[$field . '_title_override'] = $title_override;
  }
  $this
    ->drupalGet(Url::fromRoute("eck.entity.{$entity_type}_type.add"));
  $this
    ->submitForm($edit, 'Save bundle');
  $this
    ->assertSession()
    ->responseContains("The entity bundle <em class=\"placeholder\">{$label}</em> has been added.");
  return $edit;
}