From 240aaedf23c0f359a2e45ab6c67220772cb434f6 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 22 Aug 2024 11:23:59 +0200 Subject: [PATCH] Fix cs and tests --- inc/settings/mollie_advanced_settings.php | 12 ++++----- inc/settings/mollie_applepay_settings.php | 10 +++---- src/Activation/ActivationModule.php | 2 +- src/Activation/ConstraintsChecker.php | 10 +++++-- .../ApplePayButton/AppleAjaxRequests.php | 2 +- .../ApplePayButton/ApplePayDirectHandler.php | 4 +-- .../PayPalButton/PayPalAjaxRequests.php | 4 +-- src/Gateway/Surcharge.php | 2 +- .../Capture/Action/CapturePayment.php | 2 +- src/Payment/MollieOrder.php | 8 +++--- src/Payment/MollieOrderService.php | 4 +-- src/Payment/PaymentModule.php | 5 ++-- src/Payment/RefundLineItemsBuilder.php | 2 +- src/PaymentMethods/Giftcard.php | 4 +-- src/PaymentMethods/Giropay.php | 2 +- .../MybankInstructionStrategy.php | 2 +- .../General/MollieGeneralSettings.php | 26 +++++++++---------- src/Settings/Settings.php | 2 +- src/Shared/Data.php | 4 +-- .../Payment/OrderItemsRefunderTest.php | 5 ++-- .../Payment/RefundLineItemsBuilderTest.php | 3 ++- 21 files changed, 62 insertions(+), 53 deletions(-) diff --git a/inc/settings/mollie_advanced_settings.php b/inc/settings/mollie_advanced_settings.php index e2c67aa3..e108e62d 100644 --- a/inc/settings/mollie_advanced_settings.php +++ b/inc/settings/mollie_advanced_settings.php @@ -72,7 +72,7 @@ ], 'desc' => sprintf( /* translators: Placeholder 1: link tag Placeholder 2: closing tag */ - __('Sending a language (or locale) is required. The option \'Automatically send WordPress language\' will try to get the customer\'s language in WordPress (and respects multilanguage plugins) and convert it to a format Mollie understands. If this fails, or if the language is not supported, it will fall back to American English. You can also select one of the locales currently supported by Mollie, that will then be used for all customers.', 'mollie-payments-for-woocommerce'), + __('Sending a language (or locale) is required. The option \'Automatically send WordPress language\' will try to get the customer\'s language in WordPress (and respects multilanguage plugins) and convert it to a format Mollie understands. If this fails, or if the language is not supported, it will fall back to American English. You can also select one of the locales currently supported by Mollie, that will then be used for all customers.', 'mollie-payments-for-woocommerce'), '', '' ), @@ -113,7 +113,7 @@ 'default' => PaymentService::PAYMENT_METHOD_TYPE_ORDER, 'desc' => sprintf( /* translators: Placeholder 1: opening link tag, placeholder 2: closing link tag */ - __( + __( 'Click %1$shere%2$s to read more about the differences between the Payments and Orders API', 'mollie-payments-for-woocommerce' ), @@ -163,7 +163,7 @@ class="mollie-settings-advanced-payment-desc-label button button-secondary butto )), sprintf( /* translators: Placeholder 1: Opening paragraph tag, placeholder 2: Closing paragraph tag */ - __( + __( 'Select among the available variables the description to be used for this transaction.%1$s(Note: this only works when the method is set to Payments API)%2$s', 'mollie-payments-for-woocommerce' ), @@ -182,9 +182,9 @@ class="mollie-settings-advanced-payment-desc-label button button-secondary butto 'custom_attributes' => ['maxlength' => '30'], 'default' => __('Gateway Fee', 'mollie-payments-for-woocommerce'), 'desc' => __( - 'This is the label will appear in frontend when the surcharge applies', - 'mollie-payments-for-woocommerce' - ), + 'This is the label will appear in frontend when the surcharge applies', + 'mollie-payments-for-woocommerce' + ), ], [ 'id' => $pluginName . '_removeOptionsAndTransients', diff --git a/inc/settings/mollie_applepay_settings.php b/inc/settings/mollie_applepay_settings.php index eeb804f5..2ef1c3fa 100644 --- a/inc/settings/mollie_applepay_settings.php +++ b/inc/settings/mollie_applepay_settings.php @@ -45,9 +45,9 @@ 'id' => 'display_logo', 'title' => __('Display logo', 'mollie-payments-for-woocommerce'), 'desc' => __( - 'Display logo', - 'mollie-payments-for-woocommerce' - ), + 'Display logo', + 'mollie-payments-for-woocommerce' + ), 'desc_tip' => true, 'type' => 'checkbox', 'default' => 'yes', @@ -88,7 +88,7 @@ 'title' => __('Enable Apple Pay Button on Cart page', 'mollie-payments-for-woocommerce'), 'desc' => sprintf( /* translators: Placeholder 1: enabled or disabled */ - __( + __( 'Enable the Apple Pay direct buy button on the Cart page', 'mollie-payments-for-woocommerce' ), @@ -104,7 +104,7 @@ 'title' => __('Enable Apple Pay Button on Product page', 'mollie-payments-for-woocommerce'), 'desc' => sprintf( /* translators: Placeholder 1: enabled or disabled */ - __( + __( 'Enable the Apple Pay direct buy button on the Product page', 'mollie-payments-for-woocommerce' ), diff --git a/src/Activation/ActivationModule.php b/src/Activation/ActivationModule.php index 7fb243c9..ec70f8c7 100644 --- a/src/Activation/ActivationModule.php +++ b/src/Activation/ActivationModule.php @@ -119,7 +119,7 @@ public function mollieWcNoticeApiKeyMissing() $notice = new AdminNotice(); $message = sprintf( /* translators: Placeholder 1: Opening strong tag. Placeholder 2: Closing strong tag. Placeholder 3: Opening link tag to settings. Placeholder 4: Closing link tag.*/ - esc_html__( + esc_html__( '%1$sMollie Payments for WooCommerce: API keys missing%2$s Please%3$s set your API keys here%4$s.', 'mollie-payments-for-woocommerce' ), diff --git a/src/Activation/ConstraintsChecker.php b/src/Activation/ConstraintsChecker.php index 861233f8..27a662d0 100644 --- a/src/Activation/ConstraintsChecker.php +++ b/src/Activation/ConstraintsChecker.php @@ -105,13 +105,19 @@ protected function showNotice(array $errors) { $message = sprintf( /* translators: Placeholder 1: opening tags Placeholder 2: closing tags */ - __('%1$sMollie Payments for WooCommerce is inactive:%2$s', 'mollie-payments-for-woocommerce'), '

', '

'); + __('%1$sMollie Payments for WooCommerce is inactive:%2$s', 'mollie-payments-for-woocommerce'), + '

', + '

' + ); foreach ($errors as $error) { $message .= sprintf('

%s

', $error); } $message .= sprintf( /* translators: Placeholder 1: opening tags Placeholder 2: closing tags */ - __('%1$sCorrect the above errors to use Mollie Payments for Woocommerce%2$s', 'mollie-payments-for-woocommerce'), '

', '

'); + __('%1$sCorrect the above errors to use Mollie Payments for Woocommerce%2$s', 'mollie-payments-for-woocommerce'), + '

', + '

' + ); $errorLevel = 'notice-error'; $this->notice->addNotice($errorLevel, $message); } diff --git a/src/Buttons/ApplePayButton/AppleAjaxRequests.php b/src/Buttons/ApplePayButton/AppleAjaxRequests.php index 1c441b41..59a82fb9 100644 --- a/src/Buttons/ApplePayButton/AppleAjaxRequests.php +++ b/src/Buttons/ApplePayButton/AppleAjaxRequests.php @@ -697,7 +697,7 @@ function ($result, $order_id) { } else { $message = sprintf( /* translators: Placeholder 1: Payment method title */ - __( + __( 'Could not create %s payment.', 'mollie-payments-for-woocommerce' ), diff --git a/src/Buttons/ApplePayButton/ApplePayDirectHandler.php b/src/Buttons/ApplePayButton/ApplePayDirectHandler.php index d945f956..71a9e4af 100644 --- a/src/Buttons/ApplePayButton/ApplePayDirectHandler.php +++ b/src/Buttons/ApplePayButton/ApplePayDirectHandler.php @@ -39,7 +39,7 @@ public function bootstrap($buttonEnabledProduct, $buttonEnabledCart) if (!$this->isApplePayCompatible()) { $message = sprintf( /* translators: Placeholder 1: Opening strong tag. Placeholder 2: Closing strong tag. Placeholder 3: Opening link tag to documentation. Placeholder 4: Closing link tag.*/ - esc_html__( + esc_html__( '%1$sServer not compliant with Apple requirements%2$s Check %3$sApple Server requirements page%4$s to fix it in order to make the Apple Pay button work', 'mollie-payments-for-woocommerce' ), @@ -55,7 +55,7 @@ public function bootstrap($buttonEnabledProduct, $buttonEnabledCart) if (!$this->merchantValidated()) { $message = sprintf( /* translators: Placeholder 1: Opening link tag to documentation. Placeholder 2: Closing link tag.*/ - esc_html__( + esc_html__( 'Apple Pay Validation Error: Please review the %1$sApple Server requirements%2$s. If everything appears correct, click the Apple Pay button to retry validation.', 'mollie-payments-for-woocommerce' ), diff --git a/src/Buttons/PayPalButton/PayPalAjaxRequests.php b/src/Buttons/PayPalButton/PayPalAjaxRequests.php index d041780c..30e65bc3 100644 --- a/src/Buttons/PayPalButton/PayPalAjaxRequests.php +++ b/src/Buttons/PayPalButton/PayPalAjaxRequests.php @@ -110,7 +110,7 @@ public function createWcOrder() } else { $message = sprintf( /* translators: Placeholder 1: Payment method title */ - __( + __( 'Could not create %s payment.', 'mollie-payments-for-woocommerce' ), @@ -154,7 +154,7 @@ public function createWcOrderFromCart() } else { $message = sprintf( /* translators: Placeholder 1: Payment method title */ - __( + __( 'Could not create %s payment.', 'mollie-payments-for-woocommerce' ), diff --git a/src/Gateway/Surcharge.php b/src/Gateway/Surcharge.php index 1e3fde3f..bc966623 100644 --- a/src/Gateway/Surcharge.php +++ b/src/Gateway/Surcharge.php @@ -300,7 +300,7 @@ protected function name_fixed_fee_percentage($paymentMethod) $amountPercent = $paymentMethod->getProperty(self::PERCENTAGE); return sprintf( /* translators: Placeholder 1: Fee amount tag. Placeholder 2: Currency. Placeholder 3: Percentage amount. */ - __(' + %1$s %2$s + %3$s%% fee might apply', 'mollie-payments-for-woocommerce'), + __(' + %1$s %2$s + %3$s%% fee might apply', 'mollie-payments-for-woocommerce'), $currency, $amountFix, $amountPercent diff --git a/src/MerchantCapture/Capture/Action/CapturePayment.php b/src/MerchantCapture/Capture/Action/CapturePayment.php index 5d1e2b25..215fcca4 100644 --- a/src/MerchantCapture/Capture/Action/CapturePayment.php +++ b/src/MerchantCapture/Capture/Action/CapturePayment.php @@ -50,7 +50,7 @@ public function __invoke() $this->order->add_order_note( sprintf( /* translators: Placeholder 1: Order price */ - __( + __( 'The payment capture of %s has been sent successfully, and we are currently awaiting confirmation.', 'mollie-payments-for-woocommerce' ), diff --git a/src/Payment/MollieOrder.php b/src/Payment/MollieOrder.php index 2155092e..f64e5d86 100644 --- a/src/Payment/MollieOrder.php +++ b/src/Payment/MollieOrder.php @@ -757,7 +757,7 @@ public function refund_amount($order, $amount, $paymentObject, $reason) if ($paymentObject->isCreated() || $paymentObject->isAuthorized() || $paymentObject->isShipping()) { $noteMessage = sprintf( /* translators: Placeholder 1: payment status.*/ - _x( + _x( 'Can not refund order amount that has status %1$s at Mollie.', 'Order note error', 'mollie-payments-for-woocommerce' @@ -779,7 +779,7 @@ public function refund_amount($order, $amount, $paymentObject, $reason) ]); $noteMessage = sprintf( /* translators: Placeholder 1: Currency. Placeholder 2: Refund amount. Placeholder 3: Reason. Placeholder 4: Refund id.*/ - __('Amount refund of %1$s%2$s refunded in WooCommerce and at Mollie.%3$s Refund ID: %4$s.', 'mollie-payments-for-woocommerce'), + __('Amount refund of %1$s%2$s refunded in WooCommerce and at Mollie.%3$s Refund ID: %4$s.', 'mollie-payments-for-woocommerce'), $this->dataHelper->getOrderCurrency($order), $amount, ( ! empty($reason) ? ' Reason: ' . $reason . '.' : '' ), @@ -936,7 +936,7 @@ protected function processOrderItemsRefund( if ($refund === null) { $noteMessage = sprintf( /* translators: Placeholder 1: Number of items. Placeholder 2: Name of item. Placeholder 3: Currency. Placeholder 4: Amount.*/ - __( + __( '%1$sx %2$s cancelled for %3$s%4$s in WooCommerce and at Mollie.', 'mollie-payments-for-woocommerce' ), @@ -960,7 +960,7 @@ protected function processOrderItemsRefund( ); $noteMessage = sprintf( /* translators: Placeholder 1: Number of items. Placeholder 2: Name of item. Placeholder 3: Currency. Placeholder 4: Amount. Placeholder 5: Reason. Placeholder 6: Refund Id. */ - __( + __( '%1$sx %2$s refunded for %3$s%4$s in WooCommerce and at Mollie.%5$s Refund ID: %6$s.', 'mollie-payments-for-woocommerce' ), diff --git a/src/Payment/MollieOrderService.php b/src/Payment/MollieOrderService.php index 1b0c85d0..369dae46 100644 --- a/src/Payment/MollieOrderService.php +++ b/src/Payment/MollieOrderService.php @@ -405,7 +405,7 @@ protected function processChargebacks(WC_Order $order, $payment) $order->add_order_note( sprintf( /* translators: Placeholder 1: Chargeback to process id. */ - __( + __( 'New chargeback %s processed! Order note and order status updated.', 'mollie-payments-for-woocommerce' ), @@ -819,7 +819,7 @@ protected function notifyProcessedRefunds(array $refundsToProcess, string $logId $order->add_order_note( sprintf( /* translators: Placeholder 1: Refund to process id. */ - __( + __( 'New refund %s processed in Mollie Dashboard! Order note added, but order not updated.', 'mollie-payments-for-woocommerce' ), diff --git a/src/Payment/PaymentModule.php b/src/Payment/PaymentModule.php index b0bad152..31c721da 100644 --- a/src/Payment/PaymentModule.php +++ b/src/Payment/PaymentModule.php @@ -215,9 +215,10 @@ public function addOrderNoteForRefundCreated( WC_Order $order, array $data ) { + $orderNote = sprintf( /* translators: Placeholder 1: number of items. */ - __( + __( '%1$s items refunded in WooCommerce and at Mollie.', 'mollie-payments-for-woocommerce' ), @@ -236,7 +237,7 @@ public function addOrderNoteForCancelledLineItems(array $data, WC_Order $order) { $orderNote = sprintf( /* translators: Placeholder 1: number of items. */ - __( + __( '%1$s items cancelled in WooCommerce and at Mollie.', 'mollie-payments-for-woocommerce' ), diff --git a/src/Payment/RefundLineItemsBuilder.php b/src/Payment/RefundLineItemsBuilder.php index 5aa071a2..2815fad7 100644 --- a/src/Payment/RefundLineItemsBuilder.php +++ b/src/Payment/RefundLineItemsBuilder.php @@ -61,7 +61,7 @@ public function buildLineItems( throw new UnexpectedValueException( sprintf( /* translators: Placeholder 1: item id. */ - esc_html__( + esc_html__( 'Cannot refund %s item because it was not found in Mollie order. Aborting refund process. Try to do a refund by amount.', 'mollie-payments-for-woocommerce' ), diff --git a/src/PaymentMethods/Giftcard.php b/src/PaymentMethods/Giftcard.php index 742454d4..812e3cd7 100644 --- a/src/PaymentMethods/Giftcard.php +++ b/src/PaymentMethods/Giftcard.php @@ -28,7 +28,7 @@ public function debugGiftcardDetails( foreach ($details->giftcards as $giftcard) { $orderNoteLine .= sprintf( /* translators: Placeholder 1: giftcard issuer, Placeholder 2: amount value, Placeholder 3: currency */ - esc_html_x( + esc_html_x( 'Mollie - Giftcard details: %1$s %2$s %3$s.', 'Placeholder 1: giftcard issuer, Placeholder 2: amount value, Placeholder 3: currency', 'mollie-payments-for-woocommerce' @@ -41,7 +41,7 @@ public function debugGiftcardDetails( if ($details->remainderMethod) { $orderNoteLine .= sprintf( /* translators: Placeholder 1: Method Placeholder 2: Value Placeholder 3: currency */ - esc_html_x( + esc_html_x( ' Remainder: %1$s %2$s %3$s.', 'Placeholder 1: remainder method, Placeholder 2: amount value, Placeholder 3: currency', 'mollie-payments-for-woocommerce' diff --git a/src/PaymentMethods/Giropay.php b/src/PaymentMethods/Giropay.php index 825bfe0d..440b8f0b 100644 --- a/src/PaymentMethods/Giropay.php +++ b/src/PaymentMethods/Giropay.php @@ -32,7 +32,7 @@ public function getFormFields($generalFormFields): array 'title' => sprintf( /* translators: Placeholder 1: paragraph opening tag Placeholder 2: link url Placeholder 3: closing tags */ - __( + __( '%1$s Paydirekt, the owner of Giropay, has decided to deprecate Giropay. On Monday, 24 June 2024, Mollie was informed that Giropay would cease onboarding new merchants and processing new payments after 30 June 2024. No action is needed from your side. Mollie will automatically remove Giropay as a payment option from your Checkout by 30 June. Subscription renewals and refunds will continue to be processed as usual beyond June 30. More details can be found in the %2$s Giropay Deprecation FAQ. %3$s', 'mollie-payments-for-woocommerce' diff --git a/src/PaymentMethods/InstructionStrategies/MybankInstructionStrategy.php b/src/PaymentMethods/InstructionStrategies/MybankInstructionStrategy.php index 7980e530..631e998e 100644 --- a/src/PaymentMethods/InstructionStrategies/MybankInstructionStrategy.php +++ b/src/PaymentMethods/InstructionStrategies/MybankInstructionStrategy.php @@ -16,7 +16,7 @@ public function execute( if ($payment->isPaid() && $payment->details) { return sprintf( /* translators: Placeholder 1: Mollie_WC_Gateway_MyBank consumer name, placeholder 2: Consumer Account number */ - __( + __( 'Payment completed by %1$s - %2$s', 'mollie-payments-for-woocommerce' ), diff --git a/src/Settings/General/MollieGeneralSettings.php b/src/Settings/General/MollieGeneralSettings.php index b346516f..e6ef5457 100644 --- a/src/Settings/General/MollieGeneralSettings.php +++ b/src/Settings/General/MollieGeneralSettings.php @@ -93,9 +93,9 @@ public function gatewayFormFields( 'type' => 'file', 'custom_attributes' => ['accept' => '.png, .jpeg, .svg, image/png, image/jpeg'], 'description' => __( - 'Upload a custom icon for this gateway. The feature must be enabled.', - 'mollie-payments-for-woocommerce' - ), + 'Upload a custom icon for this gateway. The feature must be enabled.', + 'mollie-payments-for-woocommerce' + ), 'desc_tip' => true, ], 'description' => [ @@ -191,9 +191,9 @@ public function gatewayFormFields( 'title' => __('Payment surcharge percentage amount %', 'mollie-payments-for-woocommerce'), 'type' => 'number', 'description' => __( - 'Control the percentage fee added on checkout. Default 0.00', - 'mollie-payments-for-woocommerce' - ), + 'Control the percentage fee added on checkout. Default 0.00', + 'mollie-payments-for-woocommerce' + ), 'custom_attributes' => ['step' => '0.01', 'min' => '0.00', 'max' => '999'], 'default' => '0.00', 'desc_tip' => true, @@ -223,9 +223,9 @@ public function gatewayFormFields( ), 'type' => 'number', 'description' => __( - 'Maximum order amount to apply surcharge. If the order is above this number the surcharge will not apply. Default 0, means no maximum', - 'mollie-payments-for-woocommerce' - ), + 'Maximum order amount to apply surcharge. If the order is above this number the surcharge will not apply. Default 0, means no maximum', + 'mollie-payments-for-woocommerce' + ), 'custom_attributes' => ['step' => '0.01', 'min' => '0.00', 'max' => '999'], 'default' => '0.00', 'desc_tip' => true, @@ -260,7 +260,7 @@ public function gatewayFormFields( 'default' => SharedDataDictionary::STATUS_ON_HOLD, 'description' => sprintf( /* translators: Placeholder 1: Default order status, placeholder 2: Link to 'Hold Stock' setting */ - __( + __( 'Some payment methods take longer than a few hours to complete. The initial order state is then set to \'%1$s\'. This ensures the order is not cancelled when the setting %2$s is used. This will also prevent the order to be canceled when expired.', 'mollie-payments-for-woocommerce' ), @@ -289,9 +289,9 @@ public function gatewayFormFields( 'type' => 'number', 'custom_attributes' => ['step' => '1', 'min' => '10', 'max' => '526000'], 'description' => __( - 'Number of MINUTES after the order will expire and will be canceled at Mollie and WooCommerce.', - 'mollie-payments-for-woocommerce' - ), + 'Number of MINUTES after the order will expire and will be canceled at Mollie and WooCommerce.', + 'mollie-payments-for-woocommerce' + ), 'default' => '10', 'desc_tip' => false, ]; diff --git a/src/Settings/Settings.php b/src/Settings/Settings.php index 58e2203b..c9358964 100644 --- a/src/Settings/Settings.php +++ b/src/Settings/Settings.php @@ -665,7 +665,7 @@ protected function validateUploadedFile(string $fileName, string $fileTempName, if ($invalidFileSize) { $message = sprintf( /* translators: Placeholder 1: opening tag Placeholder 2: closing tag */ - esc_html__( + esc_html__( '%1$sMollie Payments for WooCommerce%2$s Unable to upload the file. Size must be under 500kb.', 'mollie-payments-for-woocommerce' ), diff --git a/src/Shared/Data.php b/src/Shared/Data.php index 1a12ff5a..54230c6d 100644 --- a/src/Shared/Data.php +++ b/src/Shared/Data.php @@ -272,8 +272,8 @@ public function getFilters( throw new InvalidArgumentException( sprintf( /* translators: Placeholder 1: amount value */ - esc_html__('Amount %s is not valid.', 'mollie-payments-for-woocommerce'), - esc_html($amountValue) + esc_html__('Amount %s is not valid.', 'mollie-payments-for-woocommerce'), + esc_html($amountValue) ) ); } diff --git a/tests/php/Functional/Payment/OrderItemsRefunderTest.php b/tests/php/Functional/Payment/OrderItemsRefunderTest.php index 35356308..15e04b90 100644 --- a/tests/php/Functional/Payment/OrderItemsRefunderTest.php +++ b/tests/php/Functional/Payment/OrderItemsRefunderTest.php @@ -250,7 +250,8 @@ public function testUnexpectedValueExceptionWhenBuildRemoteItems() $order = new \WC_Order(); stubs( [ - 'esc_html__' => null + 'esc_html__' => null, + 'esc_html' => null ] ); /** @var WC_Order_Item $orderItem */ @@ -302,7 +303,7 @@ public function testBailIfNoItemsToRefund() $refundReason = uniqid(); stubs( [ - 'esc_html__' => null + 'esc_html__' => null, ] ); diff --git a/tests/php/Functional/Payment/RefundLineItemsBuilderTest.php b/tests/php/Functional/Payment/RefundLineItemsBuilderTest.php index 4c9f9e60..b5924f04 100644 --- a/tests/php/Functional/Payment/RefundLineItemsBuilderTest.php +++ b/tests/php/Functional/Payment/RefundLineItemsBuilderTest.php @@ -340,7 +340,8 @@ public function testBuildLineItemsThrowUnexpectedValueExceptionBecauseRemoteItem $currency = uniqid(); stubs( [ - 'esc_html__' => null + 'esc_html__' => null, + 'esc_html' => null ] );