CashOnDeliveryTest.php in Ubercart 8.4
File
payment/uc_payment_pack/tests/src/Functional/CashOnDeliveryTest.php
View source
<?php
namespace Drupal\Tests\uc_payment_pack\Functional;
use Drupal\uc_order\Entity\Order;
class CashOnDeliveryTest extends PaymentPackTestBase {
public function testCashOnDelivery() {
$assert = $this
->assertSession();
$this
->drupalGet('admin/store/config/payment/add/cod');
$assert
->fieldValueEquals('settings[policy]', 'Full payment is expected upon delivery or prior to pick-up.');
$cod = $this
->createPaymentMethod('cod', [
'settings[policy]' => $this
->randomString(),
]);
$this
->drupalGet('cart/checkout');
$assert
->fieldValueEquals('panes[payment][payment_method]', $cod['id']);
$assert
->assertEscaped($cod['settings[policy]'], 'COD policy found at checkout.');
$this
->submitForm([], 'Review order');
$assert
->pageTextContains('Cash on delivery');
$this
->submitForm([], 'Submit order');
$order = Order::load(1);
$this
->assertEquals($cod['id'], $order
->getPaymentMethodId(), 'Order has COD payment method.');
$this
->drupalGet('user/' . $order
->getOwnerId() . '/orders/' . $order
->id());
$assert
->pageTextContains('Method: Cash on delivery');
$this
->drupalGet('admin/store/orders/' . $order
->id());
$assert
->pageTextContains('Method: Cash on delivery');
}
}