You are here

protected function ProductBehaviorSettingsFormTest::createEntity in Rabbit Hole 8

Same name and namespace in other branches
  1. 2.x modules/rh_commerce/tests/src/Functional/ProductBehaviorSettingsFormTest.php \Drupal\Tests\rh_commerce\Functional\ProductBehaviorSettingsFormTest::createEntity()

Creates new entity.

Parameters

string $action: Rabbit Hole action.

Return value

int ID of the created entity.

Overrides RabbitHoleBehaviorSettingsFormTestBase::createEntity

File

modules/rh_commerce/tests/src/Functional/ProductBehaviorSettingsFormTest.php, line 92

Class

ProductBehaviorSettingsFormTest
Test the functionality of the rabbit hole form additions to Commerce Product.

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->bundle
      ->id(),
    'stores' => [
      $this->store,
    ],
  ]);
  $product
    ->save();
  return $product
    ->id();
}