You are here

protected function MonitoringCommerceTest::setUp in Monitoring 8

Overrides MonitoringTestBase::setUp

File

tests/src/Functional/MonitoringCommerceTest.php, line 34

Class

MonitoringCommerceTest
Tests the commerce turnover sensor.

Namespace

Drupal\Tests\monitoring\Functional

Code

protected function setUp() {
  parent::setUp();
  $this->account = $this
    ->drupalCreateUser([
    'administer commerce_order',
    'administer commerce_currency',
    'administer commerce_store',
    'administer commerce_order_type',
    'administer monitoring',
    'monitoring reports',
  ]);
  $this
    ->drupalLogin($this->account);

  // Enable currencies.
  $edit = [
    'currency_codes[]' => [
      'CHF',
      'EUR',
    ],
  ];
  $this
    ->drupalPostForm('admin/commerce/config/currencies/add', $edit, t('Add'));

  // Create a default store.
  $edit = [
    'name[0][value]' => 'Default',
    'mail[0][value]' => 'test@example.com',
    'address[0][address][country_code]' => 'CH',
    'address[0][address][address_line1]' => 'Demo street',
    'address[0][address][locality]' => 'Demo city',
    'address[0][address][postal_code]' => '1234',
    'default_currency' => 'CHF',
  ];
  $this
    ->drupalPostForm('store/add/online', $edit, t('Save'));

  // Create an order item type
  $edit = [
    'id' => 'test',
    'label' => 'Test',
    'orderType' => 'default',
  ];
  $this
    ->drupalPostForm('admin/commerce/config/order-item-types/add', $edit, t('Save'));
}