2016-02-08 19:57:48 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class Payment_Token_eCheck.
|
|
|
|
* @package WooCommerce\Tests\Payment_Tokens
|
|
|
|
*/
|
2016-03-23 12:14:13 +00:00
|
|
|
class WC_Tests_Payment_Token_eCheck extends WC_Unit_Test_Case {
|
2016-02-08 19:57:48 +00:00
|
|
|
|
|
|
|
/**
|
2016-03-01 17:09:29 +00:00
|
|
|
* Test validation for empty/unset values.
|
|
|
|
* @since 2.6.0
|
2016-02-08 19:57:48 +00:00
|
|
|
*/
|
|
|
|
function test_wc_payment_token_echeck_validate_empty() {
|
2018-03-07 17:50:21 +00:00
|
|
|
$token = new WC_Payment_Token_ECheck();
|
2016-02-08 19:57:48 +00:00
|
|
|
$token->set_token( time() . ' ' . __FUNCTION__ );
|
|
|
|
$this->assertFalse( $token->validate() );
|
|
|
|
$token->set_last4( '1111' );
|
|
|
|
$this->assertTrue( $token->validate() );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-18 18:24:06 +00:00
|
|
|
* Test get/set last4.
|
2016-03-01 17:09:29 +00:00
|
|
|
* @since 2.6.0
|
2016-02-08 19:57:48 +00:00
|
|
|
*/
|
2016-03-18 18:24:06 +00:00
|
|
|
public function test_wc_payment_token_echeck_last4() {
|
2018-03-07 17:50:21 +00:00
|
|
|
$token = new WC_Payment_Token_ECheck();
|
2016-03-18 18:24:06 +00:00
|
|
|
$token->set_last4( '1111' );
|
2016-02-08 19:57:48 +00:00
|
|
|
$this->assertEquals( '1111', $token->get_last4() );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-01 17:09:29 +00:00
|
|
|
* Test reading/getting a token from DB correctly sets meta.
|
|
|
|
* @since 2.6.0
|
2016-02-08 19:57:48 +00:00
|
|
|
*/
|
|
|
|
public function test_wc_payment_token_echeck_read_pulls_meta() {
|
2016-03-23 12:14:13 +00:00
|
|
|
$token = WC_Helper_Payment_Token::create_eCheck_token();
|
2016-02-08 19:57:48 +00:00
|
|
|
$token_id = $token->get_id();
|
|
|
|
|
2018-03-07 17:50:21 +00:00
|
|
|
$token_read = new WC_Payment_Token_ECheck( $token_id );
|
2016-02-08 19:57:48 +00:00
|
|
|
$this->assertEquals( '1234', $token_read->get_last4() );
|
|
|
|
}
|
|
|
|
}
|