You are here

protected function TaxRateDefaultWidgetTest::setUp in Commerce Product Tax 8

Overrides CommerceBrowserTestBase::setUp

File

tests/src/Functional/TaxRateDefaultWidgetTest.php, line 60

Class

TaxRateDefaultWidgetTest
Tests the tax rate default widget.

Namespace

Drupal\Tests\commerce_product_tax\Functional

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->createEntity('field_storage_config', [
    'field_name' => 'field_tax_rate',
    'entity_type' => 'commerce_product_variation',
    'type' => 'commerce_tax_rate',
    'cardinality' => -1,
  ]);
  $this->taxType = $this
    ->createEntity('commerce_tax_type', [
    'id' => 'eu_vat',
    'label' => 'EU VAT',
    'plugin' => 'european_union_vat',
  ]);
  $this->field = $this
    ->createEntity('field_config', [
    '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',
      ],
    ],
  ]);
  $display = commerce_get_entity_display('commerce_product_variation', 'default', 'form');
  $display
    ->setComponent('field_tax_rate')
    ->save();
  $this->variation = $this
    ->createEntity('commerce_product_variation', [
    'type' => 'default',
    'sku' => 'foo',
    'title' => $this
      ->randomString(),
    'price' => new Price('12.00', 'USD'),
  ]);
  $this
    ->createEntity('commerce_product', [
    'type' => 'default',
    'title' => 'My product',
    'variations' => [
      $this->variation,
    ],
    'stores' => [
      $this->store,
    ],
  ]);
}