refactor: 🔨 enhance user-related tests#33
Merged
Merged
Conversation
…creation and improved assertions
… creation and improved user structure assertions
…related integration tests
…n in ListUsersActionTest
…UpdateUserActionTest
There was a problem hiding this comment.
Pull request overview
Refactors the user-related integration tests to use dynamically generated test data via Faker and a new UserFactory, and introduces a shared AbstractUsersTestCase base class. Also renames AbstractIntegrationTestCase to AbstractTestCase and broadens .gitignore for env files.
Changes:
- Adds
fakerphp/fakerdev dependency, aUserFactory, andAbstractUsersTestCase. - Renames
AbstractIntegrationTestCase→AbstractTestCaseand exposes a sharedFaker\Generator. - Rewrites all five user action integration tests to use the factory/Faker and look up users by their generated IDs instead of hardcoded values.
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| .gitignore | Ignore all .env.* except .env.example. |
| composer.json / composer.lock | Add fakerphp/faker ^1.24 dev dependency. |
| tests/Integration/AbstractTestCase.php | Rename base class and add a Faker\Generator initialized in setUp(). |
| tests/Integration/Application/Users/AbstractUsersTestCase.php | New base class wiring UserRepository and UserFactory. |
| tests/Support/Factories/UserFactory.php | New factory creating users via repository with Faker data and overrides. |
| tests/Integration/Application/Users/Actions/CreateUserActionTest.php | Use Faker-generated payload and assert against generated values. |
| tests/Integration/Application/Users/Actions/DeleteUserActionTest.php | Create-then-delete pattern instead of hardcoded IDs; drops empty-body assertion. |
| tests/Integration/Application/Users/Actions/ListUsersActionTest.php | Seed via factory and assert created emails are present; removes structural test. |
| tests/Integration/Application/Users/Actions/ShowUserActionTest.php | Use factory-created user; not-found case deletes user first. |
| tests/Integration/Application/Users/Actions/UpdateUserActionTest.php | Use factory + Faker for both update payload and not-found scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Clarify return type and exception thrown in request method docblock.
Fix spelling of "Initialises" to "Initializes" in UserServiceTest docblock.
Clarify return types and descriptions in AbstractTestCase and HelpersTest.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors and improves the integration test suite for user-related actions. The changes introduce a reusable user test base class and a user factory, leverage the Faker library for generating test data, and update test cases to use dynamically generated data instead of hardcoded values. This results in more maintainable, realistic, and isolated tests.
Test Infrastructure Improvements:
fakerphp/fakeras a development dependency incomposer.jsonto enable random test data generation.UserFactory(tests/Support/Factories/UserFactory.php) for creating test users with generated or overridden data.AbstractUsersTestCase(tests/Integration/Application/Users/AbstractUsersTestCase.php) as a base class for user-related integration tests, providing shared setup forUserRepositoryandUserFactory.AbstractTestCase, added aFakerinstance, and initialized it insetUp(). [1] [2] [3]Test Case Refactoring:
AbstractUsersTestCaseand utilizeUserFactoryandFakerfor user creation and test data, replacing hardcoded values with dynamically generated data. This affects tests for creating, listing, showing, updating, and deleting users. [1] [2] [3] [4] [5] [6] [7]