You are here

public function OrderTest::testOrderView in Ubercart 8.4

Tests order admin View.

File

uc_order/tests/src/Functional/OrderTest.php, line 164

Class

OrderTest
Tests for Ubercart orders.

Namespace

Drupal\Tests\uc_order\Functional

Code

public function testOrderView() {

  /** @var \Drupal\Tests\WebAssert $assert */
  $assert = $this
    ->assertSession();
  $order = $this
    ->ucCreateOrder($this->customer);
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('admin/store/orders/' . $order
    ->id());
  $billing_address = $order
    ->getAddress('billing');

  // Check for billing first name, billing last name, billing street1
  // and billing street2.
  $assert
    ->pageTextContains(mb_strtoupper($billing_address
    ->getFirstName()));
  $assert
    ->pageTextContains(mb_strtoupper($billing_address
    ->getLastName()));
  $assert
    ->pageTextContains(mb_strtoupper($billing_address
    ->getStreet1()));
  $assert
    ->pageTextContains(mb_strtoupper($billing_address
    ->getStreet2()));

  // Some country formats don't use City in addresses.
  $country = \Drupal::service('country_manager')
    ->getCountry($billing_address
    ->getCountry());
  if (strpos(implode('', $country
    ->getAddressFormat()), 'city') === FALSE) {

    // Check for billing city.
    $assert
      ->pageTextContains(mb_strtoupper($billing_address
      ->getCity()));
  }
  $delivery_address = $order
    ->getAddress('delivery');

  // Check for delivery first name, delivery last name, delivery street1
  // and delivery street2.
  $assert
    ->pageTextContains(mb_strtoupper($delivery_address
    ->getFirstName()));
  $assert
    ->pageTextContains(mb_strtoupper($delivery_address
    ->getLastName()));
  $assert
    ->pageTextContains(mb_strtoupper($delivery_address
    ->getStreet1()));
  $assert
    ->pageTextContains(mb_strtoupper($delivery_address
    ->getStreet2()));
  $country = \Drupal::service('country_manager')
    ->getCountry($delivery_address
    ->getCountry());
  if (strpos(implode('', $country
    ->getAddressFormat()), 'city') === FALSE) {

    // Check for delivery city.
    $assert
      ->pageTextContains(mb_strtoupper($delivery_address
      ->getCity()));
  }
  $assert
    ->linkExists($order
    ->getOwnerId(), 0, 'Link to customer account page found.');
  $assert
    ->linkExists($order
    ->getEmail(), 0, 'Link to customer email address found.');
}