You are here

function UbercartCartSettingsTestCase::testContinueShopping in Ubercart 6.2

Same name and namespace in other branches
  1. 7.3 uc_cart/tests/uc_cart.test \UbercartCartSettingsTestCase::testContinueShopping()

File

uc_cart/uc_cart.test, line 518
Shopping cart and checkout tests.

Class

UbercartCartSettingsTestCase
Tests the cart settings page.

Code

function testContinueShopping() {

  // Continue shopping link should take you back to the product page.
  $this
    ->drupalPost('node/' . $this->product->nid, array(), t('Add to cart'));
  $this
    ->assertLink(t('Continue shopping'), 0, t('Continue shopping link appears on the page.'));
  $links = $this
    ->xpath('//a[@href="' . url('node/' . $this->product->nid, array(
    'absolute' => FALSE,
  )) . '"]');
  $this
    ->assertTrue(isset($links[0]), t('Continue shopping link returns to the product page.'));
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('admin/store/settings/cart/edit');
  $this
    ->assertField('uc_continue_shopping_type', t('Continue shopping element display field exists'));
  $this
    ->assertField('uc_continue_shopping_url', t('Default continue shopping link URL field exists'));
  $this
    ->assertField('uc_continue_shopping_text', t('Custom continue shopping link text field exists'));

  // Test continue shopping button that sends users to a fixed URL.
  $settings = array(
    'uc_continue_shopping_type' => 'button',
    'uc_continue_shopping_use_last_url' => FALSE,
    'uc_continue_shopping_url' => $this
      ->randomName(8),
    'uc_continue_shopping_text' => $this
      ->randomName(16),
  );
  $this
    ->drupalPost(NULL, $settings, t('Save configuration'));
  $this
    ->drupalPost('cart', array(), $settings['uc_continue_shopping_text']);
  $url_pass = $this
    ->getUrl() == url($settings['uc_continue_shopping_url'], array(
    'absolute' => TRUE,
  ));
  $this
    ->assertTrue($url_pass, t('Continue shopping button is properly labelled, and takes the user to the correct URL.'));
}