Skip to content

feature/add-testing-trait#81

Merged
RamyHakam merged 2 commits intomasterfrom
feature/add-testing-trait
Feb 15, 2026
Merged

feature/add-testing-trait#81
RamyHakam merged 2 commits intomasterfrom
feature/add-testing-trait

Conversation

@RamyHakam
Copy link
Owner

@RamyHakam RamyHakam commented Feb 15, 2026

This pull request introduces a new TenantTestTrait to simplify and standardize tenant switching logic in tests, and refactors existing integration tests to use this trait instead of directly dispatching events. Additionally, a dedicated test suite is added to ensure the trait's correctness and robustness. These changes improve test maintainability, reduce boilerplate, and ensure consistent tenant state management across tests.

New test utility trait:

  • Added TenantTestTrait in src/Test/TenantTestTrait.php, providing reusable methods for switching tenants, resetting tenant-related state, and running code within a specific tenant context in tests. This trait encapsulates event dispatching and cleanup logic for tenant switching.

Refactoring of integration tests to use the trait:

  • Updated TenantConnectionSwitchingTest and TenantConnectionConfigDTOFlowTest to use TenantTestTrait for tenant switching and state management, replacing manual event dispatching with trait methods such as switchToTenant and resetTenantState. [1] [2] [3] [4] [5] [6] [7] [8] [9]

New tests for trait behavior:

  • Added TenantTestTraitTest to comprehensively test the behavior of TenantTestTrait, including correct state reset after execution, exception safety, manual and automatic reset scenarios, sequential calls, and idempotency of reset operations.

@RamyHakam RamyHakam self-assigned this Feb 15, 2026
@RamyHakam RamyHakam added the enhancement New feature or request label Feb 15, 2026
@RamyHakam RamyHakam merged commit d1282a5 into master Feb 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant