Skip to content

Conversation

zigzagdev
Copy link
Owner

Description

This pull request introduces the GetAllUserPostUseCase class to the application layer.
Its primary function is to retrieve all posts associated with a given user ID, using the GetAllUserPostQueryServiceInterface, and return them as a paginated result.

Details:

  • Introduced GetAllUserPostUseCase with method handle(int $userId, int $perPage, int $currentPage): Pagination
  • Delegates actual data retrieval to the query service
  • Keeps application logic clean and focused on orchestration

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

  • UseCase remains decoupled from infrastructure and domain internals
  • Pagination DTO is returned as expected
  • Tested the contract through the interface method in tests
  • Method signature clearly conveys its parameters and return type

@zigzagdev zigzagdev requested a review from Copilot June 14, 2025 08:32
@zigzagdev zigzagdev self-assigned this Jun 14, 2025
@zigzagdev zigzagdev added enhancement New feature or request backend labels Jun 14, 2025
@zigzagdev zigzagdev linked an issue Jun 14, 2025 that may be closed by this pull request
@zigzagdev zigzagdev merged commit 0807467 into feature/show-post-index-application Jun 14, 2025
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

Introduces a new use case for fetching all posts by a user with pagination and accompanying unit tests.

  • Adds GetAllUserPostUseCase to orchestrate paginated retrieval via a query service.
  • Adds GetAllUserPostUseCaseTest with mocks for the query service and pagination DTOs.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/app/Post/Application/UseCase/GetAllUserPostUseCase.php New use case class that delegates to GetAllUserPostQueryServiceInterface.
src/app/Post/Application/ApplicationTest/GetAllUserPostUseCaseTest.php Unit test for the use case, mocking the query service and pagination.
Files not reviewed (1)
  • .idea/workspace.xml: Language not supported
Comments suppressed due to low confidence (3)

src/app/Post/Application/ApplicationTest/GetAllUserPostUseCaseTest.php:52

  • Using Mockery::on('is_int') may not work as intended since on() expects a closure. Use Mockery::on(fn($v) => is_int($v)) instead.
->with(Mockery::on('is_int'),

src/app/Post/Application/ApplicationTest/GetAllUserPostUseCaseTest.php:128

  • The test only asserts the return type; consider adding assertions for pagination properties (current page, per page, total) and verifying returned item data to ensure completeness.
$this->assertInstanceOf(Pagination::class, $result);

src/app/Post/Application/ApplicationTest/GetAllUserPostUseCaseTest.php:33

  • The property $this->userId is never initialized before use in arrayRequestData(), which will result in null values. Initialize it in setUp() or replace with a literal value.
'userId' => $this->userId,


namespace App\Post\Application\UseCase;

use App\Common\Domain\ValueObject\UserId;
Copy link

Copilot AI Jun 14, 2025

Choose a reason for hiding this comment

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

The import of UserId is not used in this class; consider removing it to clean up unused imports.

Suggested change
use App\Common\Domain\ValueObject\UserId;

Copilot uses AI. Check for mistakes.

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 Posts Index UseCase

1 participant