You are here

protected function ProductBehaviorInvocationTest::createEntityBundle in Rabbit Hole 2.x

Same name and namespace in other branches
  1. 8 modules/rh_commerce/tests/src/Functional/ProductBehaviorInvocationTest.php \Drupal\Tests\rh_commerce\Functional\ProductBehaviorInvocationTest::createEntityBundle()

Creates new entity bundle.

Parameters

string $action: Rabbit Hole action.

Return value

string ID of the created bundle.

Overrides RabbitHoleBehaviorInvocationTestBase::createEntityBundle

File

modules/rh_commerce/tests/src/Functional/ProductBehaviorInvocationTest.php, line 39

Class

ProductBehaviorInvocationTest
Test that rabbit hole behaviors are invoked correctly for commerce products.

Namespace

Drupal\Tests\rh_commerce\Functional

Code

protected function createEntityBundle($action = NULL) {
  $storage = \Drupal::entityTypeManager()
    ->getStorage('commerce_product_type');
  $product_type = $storage
    ->create([
    'id' => mb_strtolower($this
      ->randomMachineName()),
    'label' => $this
      ->randomString(),
  ]);
  $storage
    ->save($product_type);
  $this->productType = $product_type;
  if (isset($action)) {
    $this->behaviorSettingsManager
      ->saveBehaviorSettings([
      'action' => $action,
      'allow_override' => TRUE,
    ], 'commerce_product_type', $this->productType
      ->id());
  }
  return $this->productType
    ->id();
}