Skip to content

Testing coverage: add tests to cover different scenarios#883

Merged
gcatanese merged 9 commits intomainfrom
increase-test-coverage
Feb 5, 2026
Merged

Testing coverage: add tests to cover different scenarios#883
gcatanese merged 9 commits intomainfrom
increase-test-coverage

Conversation

@gcatanese
Copy link
Contributor

The goal of this PR is to add and improve tests, before starting the upgrade of the PHP OpenAPI Generator.

The following changes have been included:

  • improve client mocking
  • add tests using models
  • extend test coverage in some services
  • split Webhook tests
  • add tests to verify the baseUrl is correctly generated for the different services

@gcatanese gcatanese requested review from a team as code owners February 4, 2026 16:04
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @gcatanese, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the testing suite by introducing model-based request and response handling in unit tests for several Adyen services, ensuring better adherence to API contracts and improving code maintainability. It also refactors webhook parsing tests into dedicated modules and adds comprehensive checks for base URL generation, laying a solid foundation for future PHP OpenAPI Generator upgrades.

Highlights

  • Enhanced Test Coverage with Models: New tests have been added across various services (Checkout, Balance Platform, Legal Entity Management) to utilize OpenAPI generated model objects for requests, improving type safety and test robustness. Existing array-based tests have been retained and renamed to differentiate them from the new model-based tests.
  • Improved Client Mocking: The TestCaseMock class has been updated to include a handleCurlError method in its mock, allowing for more precise testing of error scenarios, particularly when API keys are missing.
  • Webhook Test Refactoring: Webhook parsing tests have been split into dedicated unit test files for Banking, Management, and Tokenization webhooks, moving them out of the general NotificationTest.php for better organization and clarity.
  • Base URL Generation Verification: New tests have been introduced to explicitly verify that the createBaseUrl method correctly generates service-specific base URLs for different environments (test and live) across various Adyen APIs, including Legal Entity Management, Balance Platform, Management, Transfers, BinLookup, Payout, and Recurring.
  • New Test Resources: Several new JSON resource files have been added to support the expanded test coverage for Balance Platform and Legal Entity Management API calls, providing realistic request and response payloads.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • tests/Resources/BalancePlatform/create-account-holder-request.json
    • Added new JSON resource for create-account-holder request.
  • tests/Resources/BalancePlatform/create-account-holder-response.json
    • Added new JSON resource for create-account-holder response.
  • tests/Resources/Checkout/donations-success.json
    • Modified the structure of the donation success JSON response to align with updated API specifications.
  • tests/Resources/LegalEntityManagement/create-legal-entity-request.json
    • Added new JSON resource for create-legal-entity request.
  • tests/Resources/LegalEntityManagement/create-legal-entity-response.json
    • Added new JSON resource for create-legal-entity response.
  • tests/Resources/LegalEntityManagement/update-legal-entity-request.json
    • Added new JSON resource for update-legal-entity request.
  • tests/Resources/LegalEntityManagement/update-legal-entity-response.json
    • Added new JSON resource for update-legal-entity response.
  • tests/Unit/BalancePlatformTest.php
    • Removed unused Adyen\Client and other imports.
    • Added Adyen\Model\BalancePlatform\AccountHolderInfo import.
    • Introduced testCreateAccountHolder to test account holder creation using model objects.
  • tests/Unit/BankingWebhookParserTest.php
    • Added new unit test file for BankingWebhookParser.
    • Includes tests for various banking webhook types: AccountHolder, SweepConfiguration, Authentication, TransactionV4, BalanceAccountBalance, RelayedAuthentication, ReleasedBlockedBalance, and RelayedAuthorisation notifications.
  • tests/Unit/CheckoutTest.php
    • Refactored existing tests to create new model-based versions (e.g., testPaymentMethodsSuccess now uses PaymentMethodsRequest model).
    • Renamed original array-based tests with WithArray suffix (e.g., testPaymentMethodsSuccessWithArray).
    • Added testPaymentLinksFailure to specifically test for missing reference in payment link requests using models.
  • tests/Unit/LegalEntityManagementTest.php
    • Added imports for various Legal Entity Management model objects.
    • Introduced testCreateLegalEntity to test legal entity creation using model objects.
    • Introduced testUpdateLegalEntity to test legal entity updates using model objects.
  • tests/Unit/ManagementWebhookParserTest.php
    • Added new unit test file for ManagementWebhookParser.
    • Includes tests for PaymentMethodCreatedNotificationRequest.
  • tests/Unit/NotificationTest.php
    • Removed all webhook-related imports and tests, delegating them to specific webhook parser test files.
  • tests/Unit/ServiceTest.php
    • Added new tests to verify correct base URL generation for Legal Entity Management, Balance Platform, Management, Transfers, BinLookup, Payout, and Recurring services in both test and live environments.
  • tests/Unit/TestCaseMock.php
    • Modified createMockClient to include a handleCurlError mock, allowing for more robust error handling tests, especially for missing API keys.
  • tests/Unit/TokenizationWebhookParserTest.php
    • Added new unit test file for TokenizationWebhookParser.
    • Includes tests for TokenizationCreatedDetailsNotificationRequest, TokenizationDisabledDetailsNotificationRequest, TokenizationUpdatedDetailsNotificationRequest, and TokenizationAlreadyExistingDetailsNotificationRequest.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gcatanese gcatanese enabled auto-merge February 4, 2026 16:06
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly enhances the test coverage by introducing new test resources and dedicated test files for webhook parsers. The refactoring of webhook tests into separate files improves code organization and maintainability. Additionally, new test methods have been added to cover model-based API calls across various services, which is a valuable improvement for ensuring the correctness of the API client. However, there are a few areas that require attention, including updating deprecated PHPUnit assertions, resolving a duplicated test method, and correcting some live URL assertions in ServiceTest.php.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 5, 2026

@gcatanese gcatanese added this pull request to the merge queue Feb 5, 2026
Merged via the queue into main with commit ff89742 Feb 5, 2026
9 checks passed
@gcatanese gcatanese deleted the increase-test-coverage branch February 5, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants