Skip to content

Commit 1f13e7e

Browse files
committed
Fixed deposit tests class
1 parent a9b2903 commit 1f13e7e

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

tests/unit/helpers/class-wc-helper-deposit-product-manager.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class WC_Deposits_Product_Manager {
1616
* @return mixed
1717
*/
1818
public static function get_deposit_type( $product ) {
19-
if ( is_int( $product ) ) {
20-
$product = wc_get_product( $product );
19+
if ( ! is_object( $product ) ) {
20+
$product = apply_filters( 'test_deposit_get_product', wc_get_product( $product ) );
2121
}
2222
return $product->get_meta( '_wc_deposit_type' );
2323
}
@@ -27,8 +27,8 @@ public static function get_deposit_type( $product ) {
2727
* @return bool
2828
*/
2929
public static function deposits_enabled( $product ) {
30-
if ( is_int( $product ) ) {
31-
$product = wc_get_product( $product );
30+
if ( ! is_object( $product ) ) {
31+
$product = apply_filters( 'test_deposit_get_product', wc_get_product( $product ) );
3232
}
3333
return true === $product->get_meta( '_wc_deposits_enabled' );
3434
}

tests/unit/test-class-wc-payments-payment-request-button-handler.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,12 @@ public function provide_get_product_tax_tests() {
446446

447447
public function test_get_product_price_includes_subscription_sign_up_fee() {
448448
$mock_product = $this->create_mock_subscription( 'subscription' );
449+
add_filter(
450+
'test_deposit_get_product',
451+
function() use ( $mock_product ) {
452+
return $mock_product;
453+
}
454+
);
449455

450456
// We have a helper because we are not loading subscriptions.
451457
WC_Subscriptions_Product::set_sign_up_fee( 10 );
@@ -458,6 +464,12 @@ public function test_get_product_price_includes_subscription_sign_up_fee() {
458464

459465
public function test_get_product_price_includes_variable_subscription_sign_up_fee() {
460466
$mock_product = $this->create_mock_subscription( 'subscription_variation' );
467+
add_filter(
468+
'test_deposit_get_product',
469+
function() use ( $mock_product ) {
470+
return $mock_product;
471+
}
472+
);
461473

462474
// We have a helper because we are not loading subscriptions.
463475
WC_Subscriptions_Product::set_sign_up_fee( 10 );
@@ -483,6 +495,12 @@ public function test_get_product_price_throws_exception_for_products_without_pri
483495

484496
public function test_get_product_price_throws_exception_for_a_non_numeric_signup_fee() {
485497
$mock_product = $this->create_mock_subscription( 'subscription' );
498+
add_filter(
499+
'test_deposit_get_product',
500+
function() use ( $mock_product ) {
501+
return $mock_product;
502+
}
503+
);
486504
WC_Subscriptions_Product::set_sign_up_fee( 'a' );
487505

488506
$this->expectException( WCPay\Exceptions\Invalid_Price_Exception::class );

0 commit comments

Comments
 (0)