You are here

protected function TaxNumberTest::setUp in Commerce Core 8.2

Overrides CommerceWebDriverTestBase::setUp

File

modules/tax/tests/src/FunctionalJavascript/TaxNumberTest.php, line 65

Class

TaxNumberTest
Tests the tax number widget and formatter.

Namespace

Drupal\Tests\commerce_tax\FunctionalJavascript

Code

protected function setUp() : void {
  parent::setUp();
  $this->store
    ->set('billing_countries', [
    'RS',
    'ME',
    'MK',
  ]);
  $this->store
    ->save();

  // The tax number field is not exposed by default.
  $form_display = commerce_get_entity_display('profile', 'customer', 'form');
  $form_display
    ->setComponent('tax_number', [
    'type' => 'commerce_tax_number_default',
  ]);
  $form_display
    ->save();

  // Limit the available countries.
  $field = FieldConfig::loadByName('profile', 'customer', 'tax_number');
  $field
    ->setSetting('countries', [
    'RS',
    'ME',
  ]);
  $field
    ->save();
  $this->customerProfile = Profile::create([
    'type' => 'customer',
    'uid' => 0,
    'address' => [
      'country_code' => 'RS',
      'postal_code' => '11000',
      'locality' => 'Belgrade',
      'address_line1' => 'Cetinjska 15',
      'given_name' => 'Dusan',
      'family_name' => 'Popov',
    ],
  ]);
  $this->customerProfile
    ->save();
  $order_item = OrderItem::create([
    'type' => 'default',
    'unit_price' => [
      'number' => '999',
      'currency_code' => 'USD',
    ],
  ]);
  $order_item
    ->save();
  $this->order = Order::create([
    'type' => 'default',
    'store_id' => $this->store,
    'uid' => $this->adminUser,
    'billing_profile' => $this->customerProfile,
    'order_items' => [
      $order_item,
    ],
    'state' => 'completed',
  ]);
  $this->order
    ->save();
}