public function CreditCardTest::testExpiryDate in Ubercart 8.4
Tests that expiry date validation functions correctly.
File
- payment/
uc_credit/ tests/ src/ Functional/ CreditCardTest.php, line 252
Class
- CreditCardTest
- Tests credit card payments with the test gateway.
Namespace
Drupal\Tests\uc_credit\FunctionalCode
public function testExpiryDate() {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
$order = $this
->createOrder([
'payment_method' => $this->paymentMethod['id'],
]);
$year = date('Y');
$month = date('n');
for ($y = $year; $y <= $year + 2; $y++) {
for ($m = 1; $m <= 12; $m++) {
$edit = [
'amount' => 1,
'cc_data[cc_number]' => '4111111111111111',
'cc_data[cc_cvv]' => '123',
'cc_data[cc_exp_month]' => $m,
'cc_data[cc_exp_year]' => $y,
];
$this
->drupalGet('admin/store/orders/' . $order
->id() . '/credit/' . $this->paymentMethod['id']);
$this
->submitForm($edit, 'Charge amount');
if ($y > $year || $m >= $month) {
// Check that expiry date in the future passed validation.
$assert
->pageTextContains('The credit card was processed successfully.');
}
else {
// Check that expiry date in the past failed validation.
$assert
->pageTextNotContains('The credit card was processed successfully.');
}
}
}
}