You are here

public function UcAddressesOrderTestCase::testOrderEditing in Ubercart Addresses 7

Same name and namespace in other branches
  1. 6.2 tests/uc_addresses.order.test \UcAddressesOrderTestCase::testOrderEditing()

Override of UbercartOrderTestCase::testOrderEditing().

With Ubercart Addresses, address fields on the order administration form have a bit different name. Example: Instead of "billing_first_name", Ubercart Addresses uses "bill_to[address][billing_first_name]". This is done to fix issues with the zone field.

Overrides UbercartOrderTestCase::testOrderEditing

1 call to UcAddressesOrderTestCase::testOrderEditing()
UcAddressesOrderTestCase::testOrderExtraFields in tests/uc_addresses.order.test
Test if editing an order works properly when an extra field is added.

File

tests/uc_addresses.order.test, line 47
Test cases for order admin.

Class

UcAddressesOrderTestCase
Test cases order administration.

Code

public function testOrderEditing() {
  $order = $this
    ->ucCreateOrder($this->customer);
  $this
    ->drupalLogin($this->customer);
  $this
    ->drupalGet('user/' . $this->customer->uid . '/orders');
  $this
    ->assertText(t('My order history'));
  $this
    ->drupalGet('user/' . $this->customer->uid . '/orders/' . $order->order_id);
  $this
    ->assertResponse(200, 'Customer can view their own order.');
  $this
    ->drupalGet('admin/store/orders/' . $order->order_id);
  $this
    ->assertResponse(403, 'Customer may not edit orders.');
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('user/' . $this->customer->uid . '/orders/' . $order->order_id);
  $this
    ->assertText(drupal_strtoupper($order->billing_first_name . ' ' . $order->billing_last_name), 'Found customer name.');
  $edit = array(
    'bill_to[address][billing_first_name]' => $this
      ->randomName(8),
    'bill_to[address][billing_last_name]' => $this
      ->randomName(15),
  );
  $this
    ->drupalPost('admin/store/orders/' . $order->order_id . '/edit', $edit, t('Submit changes'));
  $this
    ->assertText(t('Order changes saved.'));
  $this
    ->assertFieldByName('bill_to[address][billing_first_name]', $edit['bill_to[address][billing_first_name]'], 'Billing first name changed.');
  $this
    ->assertFieldByName('bill_to[address][billing_last_name]', $edit['bill_to[address][billing_last_name]'], 'Billing last name changed.');
}