Skip to content

Commit

Permalink
Fixed deposit tests class
Browse files Browse the repository at this point in the history
  • Loading branch information
gpressutto5 committed Jan 4, 2024
1 parent a9b2903 commit 1f13e7e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class WC_Deposits_Product_Manager {
* @return mixed
*/
public static function get_deposit_type( $product ) {
if ( is_int( $product ) ) {
$product = wc_get_product( $product );
if ( ! is_object( $product ) ) {
$product = apply_filters( 'test_deposit_get_product', wc_get_product( $product ) );
}
return $product->get_meta( '_wc_deposit_type' );
}
Expand All @@ -27,8 +27,8 @@ public static function get_deposit_type( $product ) {
* @return bool
*/
public static function deposits_enabled( $product ) {
if ( is_int( $product ) ) {
$product = wc_get_product( $product );
if ( ! is_object( $product ) ) {
$product = apply_filters( 'test_deposit_get_product', wc_get_product( $product ) );
}
return true === $product->get_meta( '_wc_deposits_enabled' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,12 @@ public function provide_get_product_tax_tests() {

public function test_get_product_price_includes_subscription_sign_up_fee() {
$mock_product = $this->create_mock_subscription( 'subscription' );
add_filter(
'test_deposit_get_product',
function() use ( $mock_product ) {
return $mock_product;
}
);

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

public function test_get_product_price_includes_variable_subscription_sign_up_fee() {
$mock_product = $this->create_mock_subscription( 'subscription_variation' );
add_filter(
'test_deposit_get_product',
function() use ( $mock_product ) {
return $mock_product;
}
);

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

public function test_get_product_price_throws_exception_for_a_non_numeric_signup_fee() {
$mock_product = $this->create_mock_subscription( 'subscription' );
add_filter(
'test_deposit_get_product',
function() use ( $mock_product ) {
return $mock_product;
}
);
WC_Subscriptions_Product::set_sign_up_fee( 'a' );

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

0 comments on commit 1f13e7e

Please sign in to comment.