You are here

public function CommerceOrderUIAdminTest::testCommerceOrderUIHelpText in Commerce Core 7

Test the helper text of an order.

File

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

Class

CommerceOrderUIAdminTest
Functional tests for the commerce order UI module.

Code

public function testCommerceOrderUIHelpText() {

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

  // Navigate to the page to configure the helper text.
  $this
    ->drupalGet('admin/commerce/config/order');
  $this
    ->assertResponse(403, t('Normal user is not able to configure the helper text for orders'));

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

  // Navigate to the page to configure the helper text.
  $this
    ->drupalGet('admin/commerce/config/order');
  $this
    ->assertResponse(200, t('Store admin user can configure the helper text for orders'));

  // Check the integrity of the form.
  $this
    ->assertFieldById('edit-commerce-order-help-text', NULL, t('Order help text textarea is available'));

  // Save a random content for the help text.
  $edit = array(
    'commerce_order_help_text' => $this
      ->randomName(),
  );
  $this
    ->drupalPost(NULL, $edit, t('Save configuration'));

  // Check if the text has been stored
  $this
    ->assertText(t('The configuration options have been saved.'), t('Confirmation message for saving the helper text is displayed'));
  $this
    ->assertFieldById('edit-commerce-order-help-text', $edit['commerce_order_help_text'], t('Order help text textarea displays the stored helper text'));
  $this
    ->assertTrue(variable_get('commerce_order_help_text', '') == $edit['commerce_order_help_text'], t('Order help text saved in database'));

  // Check if the text is displayed in the order creation page.
  $this
    ->drupalGet('admin/commerce/orders/add');
  $this
    ->assertText($edit['commerce_order_help_text'], t('Order help text message displayed in the order creation page'));
}