public function CartCheckoutTest::testCheckoutCartPane in Ubercart 8.4
Tests cart pane on checkout page.
File
- uc_cart/
tests/ src/ Functional/ CartCheckoutTest.php, line 245
Class
- CartCheckoutTest
- Tests the cart and checkout functionality.
Namespace
Drupal\Tests\uc_cart\FunctionalCode
public function testCheckoutCartPane() {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
// Add a product to the cart.
$this
->addToCart($this->product);
$this
->drupalGet('cart');
// Verify the product quantity is 1.
$assert
->fieldValueEquals('items[0][qty]', 1);
// Test the checkout pane.
$this
->submitForm([], 'Checkout');
$assert
->pageTextContains($this->product
->label(), 'The product title is displayed.');
$assert
->pageTextContains('1 ×', 'The product quantity is displayed.');
$assert
->pageTextContains(uc_currency_format($this->product->price->value), 'The product price is displayed.');
// Change the quantity.
$qty = mt_rand(3, 100);
$this
->drupalGet('cart');
$this
->submitForm([
'items[0][qty]' => $qty,
], 'Checkout');
// Test the checkout pane.
$assert
->pageTextContains($this->product
->label(), 'The product title is displayed.');
$assert
->pageTextContains($qty . ' ×', 'The updated product quantity is displayed.');
$assert
->pageTextContains(uc_currency_format($qty * $this->product->price->value), 'The updated product price is displayed.');
}