You are here

protected function ProductVariationGeneratedTitleTest::setUp in Commerce Core 8.2

Overrides CommerceKernelTestBase::setUp

File

modules/product/tests/src/Kernel/ProductVariationGeneratedTitleTest.php, line 57

Class

ProductVariationGeneratedTitleTest
Tests the product variation title generation.

Namespace

Drupal\Tests\commerce_product\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installEntitySchema('commerce_product_variation');
  $this
    ->installEntitySchema('commerce_product');
  $this
    ->installEntitySchema('commerce_product_attribute');
  $this
    ->installEntitySchema('commerce_product_attribute_value');
  $this
    ->installConfig([
    'commerce_product',
  ]);
  ConfigurableLanguage::createFromLangcode('fr')
    ->save();
  $variation_type = ProductVariationType::create([
    'id' => 'generate_title',
    'label' => 'Generate title test',
    'orderItemType' => 'default',
    'generateTitle' => TRUE,
  ]);
  $variation_type
    ->save();
  $this->variationType = $variation_type;
  $product_type = ProductType::create([
    'id' => 'generate_title',
    'label' => 'Generate title test',
    'variationType' => $variation_type
      ->id(),
  ]);
  $product_type
    ->save();
  $this->productType = $product_type;
  $color_attribute = ProductAttribute::create([
    'id' => 'color',
    'label' => 'Color',
  ]);
  $color_attribute
    ->save();
  $this->container
    ->get('commerce_product.attribute_field_manager')
    ->createField($color_attribute, $this->variationType
    ->id());
  $this->attribute = $color_attribute;
}