public function CommercePaymentCreditCardTest::testsValidateSecurityCode in Commerce Core 7
@covers ::validateSecurityCode
File
- modules/
payment/ tests/ commerce_payment_credit_card.test, line 104 - Unit tests for credit card detection.
Class
- CommercePaymentCreditCardTest
- Tests credit card detection.
Code
public function testsValidateSecurityCode() {
$data = array(
// Invalid lengths.
array(
1,
'visa',
FALSE,
),
array(
1111,
'visa',
FALSE,
),
// Non-numeric inputs.
array(
'llama',
'visa',
FALSE,
),
array(
'12.4',
'visa',
FALSE,
),
// Valid number.
array(
111,
'visa',
TRUE,
),
);
$types = CommercePaymentCreditCard::getTypes();
foreach ($data as $datum) {
$result = CommercePaymentCreditCard::validateSecurityCode($datum[0], $types[$datum[1]]);
$this
->assertEqual($datum[2], $result);
}
}