public function CartSettingsTest::testContinueShopping in Ubercart 8.4
Tests that continue shopping link returns customer to the correct place.
File
- uc_cart/
tests/ src/ Functional/ CartSettingsTest.php, line 164
Class
- CartSettingsTest
- Tests the cart settings page.
Namespace
Drupal\Tests\uc_cart\FunctionalCode
public function testContinueShopping() {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
// Continue shopping link should take you back to the product page.
$this
->drupalGet('node/' . $this->product
->id());
$this
->submitForm([], 'Add to cart');
// Check that 'Continue shopping' link appears on the page.
$assert
->linkExists('Continue shopping');
$links = $this
->xpath('//a[@href="' . $this->product
->toUrl()
->toString() . '"]');
$this
->assertTrue(isset($links[0]), 'Continue shopping link returns to the product page.');
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/store/config/cart');
// Check that continue shopping element display field exists.
$assert
->fieldExists('uc_continue_shopping_type');
// Check that default continue shopping link URL field exists.
$assert
->fieldExists('uc_continue_shopping_url');
// Test continue shopping button that sends users to a fixed URL.
$settings = [
'uc_continue_shopping_type' => 'button',
'uc_continue_shopping_use_last_url' => FALSE,
'uc_continue_shopping_url' => 'admin/store',
];
$this
->submitForm($settings, 'Save configuration');
$this
->drupalGet('cart');
$this
->submitForm([], 'Continue shopping');
$this
->assertEquals(Url::fromUri('base:' . $settings['uc_continue_shopping_url'], [
'absolute' => TRUE,
])
->toString(), $this
->getUrl(), 'Continue shopping button takes the user to the correct URL.');
}