uc_addresses.order.test in Ubercart Addresses 6.2
Same filename and directory in other branches
Test cases for order admin.
File
tests/uc_addresses.order.testView source
<?php
/**
* @file
* Test cases for order admin.
*/
// Ensure UcAddressesTestCase is available.
require_once 'UcAddressesTestCase.test';
// Ensure UbercartOrderTestCase is available.
module_load_include('test', 'uc_order', 'uc_order');
/**
* Test cases order administration.
*/
class UcAddressesOrderTestCase extends UbercartOrderTestCase {
/**
* Describes this test.
*
* @return array
*/
public static function getInfo() {
return array(
'name' => 'Orders',
'description' => 'Ensure that orders function properly when Ubercart Addresses is enabled.',
'group' => 'Ubercart Addresses',
'dependencies' => array(
'ctools',
'token',
'uc_store',
'uc_order',
),
);
}
/**
* Setup modules
*/
public function setUp() {
parent::setUp();
// Install Ubercart Addresses and flush schema cache.
drupal_install_modules(array(
'ctools',
'uc_addresses',
));
drupal_get_schema(NULL, TRUE);
}
/**
* Override of UbercartOrderTestCase::testOrderEditing().
*/
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 . '/order/' . $order->order_id);
$this
->assertText(drupal_strtoupper($order->billing_first_name . ' ' . $order->billing_last_name), 'Found customer name.');
$edit = array(
'billing[billing_first_name]' => $this
->randomName(8),
'billing[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[billing_first_name]', $edit['billing[billing_first_name]'], 'Billing first name changed.');
$this
->assertFieldByName('billing[billing_last_name]', $edit['billing[billing_last_name]'], 'Billing last name changed.');
}
/**
* Test if editing an order works properly when an extra field is added
* that's not registered through Ubercart Addresses hooks.
*/
public function testOrderExtraFields() {
$ret = array();
$definition = array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
);
db_add_field($ret, 'uc_orders', 'delivery_extra_field', $definition);
$this
->testOrderEditing();
}
}
Classes
Name | Description |
---|---|
UcAddressesOrderTestCase | Test cases order administration. |