-
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
Fix fatal error if store currency is changed after enabled currencies are set #2078
Fix fatal error if store currency is changed after enabled currencies are set #2078
Conversation
… set, update tests.
… set, update tests.
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.
Looks great! I've added a couple of comments regarding some tests, but I'm pre-approving this. Feel free to once they're addressed 🚀
if ( ! isset( $available_currencies[ $code ] ) ) { | ||
continue; | ||
} |
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.
Would you mind adding a test for this change? Something like this would be enough:
public function test_enabled_but_unavailable_currencies_are_skipped() {
update_option( 'wcpay_multi_currency_enabled_currencies', [ 'RANDOM_CURRENCY', 'USD' ] );
// Recreate Multi_Currency instance to use the recently set currencies.
$this->reset_multi_currency_instance();
$this->multi_currency = WCPay\Multi_Currency\Multi_Currency::instance();
$this->assertSame( [ 'USD' ], array_keys( $this->multi_currency->get_enabled_currencies() ) );
}
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.
Done in b9a7c71 , thanks for the example, I applied it directly 😁
@@ -87,8 +92,6 @@ function () { | |||
} | |||
|
|||
public function test_get_enabled_currencies_returns_correctly() { | |||
update_option( 'wcpay_multi_currency_enabled_currencies', $this->mock_enabled_currencies ); |
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.
Now that the options are defined during the test's setUp, could we remove the Multi_Currency instance reset from this test?
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.
Good catch, I missed that. Updated in b9a7c71
* Added phpunit tests for Customer Multi-Currency. * Fix fatal error if store currency is changed after enabled currencies are set (#2078) * Fix fatal error if store currency is changed after enabled currencies set, update tests. * Fix fatal error if store currency is changed after enabled currencies set, update tests. * Additional test for multi-currency, clean up of other tests.
* Added phpunit tests for Customer Multi-Currency. * Fix fatal error if store currency is changed after enabled currencies are set (#2078) * Fix fatal error if store currency is changed after enabled currencies set, update tests. * Fix fatal error if store currency is changed after enabled currencies set, update tests. * Additional test for multi-currency, clean up of other tests.
Fixes #2068 #2004
Changes proposed in this Pull Request
Testing instructions