mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Add unit test
This commit is contained in:
parent
eb86f8a71d
commit
4a95f22e75
3 changed files with 39 additions and 19 deletions
|
@ -16,7 +16,7 @@ use WooCommerce\PayPalCommerce\WcSubscriptions\Helper\SubscriptionHelper;
|
|||
|
||||
return array(
|
||||
'wc-subscriptions.helper' => static function ( ContainerInterface $container ): SubscriptionHelper {
|
||||
return new SubscriptionHelper( $container->get( 'wcgateway.settings' ) );
|
||||
return new SubscriptionHelper();
|
||||
},
|
||||
'wc-subscriptions.renewal-handler' => static function ( ContainerInterface $container ): RenewalHandler {
|
||||
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
||||
|
|
|
@ -16,7 +16,6 @@ use WC_Product_Subscription_Variation;
|
|||
use WC_Subscription;
|
||||
use WC_Subscriptions;
|
||||
use WC_Subscriptions_Product;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
||||
|
||||
/**
|
||||
|
@ -24,22 +23,6 @@ use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
|||
*/
|
||||
class SubscriptionHelper {
|
||||
|
||||
/**
|
||||
* The settings.
|
||||
*
|
||||
* @var Settings
|
||||
*/
|
||||
private $settings;
|
||||
|
||||
/**
|
||||
* SubscriptionHelper constructor.
|
||||
*
|
||||
* @param Settings $settings The settings.
|
||||
*/
|
||||
public function __construct( Settings $settings ) {
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the current product is a subscription.
|
||||
*
|
||||
|
@ -308,7 +291,7 @@ class SubscriptionHelper {
|
|||
* @return string
|
||||
*/
|
||||
public function previous_transaction( WC_Subscription $subscription ): string {
|
||||
$orders = $subscription->get_related_orders( 'all', array( 'parent', 'renewal' ) );
|
||||
$orders = $subscription->get_related_orders( 'ids', array( 'parent', 'renewal' ) );
|
||||
if ( ! $orders ) {
|
||||
return '';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue