Skip to content

refactor: 🔨 enhance user-related tests#33

Merged
andrewdyer merged 22 commits into
mainfrom
refactor/tests
May 15, 2026
Merged

refactor: 🔨 enhance user-related tests#33
andrewdyer merged 22 commits into
mainfrom
refactor/tests

Conversation

@andrewdyer
Copy link
Copy Markdown
Owner

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:

  • Added fakerphp/faker as a development dependency in composer.json to enable random test data generation.
  • Introduced a UserFactory (tests/Support/Factories/UserFactory.php) for creating test users with generated or overridden data.
  • Created AbstractUsersTestCase (tests/Integration/Application/Users/AbstractUsersTestCase.php) as a base class for user-related integration tests, providing shared setup for UserRepository and UserFactory.
  • Refactored the main integration test base class: renamed to AbstractTestCase, added a Faker instance, and initialized it in setUp(). [1] [2] [3]

Test Case Refactoring:

  • Updated all user-related integration tests to extend AbstractUsersTestCase and utilize UserFactory and Faker for 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]

andrewdyer added 19 commits May 14, 2026 00:13
… creation and improved user structure assertions
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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/faker dev dependency, a UserFactory, and AbstractUsersTestCase.
  • Renames AbstractIntegrationTestCaseAbstractTestCase and exposes a shared Faker\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.
@andrewdyer andrewdyer merged commit 977f6ec into main May 15, 2026
1 check passed
@andrewdyer andrewdyer deleted the refactor/tests branch May 15, 2026 14:24
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