PaymentPaneTest.php in Ubercart 8.4
File
payment/uc_payment/tests/src/Functional/PaymentPaneTest.php
View source
<?php
namespace Drupal\Tests\uc_payment\Functional;
use Drupal\Tests\uc_store\Functional\UbercartBrowserTestBase;
class PaymentPaneTest extends UbercartBrowserTestBase {
protected static $modules = [
'uc_payment',
'uc_payment_pack',
];
protected function setUp() {
parent::setUp();
$this
->drupalLogin($this->adminUser);
$this
->addToCart($this->product);
}
public function testPaymentMethodOptions() {
$assert = $this
->assertSession();
$this
->drupalGet('cart/checkout');
$assert
->pageTextContains('Checkout cannot be completed without any payment methods enabled. Please contact an administrator to resolve the issue.');
$check = $this
->createPaymentMethod('check');
$this
->drupalGet('cart/checkout');
$assert
->pageTextNotContains('Select a payment method from the following options.');
$assert
->assertEscaped($check['label']);
$this
->assertFieldByXPath("//input[@name='panes[payment][payment_method]' and @disabled='disabled']");
$other = $this
->createPaymentMethod('other');
$this
->drupalGet('cart/checkout');
$assert
->pageTextContains('Select a payment method from the following options.');
$assert
->assertEscaped($check['label']);
$assert
->assertEscaped($other['label']);
$this
->assertNoFieldByXPath("//input[@name='panes[payment][payment_method]' and @disabled='disabled']");
}
public function testOrderTotalPreview() {
$assert = $this
->assertSession();
$edit = [
'panes[payment][settings][show_preview]' => TRUE,
];
$this
->drupalGet('admin/store/config/checkout');
$this
->submitForm($edit, 'Save configuration');
$this
->drupalGet('cart/checkout');
$assert
->pageTextContains('Order total:');
$edit = [
'panes[payment][settings][show_preview]' => FALSE,
];
$this
->drupalGet('admin/store/config/checkout');
$this
->submitForm($edit, 'Save configuration');
$this
->drupalGet('cart/checkout');
$assert
->pageTextNotContains('Order total:');
}
public function testFreeOrders() {
$assert = $this
->assertSession();
$free_product = $this
->createProduct([
'price' => 0,
]);
$check = $this
->createPaymentMethod('check');
$this
->drupalGet('cart/checkout');
$assert
->assertEscaped($check['label']);
$assert
->pageTextNotContains('No payment required');
$assert
->pageTextNotContains("Subtotal:\n \$0.00");
$this
->addToCart($free_product);
$this
->drupalGet('cart/checkout');
$assert
->assertEscaped($check['label']);
$assert
->pageTextNotContains('No payment required');
$assert
->pageTextNotContains("Subtotal:\n \$0.00");
$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');
$assert
->pageTextNotContains('Select a payment method from the following options.');
$this
->assertFieldByXPath("//input[@name='panes[payment][payment_method]' and @disabled='disabled']");
}
}