You are here

public function UbercartOrderTestCase::testOrderEditing in Ubercart 7.3

Same name and namespace in other branches
  1. 6.2 uc_order/uc_order.test \UbercartOrderTestCase::testOrderEditing()

Tests admin editing of orders.

File

uc_order/tests/uc_order.test, line 123
Tests for Ubercart orders.

Class

UbercartOrderTestCase
Tests for Ubercart orders.

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(
    'billing_first_name' => $this
      ->randomName(8),
    '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('billing_first_name', $edit['billing_first_name'], 'Billing first name changed.');
  $this
    ->assertFieldByName('billing_last_name', $edit['billing_last_name'], 'Billing last name changed.');
}