You are here

protected function ProductVariationAttributeMapperTest::setUp in Commerce Core 8.2

Overrides CommerceKernelTestBase::setUp

File

modules/product/tests/src/Kernel/ProductVariationAttributeMapperTest.php, line 85

Class

ProductVariationAttributeMapperTest
Tests the product variation attribute mapper.

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',
  ]);
  $this->attributeFieldManager = $this->container
    ->get('commerce_product.attribute_field_manager');
  $this->mapper = $this->container
    ->get('commerce_product.variation_attribute_mapper');
  $variation_type = ProductVariationType::load('default');
  $this->colorAttributes = $this
    ->createAttributeSet($variation_type, 'color', [
    'black' => 'Black',
    'blue' => 'Blue',
    'green' => 'Green',
    'red' => 'Red',
    'white' => 'White',
    'yellow' => 'Yellow',
  ]);
  $this->sizeAttributes = $this
    ->createAttributeSet($variation_type, 'size', [
    'small' => 'Small',
    'medium' => 'Medium',
    'large' => 'Large',
  ]);
  $this->ramAttributes = $this
    ->createAttributeSet($variation_type, 'ram', [
    '4gb' => '4GB',
    '8gb' => '8GB',
    '16gb' => '16GB',
    '32gb' => '32GB',
  ]);
  $this->disk1Attributes = $this
    ->createAttributeSet($variation_type, 'disk1', [
    '1tb' => '1TB',
    '2tb' => '2TB',
    '3tb' => '3TB',
  ]);
  $this->disk2Attributes = $this
    ->createAttributeSet($variation_type, 'disk2', [
    '1tb' => '1TB',
    '2tb' => '2TB',
    '3tb' => '3TB',
  ], FALSE);
  $user = $this
    ->createUser([], [
    'administer commerce_product',
  ]);
  $this->container
    ->get('current_user')
    ->setAccount($user);
}