protected function ProductVariationResourceTest::createEntity in Commerce Core 8.2
Creates the entity to be tested.
Return value
\Drupal\Core\Entity\EntityInterface The entity to be tested.
Overrides ResourceTestBase::createEntity
File
- modules/
product/ tests/ src/ Functional/ Jsonapi/ ProductVariationResourceTest.php, line 102
Class
- ProductVariationResourceTest
- JSON:API resource test for variations.
Namespace
Drupal\Tests\commerce_product\Functional\JsonapiCode
protected function createEntity() {
if ($this->entity === NULL) {
$store = $this
->createStore();
$this->product = Product::create([
'type' => 'default',
'title' => $this
->randomMachineName(),
'stores' => [
$store,
],
]);
$this->product
->save();
}
$variation = ProductVariation::create([
'type' => 'default',
'sku' => '456DEF',
'product_id' => $this->product
->id(),
'price' => new Price('4.00', 'USD'),
]);
$variation
->save();
return $variation;
}