You are here

protected function CartBrowserTestTrait::postAddToCart in Commerce Core 8.2

Posts the add to cart form for a product.

Parameters

\Drupal\commerce_product\Entity\ProductInterface $product: The product.

array $edit: The form array.

Throws

\Exception

4 calls to CartBrowserTestTrait::postAddToCart()
AddToCartFormTest::testCartAssignment in modules/cart/tests/src/Functional/AddToCartFormTest.php
Test assigning an anonymous cart to a logged in user.
AddToCartFormTest::testExposedOrderItemFields in modules/cart/tests/src/Functional/AddToCartFormTest.php
Tests ability to expose order item fields on the add to cart form.
AddToCartFormTest::testProductAddToCartForm in modules/cart/tests/src/Functional/AddToCartFormTest.php
Test adding a product to the cart.
AddToCartFormTest::testProductAddToCartFormValidations in modules/cart/tests/src/Functional/AddToCartFormTest.php
Test adding an unavailable product to the cart.

File

modules/cart/tests/src/Traits/CartBrowserTestTrait.php, line 24

Class

CartBrowserTestTrait
Defines a trait for commerce_cart functional tests.

Namespace

Drupal\Tests\commerce_cart\Traits

Code

protected function postAddToCart(ProductInterface $product, array $edit = []) {
  $this
    ->drupalGet('product/' . $product
    ->id());
  $this
    ->assertSession()
    ->buttonExists('Add to cart');
  $this
    ->submitForm($edit, 'Add to cart');
}