You are here

public function CommercePaymentCreditCardTest::testValidateExpirationDate in Commerce Core 7

Tests expiration date validation.

File

modules/payment/tests/commerce_payment_credit_card.test, line 74
Unit tests for credit card detection.

Class

CommercePaymentCreditCardTest
Tests credit card detection.

Code

public function testValidateExpirationDate() {
  $data = array(
    // Invalid month.
    array(
      0,
      2020,
      FALSE,
    ),
    array(
      13,
      2020,
      FALSE,
    ),
    // Invalid year.
    array(
      10,
      2012,
      FALSE,
    ),
    // Valid month and year.
    array(
      date('n'),
      date('Y'),
      TRUE,
    ),
  );
  foreach ($data as $datum) {
    $result = CommercePaymentCreditCard::validateExpirationDate($datum[0], $datum[1]);
    $this
      ->assertEqual($datum[2], $result);
  }
}