You are here

public function CommerceOrderUIAdminTest::testCommerceOrderUIViewOrderAdmin in Commerce Core 7

Check the integrity of the order admin page and also if a given order is displayed correctly.

File

modules/order/tests/commerce_order_ui.test, line 239
Functional tests for the commerce order UI module.

Class

CommerceOrderUIAdminTest
Functional tests for the commerce order UI module.

Code

public function testCommerceOrderUIViewOrderAdmin() {

  // Log in as a normal user.
  $this
    ->drupalLogin($this->store_customer);

  // Navigate to the order management page, it shouldn't be accessible.
  $this
    ->drupalGet('admin/commerce/orders');
  $this
    ->assertResponse(403, t('Normal user is not able to access the order admin screen'));

  // Log in as store admin.
  $this
    ->drupalLogin($this->store_admin);

  // Navigate to the order management page and check if the order data is
  // really there.
  $this
    ->drupalGet('admin/commerce/orders');
  $this
    ->assertResponse(200, t('Store admin user can access the order admin screen'));
  $this
    ->pass(t('Order admin screen assertions:'));

  // Check if the create an order link is present.
  $this
    ->assertText(t('Create an order'), t('%create text is present', array(
    '%create' => t('Create an order'),
  )));

  // Get the current status of the order.
  $status = commerce_order_status_load($this->order->status);

  // Check if there is at least an order created and the correct one is
  // present.
  $this
    ->assertNoText(t('No orders have been created yet.'), t('Order admin screen has at least one order'));
  $this
    ->assertText($this->order->order_number, t('The order number for the created order is present'));
  $this
    ->assertText($status['title'], t('The order status for the created order is present'));
  $this
    ->assertText($this->store_customer->name, t('The name of the order owner for the created order is present'));

  // Check if the links for editing the order are present.
  $links = menu_contextual_links('commerce-order', 'admin/commerce/orders', array(
    $this->order->order_id,
  ));

  // Reset the cache as we don't want to keep the lock.
  entity_get_controller('commerce_order')
    ->resetCache();
  $this
    ->assertRaw(theme('links', array(
    'links' => $links,
    'attributes' => array(
      'class' => array(
        'links',
        'inline',
        'operations',
      ),
    ),
  )), t('Links for orders are present'));
  $this
    ->drupalGet('admin/commerce/orders/' . $this->order->order_id . '/view');
  $this
    ->assertResponse(200, t('Store admin user can access the order view page'));
}