public function CartSettingsTest::testAddToCartRedirect in Ubercart 8.4
Tests add-to-cart redirection.
File
- uc_cart/
tests/ src/ Functional/ CartSettingsTest.php, line 57
Class
- CartSettingsTest
- Tests the cart settings page.
Namespace
Drupal\Tests\uc_cart\FunctionalCode
public function testAddToCartRedirect() {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/store/config/cart');
// Check that add to cart redirect field exists.
$assert
->fieldExists('uc_add_item_redirect');
$redirect = 'admin/store';
$this
->drupalGet('admin/store/config/cart');
$this
->submitForm([
'uc_add_item_redirect' => $redirect,
], 'Save configuration');
$this
->drupalGet('node/' . $this->product
->id());
$this
->submitForm([], 'Add to cart');
$this
->assertEquals(Url::fromUri('base:' . $redirect, [
'absolute' => TRUE,
])
->toString(), $this
->getUrl(), 'Add to cart redirect takes user to the correct URL.');
}