validate() public method

These fields are required by all credit card payment tokens: expiry_month - string Expiration date (MM) for the card expiry_year - string Expiration date (YYYY) for the card last4 - string Last 4 digits of the card card_type - string Card type (visa, mastercard, etc)
Since: 2.6.0
public validate ( ) : boolean
return boolean True if the passed data is valid
コード例 #1
0
ファイル: cc.php プロジェクト: tlovett1/woocommerce
 /**
  * Test validation for expiry length.
  * @since 2.6.0
  */
 function test_wc_payment_token_cc_validate_expiry_length()
 {
     $token = new WC_Payment_Token_CC();
     $token->set_token(time() . ' ' . __FUNCTION__);
     $this->assertFalse($token->validate());
     $token->set_last4('1111');
     $token->set_expiry_year('16');
     $token->set_expiry_month('08');
     $token->set_card_type('visa');
     $this->assertFalse($token->validate());
     $token->set_expiry_year('2016');
     $this->assertTrue($token->validate());
     $token->set_expiry_month('888');
     $this->assertFalse($token->validate());
 }