You are here

protected function OrderIntegrationTest::setUp in Commerce Core 8.2

Same name in this branch
  1. 8.2 modules/tax/tests/src/Kernel/OrderIntegrationTest.php \Drupal\Tests\commerce_tax\Kernel\OrderIntegrationTest::setUp()
  2. 8.2 modules/log/tests/src/Kernel/OrderIntegrationTest.php \Drupal\Tests\commerce_log\Kernel\OrderIntegrationTest::setUp()

Overrides OrderKernelTestBase::setUp

File

modules/tax/tests/src/Kernel/OrderIntegrationTest.php, line 39

Class

OrderIntegrationTest
Tests integration with orders.

Namespace

Drupal\Tests\commerce_tax\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installConfig([
    'commerce_tax',
  ]);
  $user = $this
    ->createUser([
    'mail' => $this
      ->randomString() . '@example.com',
  ]);
  $this->store
    ->set('prices_include_tax', TRUE);
  $this->store
    ->save();

  // The default store is US-WI, so imagine that the US has VAT.
  TaxType::create([
    'id' => 'us_vat',
    'label' => 'US VAT',
    'plugin' => 'custom',
    'configuration' => [
      'display_inclusive' => TRUE,
      'rates' => [
        [
          'id' => 'standard',
          'label' => 'Standard',
          'percentage' => '0.2',
        ],
      ],
      'territories' => [
        [
          'country_code' => 'US',
          'administrative_area' => 'WI',
        ],
        [
          'country_code' => 'US',
          'administrative_area' => 'SC',
        ],
      ],
    ],
  ])
    ->save();
  $order = Order::create([
    'type' => 'default',
    'store_id' => $this->store
      ->id(),
    'state' => 'draft',
    'mail' => $user
      ->getEmail(),
    'uid' => $user
      ->id(),
    'ip_address' => '127.0.0.1',
    'order_number' => '6',
  ]);
  $order
    ->save();
  $this->order = $this
    ->reloadEntity($order);
}