public function CheckoutOrderTest::testCheckoutRedirect in Commerce Core 8.2
Tests the checkout redirect route.
File
- modules/
checkout/ tests/ src/ Functional/ CheckoutOrderTest.php, line 839
Class
- CheckoutOrderTest
- Tests the checkout of an order.
Namespace
Drupal\Tests\commerce_checkout\FunctionalCode
public function testCheckoutRedirect() {
// Create a product that belongs to a different store to test the redirect
// to the cart page.
$another_store = $this
->createStore();
$variation = $this
->createEntity('commerce_product_variation', [
'type' => 'default',
'sku' => strtolower($this
->randomMachineName()),
'price' => [
'number' => 9.99,
'currency_code' => 'USD',
],
]);
/** @var \Drupal\commerce_product\Entity\ProductInterface $product */
$product2 = $this
->createEntity('commerce_product', [
'type' => 'default',
'title' => 'My product',
'variations' => [
$variation,
],
'stores' => [
$another_store,
],
]);
$this
->drupalGet('checkout');
$this
->assertSession()
->pageTextContains('Add some items to your cart and then try checking out.');
$this
->assertSession()
->pageTextContains('Shopping cart');
$this
->drupalGet($this->product
->toUrl());
$this
->submitForm([], 'Add to cart');
$this
->drupalGet('checkout');
$this
->assertSession()
->elementContains('css', 'h1.page-title', 'Order information');
$this
->drupalGet($product2
->toUrl());
$this
->submitForm([], 'Add to cart');
$this
->drupalGet('checkout');
$this
->assertSession()
->pageTextContains('Shopping cart');
}