Patcing tests relevant to new payment gateway API

This commit is contained in:
Joel Thiessen 2021-07-21 12:06:41 -07:00
parent c5cf917850
commit 9801cd80c6
3 changed files with 61 additions and 36 deletions

View File

@ -49,21 +49,27 @@ class Payment_Gateways_V2 extends WC_REST_Unit_Test_Case {
$this->assertEquals( 200, $response->get_status() ); $this->assertEquals( 200, $response->get_status() );
$this->assertContains( $this->assertContains(
array( array(
'id' => 'cheque', 'id' => 'cheque',
'title' => 'Check payments', 'title' => 'Check payments',
'description' => 'Please send a check to Store Name, Store Street, Store Town, Store State / County, Store Postcode.', 'description' => 'Please send a check to Store Name, Store Street, Store Town, Store State / County, Store Postcode.',
'order' => '', 'order' => '',
'enabled' => false, 'enabled' => false,
'method_title' => 'Check payments', 'method_title' => 'Check payments',
'method_description' => 'Take payments in person via checks. This offline gateway can also be useful to test purchases.', 'method_description' => 'Take payments in person via checks. This offline gateway can also be useful to test purchases.',
'settings' => array_diff_key( 'settings' => array_diff_key(
$this->get_settings( 'WC_Gateway_Cheque' ), $this->get_settings( 'WC_Gateway_Cheque' ),
array( array(
'enabled' => false, 'enabled' => false,
'description' => false, 'description' => false,
) )
), ),
'_links' => array( 'needs_setup' => false,
'post_install_scripts' => array(),
'settings_url' => 'http://example.org/wp-admin/admin.php?page=wc-settings&tab=checkout&section=cheque',
'connection_url' => '',
'setup_help_text' => '',
'required_settings_keys' => array(),
'_links' => array(
'self' => array( 'self' => array(
array( array(
'href' => rest_url( '/wc/v2/payment_gateways/cheque' ), 'href' => rest_url( '/wc/v2/payment_gateways/cheque' ),
@ -105,20 +111,26 @@ class Payment_Gateways_V2 extends WC_REST_Unit_Test_Case {
$this->assertEquals( 200, $response->get_status() ); $this->assertEquals( 200, $response->get_status() );
$this->assertEquals( $this->assertEquals(
array( array(
'id' => 'paypal', 'id' => 'paypal',
'title' => 'PayPal', 'title' => 'PayPal',
'description' => "Pay via PayPal; you can pay with your credit card if you don't have a PayPal account.", 'description' => "Pay via PayPal; you can pay with your credit card if you don't have a PayPal account.",
'order' => '', 'order' => '',
'enabled' => false, 'enabled' => false,
'method_title' => 'PayPal Standard', 'method_title' => 'PayPal Standard',
'method_description' => 'PayPal Standard redirects customers to PayPal to enter their payment information.', 'method_description' => 'PayPal Standard redirects customers to PayPal to enter their payment information.',
'settings' => array_diff_key( 'settings' => array_diff_key(
$this->get_settings( 'WC_Gateway_Paypal' ), $this->get_settings( 'WC_Gateway_Paypal' ),
array( array(
'enabled' => false, 'enabled' => false,
'description' => false, 'description' => false,
) )
), ),
'needs_setup' => false,
'post_install_scripts' => array(),
'settings_url' => 'http://example.org/wp-admin/admin.php?page=wc-settings&tab=checkout&section=paypal',
'connection_url' => null,
'setup_help_text' => null,
'required_settings_keys' => array(),
), ),
$paypal $paypal
); );

View File

@ -49,24 +49,30 @@ class Payment_Gateways extends WC_REST_Unit_Test_Case {
$this->assertEquals( 200, $response->get_status() ); $this->assertEquals( 200, $response->get_status() );
$this->assertContains( $this->assertContains(
array( array(
'id' => 'cheque', 'id' => 'cheque',
'title' => 'Check payments', 'title' => 'Check payments',
'description' => 'Please send a check to Store Name, Store Street, Store Town, Store State / County, Store Postcode.', 'description' => 'Please send a check to Store Name, Store Street, Store Town, Store State / County, Store Postcode.',
'order' => '', 'order' => '',
'enabled' => false, 'enabled' => false,
'method_title' => 'Check payments', 'method_title' => 'Check payments',
'method_description' => 'Take payments in person via checks. This offline gateway can also be useful to test purchases.', 'method_description' => 'Take payments in person via checks. This offline gateway can also be useful to test purchases.',
'method_supports' => array( 'method_supports' => array(
'products', 'products',
), ),
'settings' => array_diff_key( 'settings' => array_diff_key(
$this->get_settings( 'WC_Gateway_Cheque' ), $this->get_settings( 'WC_Gateway_Cheque' ),
array( array(
'enabled' => false, 'enabled' => false,
'description' => false, 'description' => false,
) )
), ),
'_links' => array( 'needs_setup' => false,
'post_install_scripts' => array(),
'settings_url' => 'http://example.org/wp-admin/admin.php?page=wc-settings&tab=checkout&section=cheque',
'connection_url' => '',
'setup_help_text' => '',
'required_settings_keys' => array(),
'_links' => array(
'self' => array( 'self' => array(
array( array(
'href' => rest_url( '/wc/v3/payment_gateways/cheque' ), 'href' => rest_url( '/wc/v3/payment_gateways/cheque' ),
@ -108,24 +114,30 @@ class Payment_Gateways extends WC_REST_Unit_Test_Case {
$this->assertEquals( 200, $response->get_status() ); $this->assertEquals( 200, $response->get_status() );
$this->assertEquals( $this->assertEquals(
array( array(
'id' => 'paypal', 'id' => 'paypal',
'title' => 'PayPal', 'title' => 'PayPal',
'description' => "Pay via PayPal; you can pay with your credit card if you don't have a PayPal account.", 'description' => "Pay via PayPal; you can pay with your credit card if you don't have a PayPal account.",
'order' => '', 'order' => '',
'enabled' => false, 'enabled' => false,
'method_title' => 'PayPal Standard', 'method_title' => 'PayPal Standard',
'method_description' => 'PayPal Standard redirects customers to PayPal to enter their payment information.', 'method_description' => 'PayPal Standard redirects customers to PayPal to enter their payment information.',
'method_supports' => array( 'method_supports' => array(
'products', 'products',
'refunds', 'refunds',
), ),
'settings' => array_diff_key( 'settings' => array_diff_key(
$this->get_settings( 'WC_Gateway_Paypal' ), $this->get_settings( 'WC_Gateway_Paypal' ),
array( array(
'enabled' => false, 'enabled' => false,
'description' => false, 'description' => false,
) )
), ),
'needs_setup' => false,
'post_install_scripts' => array(),
'settings_url' => 'http://example.org/wp-admin/admin.php?page=wc-settings&tab=checkout&section=paypal',
'connection_url' => null,
'setup_help_text' => null,
'required_settings_keys' => array(),
), ),
$paypal $paypal
); );

View File

@ -29,6 +29,7 @@ class WC_Settings_Advanced_Test extends WC_Settings_Unit_Test_Case {
'webhooks', 'webhooks',
'legacy_api', 'legacy_api',
'woocommerce_com', 'woocommerce_com',
'features',
); );
$this->assertEquals( $expected, $section_names ); $this->assertEquals( $expected, $section_names );