Skip to content

Conversation

zigzagdev
Copy link
Owner

Description

This PR introduces the GetAllUserPostQueryService class, responsible for fetching all posts associated with a given user ID. It adheres to the interface GetAllUserPostQueryServiceInterface and returns a PostEntityCollection by transforming raw Eloquent models into domain entities via PostFromModelEntityFactory.

Additionally, an integration test GetAllUserPostQueryServiceTest has been added to verify:

  • The return type of the method is PostEntityCollection
  • The content of the collection matches the expected post values

Changes

  • Added GetAllUserPostQueryService with a constructor-injected Post model
  • Implemented getAllUserPosts(int $userId): PostEntityCollection
  • Created a test user and inserted dummy post data in test setup
  • Verified the result type and content correctness

@zigzagdev zigzagdev requested a review from Copilot June 13, 2025 00:20
@zigzagdev zigzagdev self-assigned this Jun 13, 2025
@zigzagdev zigzagdev added enhancement New feature or request backend labels Jun 13, 2025
@zigzagdev zigzagdev linked an issue Jun 13, 2025 that may be closed by this pull request
Copy link

@Copilot 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

This PR implements a new query service, GetAllUserPostQueryService, for retrieving posts by user ID, along with its integration tests. The key changes include:

  • Introducing GetAllUserPostQueryService with dependency injection of the Post model.
  • Adding integration tests to verify return type and correct post count.
  • Updating PostFromModelEntityFactory to use PostVisibilityEnum::fromString for transforming raw visibility values.

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

File Description
src/app/Post/Infrastructure/QueryService/GetAllUserPostQueryService.php Implements the query service that maps model data to domain entities.
src/app/Post/Infrastructure/InfrastructureTest/GetAllUserPostQueryServiceTest.php Provides integration tests to confirm correct type and expected post count.
src/app/Post/Domain/EntityFactory/PostFromModelEntityFactory.php Updates entity factory to convert the visibility attribute via PostVisibilityEnum::fromString.
Files not reviewed (1)
  • .idea/workspace.xml: Language not supported
Comments suppressed due to low confidence (1)

src/app/Post/Domain/EntityFactory/PostFromModelEntityFactory.php:21

  • Ensure that the value provided to fromString is of type string. Since the inserted dummy posts appear to use integer values (e.g., 0 or 1) for visibility, confirm that fromString can handle those integer inputs or perform an appropriate conversion.
PostVisibilityEnum::fromString($request['visibility'])

Copy link
Owner Author

@zigzagdev zigzagdev left a comment

Choose a reason for hiding this comment

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

Self-review

  • Confirmed that PostFromModelEntityFactory::build() receives array input correctly
  • Verified that PostVisibility enum conversion works from integer values stored in the DB
  • Ensured test database is truncated before and after each test to maintain isolation
  • Avoided unnecessary mocking in favour of integration-style validation
  • Confirmed tests pass locally with phpunit and reflect actual DB-layer behaviour

@zigzagdev zigzagdev merged commit e32a9ef into feature/show-post-index Jun 13, 2025
@zigzagdev zigzagdev deleted the feature/show-post-index-infrastructure branch June 13, 2025 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Show Post Infrastructre Layer QueryService

1 participant