-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable deferred intent creation when initialization process encounters cache unavailability #7686
Changes from all commits
e2a6285
4ed46d9
b623c8f
7869532
5def517
9d8d698
f1d2c51
5306cd8
82fd490
98d6852
e0e85b2
e95b783
73fb1e2
52496de
abc7347
a540e9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: fix | ||
|
||
Enable deferred intent creation when initialization process encounters cache unavailability |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,9 @@ function() { | |
require_once $_plugin_dir . 'includes/admin/class-wc-rest-payments-payment-intents-controller.php'; | ||
require_once $_plugin_dir . 'includes/class-woopay-tracker.php'; | ||
require_once $_plugin_dir . 'includes/admin/class-wc-rest-payments-customer-controller.php'; | ||
|
||
// Load currency helper class early to ensure its implementation is used over the one resolved during further test initialization. | ||
require_once __DIR__ . '/helpers/class-wc-helper-site-currency.php'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More context on this change in p1700139623363929-slack-CU6SYV31A |
||
} | ||
|
||
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,21 +59,6 @@ public function test_track_enabled_on_upgrade() { | |
$this->assertSame( '1', get_option( Track_Upe_Status::IS_TRACKED_OPTION ) ); | ||
} | ||
|
||
public function test_track_disabled_on_upgrade() { | ||
update_option( WC_Payments_Features::UPE_FLAG_NAME, 'disabled' ); | ||
|
||
Track_Upe_Status::maybe_track(); | ||
|
||
$this->assertEquals( | ||
[ | ||
'wcpay_upe_disabled' => [], | ||
], | ||
Tracker::get_admin_events() | ||
); | ||
|
||
$this->assertSame( '1', get_option( Track_Upe_Status::IS_TRACKED_OPTION ) ); | ||
} | ||
|
||
Comment on lines
-62
to
-76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to check for |
||
public function test_do_nothing_default_on_upgrade() { | ||
Track_Upe_Status::maybe_track(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,78 +24,6 @@ public function tear_down() { | |
delete_option( '_wcpay_feature_upe' ); | ||
} | ||
|
||
public function test_get_note() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the non-UPE related tests have been removed from this class, since the plugin now executes UPE by default |
||
$note = WC_Payments_Notes_Additional_Payment_Methods::get_note(); | ||
|
||
$this->assertSame( 'Boost your sales by accepting new payment methods', $note->get_title() ); | ||
$this->assertSame( 'Get early access to additional payment methods and an improved checkout experience, coming soon to WooPayments. <a href="https://woo.com/document/woopayments/payment-methods/additional-payment-methods/" target="wcpay_upe_learn_more">Learn more</a>', $note->get_content() ); | ||
$this->assertSame( 'info', $note->get_type() ); | ||
$this->assertSame( 'wc-payments-notes-additional-payment-methods', $note->get_name() ); | ||
$this->assertSame( 'woocommerce-payments', $note->get_source() ); | ||
|
||
list( $enable_upe_action ) = $note->get_actions(); | ||
$this->assertSame( 'wc-payments-notes-additional-payment-methods', $enable_upe_action->name ); | ||
$this->assertSame( 'Enable on your store', $enable_upe_action->label ); | ||
$this->assertStringStartsWith( 'http://example.org/wp-admin/admin.php?page=wc-settings&tab=checkout§ion=woocommerce_payments&action=enable-upe', $enable_upe_action->query ); | ||
|
||
/** | ||
* The $primary property was deprecated from WooCommerce core. Keeping this to maintain the compatibility with old WooCommerce versions. | ||
* @see https://github.com/woocommerce/woocommerce/blob/ff2d7d704a8f72aeb4990811b6972097aa167bea/plugins/woocommerce/src/Admin/Notes/Note.php#L623-L623. | ||
* @see https://github.com/woocommerce/woocommerce-admin/pull/8474 | ||
*/ | ||
if ( isset( $enable_upe_action->primary ) ) { | ||
$this->assertSame( true, $enable_upe_action->primary ); | ||
} | ||
} | ||
|
||
public function test_get_note_does_not_return_note_when_account_is_not_connected() { | ||
$account_mock = $this->getMockBuilder( \WC_Payments_Account::class )->disableOriginalConstructor()->setMethods( [ 'is_stripe_connected' ] )->getMock(); | ||
$account_mock->expects( $this->atLeastOnce() )->method( 'is_stripe_connected' )->will( $this->returnValue( false ) ); | ||
WC_Payments_Notes_Additional_Payment_Methods::set_account( $account_mock ); | ||
|
||
$note = WC_Payments_Notes_Additional_Payment_Methods::get_note(); | ||
|
||
$this->assertNull( $note ); | ||
} | ||
|
||
public function test_get_note_returns_note_when_account_is_connected() { | ||
$account_mock = $this->getMockBuilder( \WC_Payments_Account::class )->disableOriginalConstructor()->setMethods( [ 'is_stripe_connected', 'is_account_partially_onboarded', 'is_progressive_onboarding_in_progress' ] )->getMock(); | ||
$account_mock->expects( $this->once() )->method( 'is_stripe_connected' )->willReturn( true ); | ||
$account_mock->expects( $this->once() )->method( 'is_account_partially_onboarded' )->willReturn( false ); | ||
$account_mock->expects( $this->once() )->method( 'is_progressive_onboarding_in_progress' )->willReturn( false ); | ||
|
||
WC_Payments_Notes_Additional_Payment_Methods::set_account( $account_mock ); | ||
|
||
$note = WC_Payments_Notes_Additional_Payment_Methods::get_note(); | ||
|
||
$this->assertSame( 'Boost your sales by accepting new payment methods', $note->get_title() ); | ||
} | ||
|
||
public function test_get_note_returns_note_when_account_is_partially_onboarded() { | ||
$account_mock = $this->getMockBuilder( \WC_Payments_Account::class )->disableOriginalConstructor()->setMethods( [ 'is_stripe_connected', 'is_account_partially_onboarded', 'is_progressive_onboarding_in_progress' ] )->getMock(); | ||
$account_mock->expects( $this->once() )->method( 'is_stripe_connected' )->willReturn( true ); | ||
$account_mock->expects( $this->once() )->method( 'is_account_partially_onboarded' )->willReturn( true ); | ||
|
||
WC_Payments_Notes_Additional_Payment_Methods::set_account( $account_mock ); | ||
|
||
$note = WC_Payments_Notes_Additional_Payment_Methods::get_note(); | ||
|
||
$this->assertNull( $note ); | ||
} | ||
|
||
public function test_get_note_returns_note_when_account_is_progressive_in_progress() { | ||
$account_mock = $this->getMockBuilder( \WC_Payments_Account::class )->disableOriginalConstructor()->setMethods( [ 'is_stripe_connected', 'is_account_partially_onboarded', 'is_progressive_onboarding_in_progress' ] )->getMock(); | ||
$account_mock->expects( $this->once() )->method( 'is_stripe_connected' )->willReturn( true ); | ||
$account_mock->expects( $this->once() )->method( 'is_account_partially_onboarded' )->willReturn( false ); | ||
$account_mock->expects( $this->once() )->method( 'is_progressive_onboarding_in_progress' )->willReturn( true ); | ||
|
||
WC_Payments_Notes_Additional_Payment_Methods::set_account( $account_mock ); | ||
|
||
$note = WC_Payments_Notes_Additional_Payment_Methods::get_note(); | ||
|
||
$this->assertNull( $note ); | ||
} | ||
|
||
public function test_maybe_enable_feature_flag_redirects_to_onboarding_when_account_not_connected() { | ||
$account_mock = $this->getMockBuilder( \WC_Payments_Account::class )->disableOriginalConstructor()->setMethods( [ 'is_stripe_connected', 'redirect_to_onboarding_welcome_page' ] )->getMock(); | ||
$account_mock->expects( $this->atLeastOnce() )->method( 'is_stripe_connected' )->will( $this->returnValue( false ) ); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,14 +55,6 @@ public function test_stripelink_setup_get_note() { | |
$this->assertStringStartsWith( 'https://woo.com/document/woopayments/payment-methods/link-by-stripe/', $set_up_action->query ); | ||
} | ||
|
||
public function test_stripelink_setup_note_null_when_upe_disabled() { | ||
$this->mock_gateway_data( '0', [ 'card', 'link' ], [ 'card' ] ); | ||
|
||
$note = \WC_Payments_Notes_Set_Up_StripeLink::get_note(); | ||
|
||
$this->assertNull( $note ); | ||
} | ||
|
||
Comment on lines
-58
to
-65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is irrelevant going forward due to UPE being always enabled |
||
public function test_stripelink_setup_note_null_when_link_not_available() { | ||
$this->mock_gateway_data( '1', [ 'card' ], [ 'card' ] ); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was removed because it's an integration test that works only with the legacy gateway. It's not easy nor elegant to mock gateway in
WC_Payments
because methods/objects are static.Since the tested method relies solely on
get_upe_available_payment_methods
,get_upe_available_payment_methods
is now fully tested bytest-class-upe-payment-gateway.php::test_get_upe_available_payment_methods()