public function PaymentPaneTest::testFreeOrders in Ubercart 8.4
Tests free orders.
File
- payment/
uc_payment/ tests/ src/ Functional/ PaymentPaneTest.php, line 82
Class
- PaymentPaneTest
- Tests the checkout payment pane.
Namespace
Drupal\Tests\uc_payment\FunctionalCode
public function testFreeOrders() {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
$free_product = $this
->createProduct([
'price' => 0,
]);
$check = $this
->createPaymentMethod('check');
// Check that paid products cannot be purchased for free.
$this
->drupalGet('cart/checkout');
$assert
->assertEscaped($check['label']);
$assert
->pageTextNotContains('No payment required');
$assert
->pageTextNotContains("Subtotal:\n \$0.00");
// Check that a mixture of free and paid products
// cannot be purchased for free.
$this
->addToCart($free_product);
$this
->drupalGet('cart/checkout');
$assert
->assertEscaped($check['label']);
$assert
->pageTextNotContains('No payment required');
$assert
->pageTextNotContains("Subtotal:\n \$0.00");
// Check that free products can be purchased successfully with no payment.
$this
->drupalGet('cart');
$this
->submitForm([], 'Remove');
$this
->drupalGet('cart');
$this
->submitForm([], 'Remove');
$this
->addToCart($free_product);
$this
->drupalGet('cart/checkout');
$assert
->assertNoEscaped($check['label']);
$assert
->pageTextContains('No payment required');
$assert
->pageTextContains('Continue with checkout to complete your order.');
$assert
->pageTextMatches('/Subtotal:\\s*\\$0.00/', '"Subtotal: $0.00" found');
// Check that this is the only available payment method.
$assert
->pageTextNotContains('Select a payment method from the following options.');
$this
->assertFieldByXPath("//input[@name='panes[payment][payment_method]' and @disabled='disabled']");
}