mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Fix the tests
This commit is contained in:
parent
88c0ce6ee3
commit
cf30631c19
1 changed files with 9 additions and 4 deletions
|
@ -257,19 +257,24 @@ class StylingSettingsMapHelper {
|
|||
/**
|
||||
* Retrieves the mapped enabled or disabled button value from the new settings.
|
||||
*
|
||||
* @param LocationStylingDTO[] $styling_models The list of location styling models.
|
||||
* @param string $button_name The button name (see {@link self::BUTTON_NAMES}).
|
||||
* @param PaymentSettings $payment_settings The payment settings model.
|
||||
* @param LocationStylingDTO[] $styling_models The list of location styling models.
|
||||
* @param string $button_name The button name (see {@link self::BUTTON_NAMES}).
|
||||
* @param AbstractDataModel|null $payment_settings The payment settings model.
|
||||
* @return int The enabled (1) or disabled (0) state.
|
||||
* @throws RuntimeException If an invalid button name is provided.
|
||||
*/
|
||||
protected function mapped_button_enabled_value( array $styling_models, string $button_name, PaymentSettings $payment_settings ): ?int {
|
||||
protected function mapped_button_enabled_value( array $styling_models, string $button_name, ?AbstractDataModel $payment_settings ): ?int {
|
||||
if ( is_null( $payment_settings ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( ! in_array( $button_name, self::BUTTON_NAMES, true ) ) {
|
||||
throw new RuntimeException( 'Wrong button name is provided.' );
|
||||
}
|
||||
|
||||
$locations_to_context_map = $this->current_context_to_new_button_location_map();
|
||||
$current_context = $locations_to_context_map[ $this->context() ] ?? '';
|
||||
assert( $payment_settings instanceof PaymentSettings );
|
||||
|
||||
foreach ( $styling_models as $model ) {
|
||||
if ( $model->enabled && $model->location === $current_context ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue