public function SchedulerCommerceProductSetupTrait::createProduct in Scheduler 2.x
Creates a product entity.
Parameters
array $values: The values to use for the entity.
Return value
Drupal\commerce_product\Entity\ProductInterface The created product object.
2 calls to SchedulerCommerceProductSetupTrait::createProduct()
- SchedulerBasicProductTest::testProductPublishing in tests/
src/ Functional/ SchedulerBasicProductTest.php - Tests scheduled publishing of a commerce product entity.
- SchedulerBasicProductTest::testProductUnpublishing in tests/
src/ Functional/ SchedulerBasicProductTest.php - Tests scheduled unpublishing of a commerce product entity.
File
- tests/
src/ Traits/ SchedulerCommerceProductSetupTrait.php, line 153
Class
- SchedulerCommerceProductSetupTrait
- Additional setup trait for Scheduler tests that use Commerce Product.
Namespace
Drupal\Tests\scheduler\TraitsCode
public function createProduct(array $values = []) {
// Provide defaults for the critical values.
$values += [
'type' => $this->productTypeName,
'title' => $this
->randomstring(12),
];
/** @var \Drupal\commerce_product\ProductInterface $product */
$product = $this->productStorage
->create($values);
$product
->save();
return $product;
}