Skip to content

Commit

Permalink
Merge branch 'develop' into fix/fatals-on-plugin-update
Browse files Browse the repository at this point in the history
  • Loading branch information
timur27 authored Apr 29, 2024
2 parents a9f9249 + eddecf7 commit 5537a36
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/post-release-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ jobs:
echo ":warning: File "$NEXT_RELEASE_VERSION_INSTRUCTIONS_FILENAME.md" already exists. No action needed." >> $GITHUB_STEP_SUMMARY
fi
# If an entry for the next version doesn't exist yet
# Check if this release version exists in Release-testing-instructions.md
if ! grep -q "v$NEXT_RELEASE_VERSION" Release-testing-instructions.md; then
# If it doesn't exist, remove all trailing newlines and add the new version for this release
perl -pi -e 'BEGIN{undef $/;} s/\n+\z//' Release-testing-instructions.md
echo -ne "\n* [v$NEXT_RELEASE_VERSION](https://github.com/Automattic/woocommerce-payments/wiki/$NEXT_RELEASE_VERSION_INSTRUCTIONS_FILENAME)" >> Release-testing-instructions.md
echo "Added a new entry for v$NEXT_RELEASE_VERSION in \"Release-testing-instructions.md\"." >> $GITHUB_STEP_SUMMARY
HAS_CHANGES=true
Expand Down
4 changes: 4 additions & 0 deletions changelog/fix-5151-fraud-outcome-type-error
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix type error for fraud outcome API.
5 changes: 5 additions & 0 deletions changelog/update-post-release-updates
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Just a minor change in a GitHub Actions workflow to make it more robust.


Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use WC_Payments_Utils;
use WC_Payments_API_Client;
use WCPay\Constants\Fraud_Meta_Box_Type;
use WCPay\Fraud_Prevention\Models\Rule;

/**
* Request class for getting intents.
Expand All @@ -37,6 +38,10 @@ class List_Fraud_Outcome_Transactions extends Paginated {
* @throws Invalid_Request_Parameter_Exception
*/
public function get_api(): string {
$status = $this->status ?? 'null';
if ( ! Rule::is_valid_fraud_outcome_status( $status ) ) {
throw new Invalid_Request_Parameter_Exception( "Invalid fraud outcome status provided: $status", 'invalid_fraud_outcome_status' );
}
return WC_Payments_API_Client::FRAUD_OUTCOMES_API . '/status/' . $this->status;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

use PHPUnit\Framework\MockObject\MockObject;
use WCPay\Core\Exceptions\Server\Request\Invalid_Request_Parameter_Exception;
use WCPay\Core\Server\Request\List_Fraud_Outcome_Transactions;

/**
Expand Down Expand Up @@ -68,6 +69,7 @@ public function test_list_fraud_outcome_transactions_request() {
$this->assertSame( 'GET', $request->get_method() );
$this->assertSame( WC_Payments_API_Client::FRAUD_OUTCOMES_API . '/status/' . $status, $request->get_api() );
}

public function test_list_fraud_outcome_transactions_request_using_from_rest_request_function() {
$page = 2;
$page_size = 50;
Expand Down Expand Up @@ -569,4 +571,29 @@ public function test_list_fraud_outcome_transactions_request_filters_out_non_blo

$this->assertEquals( $expected, $result );
}

/**
* Checks to see if the get_api method throws an exception if an invalid status is passed.
*
* @param ?string $status The status to check.
*
* @return void
*
* @dataProvider provider_get_api_exception_on_invalid_status
*/
public function test_get_api_exception_on_invalid_status( $status ): void {
$request = new List_Fraud_Outcome_Transactions( $this->mock_api_client, $this->mock_wc_payments_http_client );
$request->set_status( $status );

$status = $status ?? 'null';

$this->expectException( Invalid_Request_Parameter_Exception::class );
$this->expectExceptionMessage( "Invalid fraud outcome status provided: $status" );

$request->get_api();
}

public function provider_get_api_exception_on_invalid_status(): array {
return [ [ 'invalid' ], [ null ] ];
}
}

0 comments on commit 5537a36

Please sign in to comment.