You are here

protected function ProductBehaviorInvocationTest::createEntity 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::createEntity()

Creates new entity.

Parameters

string $action: Rabbit Hole action.

Return value

\Drupal\Core\Entity\EntityInterface Created entity.

Overrides RabbitHoleBehaviorInvocationTestBase::createEntity

File

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

Class

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

Namespace

Drupal\Tests\rh_commerce\Functional

Code

protected function createEntity($action = NULL) {
  $values = [];
  if (isset($action)) {
    $values['rh_action'] = $action;
  }
  $product = Product::create($values + [
    'title' => $this
      ->randomString(),
    'type' => $this->productType
      ->id(),
    'stores' => [
      $this
        ->createStore(),
    ],
  ]);
  $product
    ->save();
  return $product;
}