You are here

protected function ProductTaxKernelTestBase::setUp in Commerce Product Tax 8

Overrides CommerceKernelTestBase::setUp

1 call to ProductTaxKernelTestBase::setUp()
TaxRateResolverTest::setUp in tests/src/Kernel/TaxRateResolverTest.php
1 method overrides ProductTaxKernelTestBase::setUp()
TaxRateResolverTest::setUp in tests/src/Kernel/TaxRateResolverTest.php

File

tests/src/Kernel/ProductTaxKernelTestBase.php, line 44

Class

ProductTaxKernelTestBase
Provides a base class for Commerce product tax kernel tests.

Namespace

Drupal\Tests\commerce_product_tax\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installEntitySchema('commerce_product');
  $this
    ->installEntitySchema('commerce_product_variation');
  $this
    ->installConfig([
    'commerce_product',
  ]);
  $field_storage = FieldStorageConfig::create([
    'field_name' => 'field_tax_rate',
    'entity_type' => 'commerce_product_variation',
    'type' => 'commerce_tax_rate',
    'cardinality' => -1,
  ]);
  $field_storage
    ->save();
  $tax_type = TaxType::create([
    'id' => 'eu_vat',
    'label' => 'EU VAT',
    'plugin' => 'european_union_vat',
  ]);
  $tax_type
    ->save();
  $this->taxType = $this
    ->reloadEntity($tax_type);
  $field = FieldConfig::create([
    'field_name' => 'field_tax_rate',
    'entity_type' => 'commerce_product_variation',
    'label' => 'Tax rate',
    'bundle' => 'default',
    'required' => TRUE,
    'settings' => [
      'tax_type' => 'eu_vat',
      'allowed_zones' => [
        'fr',
        'de',
      ],
    ],
  ]);
  $field
    ->save();
  $this->field = $this
    ->reloadEntity($field);
  EntityFormDisplay::load('commerce_product_variation.default.default')
    ->setComponent('field_tax_rate')
    ->save();
}