diff --git a/tests/phpunit/test-class-wc-stripe-payment-tokens.php b/tests/phpunit/payment-tokens/test-class-wc-stripe-payment-tokens.php similarity index 100% rename from tests/phpunit/test-class-wc-stripe-payment-tokens.php rename to tests/phpunit/payment-tokens/test-class-wc-stripe-payment-tokens.php diff --git a/tests/phpunit/payment-tokens/test-trait-wc-stripe-fingerprint.php b/tests/phpunit/payment-tokens/test-trait-wc-stripe-fingerprint.php new file mode 100644 index 000000000..fbf1b2901 --- /dev/null +++ b/tests/phpunit/payment-tokens/test-trait-wc-stripe-fingerprint.php @@ -0,0 +1,16 @@ +set_fingerprint( '123abc' ); + $this->assertEquals( '123abc', $token->get_fingerprint() ); + } +} diff --git a/tests/phpunit/payment-tokens/test-trait-wc-stripe-token-comparison.php b/tests/phpunit/payment-tokens/test-trait-wc-stripe-token-comparison.php new file mode 100644 index 000000000..2ca136587 --- /dev/null +++ b/tests/phpunit/payment-tokens/test-trait-wc-stripe-token-comparison.php @@ -0,0 +1,97 @@ +set_fingerprint( '123abc' ); + break; + case 'link': + $token = new WC_Payment_Token_Link(); + $token->set_email( 'john.doe@example.com' ); + break; + case 'cashapp': + $token = new WC_Payment_Token_CashApp(); + $token->set_cashtag( '$test_cashtag' ); + break; + case 'CC': + default: + $token = new WC_Stripe_Payment_Token_CC(); + $token->set_fingerprint( '123abc' ); + } + + $this->assertEquals( $expected, $token->is_equal( $payment_method ) ); + } + + /** + * Data provider for `test_is_equal`. + * + * @return array + */ + public function provide_test_is_equal() { + return [ + 'Unknown method' => [ + 'token type' => 'unknown', + 'payment method' => (object) [], + 'expected' => false, + ], + 'CC, not equal' => [ + 'token type' => 'CC', + 'payment_method' => (object) [ + 'card' => (object) [ + 'fingerprint' => '456def', + ], + ], + 'expected' => false, + ], + 'CC, equal' => [ + 'token type' => 'CC', + 'payment method' => (object) [ + 'card' => (object) [ + 'fingerprint' => '123abc', + ], + ], + 'expected' => true, + ], + 'SEPA, equal' => [ + 'token type' => 'sepa', + 'payment method' => (object) [ + 'sepa_debit' => (object) [ + 'fingerprint' => '123abc', + ], + ], + 'expected' => true, + ], + 'Link, equal' => [ + 'token type' => 'link', + 'payment method' => (object) [ + 'link' => (object) [ + 'email' => 'john.doe@example.com', + ], + ], + 'expected' => true, + ], + 'CashApp, equal' => [ + 'token type' => 'cashapp', + 'payment method' => (object) [ + 'cashapp' => (object) [ + 'cashtag' => '$test_cashtag', + ], + ], + 'expected' => true, + ], + ]; + } +}