public function UbercartCartSettingsTestCase::testContinueShopping in Ubercart 7.3
Same name and namespace in other branches
- 6.2 uc_cart/uc_cart.test \UbercartCartSettingsTestCase::testContinueShopping()
Tests that continue shopping link returns customer to the correct place.
File
- uc_cart/
tests/ uc_cart.test, line 742 - Shopping cart and checkout tests.
Class
- UbercartCartSettingsTestCase
- Tests the cart settings page.
Code
public 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');
$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'));
// 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),
);
$this
->drupalPost(NULL, $settings, t('Save configuration'));
$this
->drupalPost('cart', array(), t('Continue shopping'));
$url_pass = $this
->getUrl() == url($settings['uc_continue_shopping_url'], array(
'absolute' => TRUE,
));
$this
->assertTrue($url_pass, t('Continue shopping button takes the user to the correct URL.'));
}