Skip to content

Conversation

@zigzagdev
Copy link
Owner

Description

This PR introduces the getOthersPosts() controller action which handles the retrieval of paginated public posts by users other than the specified user ID. It integrates:

  • Request validation and pagination parameters (per_page, current_page)
  • UseCase invocation: GetOthersAllPostsUseCase
  • DTO to ViewModel mapping (GetUserEachPostDtoGetAllUserPostViewModel)
  • PaginationViewModel formatting using PaginationViewModelFactory
  • JSON response formatting with status, data, and meta
  • Global Throwable exception catch and error response

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

  • Route-resolved userId, per_page, current_page handled safely
  • UseCase and ViewModel responsibilities remain separated
  • Proper exception handling for runtime errors
  • Tests cover both success and failure scenarios
  • JSON response is frontend-consumable and consistent

@zigzagdev zigzagdev requested a review from Copilot July 6, 2025 09:02
@zigzagdev zigzagdev self-assigned this Jul 6, 2025
@zigzagdev zigzagdev linked an issue Jul 6, 2025 that may be closed by this pull request
@zigzagdev zigzagdev merged commit cde7930 into feature/see-other-posts-presentation Jul 6, 2025
Copy link

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 adds a new controller action for fetching paginated public posts by other users, introduces a feature test for it, and removes an unused mock helper from an existing view model test.

  • Introduce getOthersPosts() in PostController with pagination, mapping, and error handling
  • Add PostController_getOthersPostsTest to verify JSON response type
  • Clean up GetPostViewModelCollectionTest by removing the unused mockEntityCollection method

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/app/Post/Presentation/PresentationTest/GetPostViewModelCollectionTest.php Removed unused mockEntityCollection method
src/app/Post/Presentation/PresentationTest/Controller/PostController_getOthersPostsTest.php Added new feature test for getOthersPosts action
src/app/Post/Presentation/Controller/PostController.php Added getOthersPosts method and its imports
Comments suppressed due to low confidence (4)

src/app/Post/Presentation/PresentationTest/Controller/PostController_getOthersPostsTest.php:77

  • This test only asserts the response class; consider adding assertions for status code and JSON payload (status, data, meta) to verify correct behavior.
    public function test_controller_type_check(): void

src/app/Post/Presentation/Controller/PostController.php:190

  • Throwable is not imported in this file; add use Throwable; at the top to prevent an undefined class error.
        } catch (Throwable $e) {

src/app/Post/Presentation/Controller/PostController.php:179

  • PaginationViewModelFactory is referenced but not imported; add use App\Post\Presentation\ViewModel\PaginationViewModelFactory; to the imports.
            $paginationViewModel = PaginationViewModelFactory::build(

src/app/Post/Presentation/Controller/PostController.php:175

  • GetUserEachPostDto and GetAllUserPostViewModel may not be imported; ensure you add their use statements (use App\Post\Application\Dto\GetUserEachPostDto; and use App\Post\Presentation\ViewModel\GetAllUserPostViewModel;).
                fn(GetUserEachPostDto $dto) => GetAllUserPostViewModel::build($dto)->toArray(),

$request = Mockery::mock(Request::class);

$request->shouldReceive('input')
->with('perPage')
Copy link

Copilot AI Jul 6, 2025

Choose a reason for hiding this comment

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

The test mocks input('perPage') but the controller uses get('per_page'); update the mock to input('per_page') or align the parameter naming between test and controller.

Suggested change
->with('perPage')
->with('per_page')

Copilot uses AI. Check for mistakes.
->andReturn($this->perPage);

$request->shouldReceive('input')
->with('currentPage')
Copy link

Copilot AI Jul 6, 2025

Choose a reason for hiding this comment

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

The test mocks input('currentPage') but the controller uses get('current_page'); update the mock to input('current_page') or make naming consistent.

Suggested change
->with('currentPage')
->with('current_page')

Copilot uses AI. Check for mistakes.
$useCase->shouldReceive('handle')
->with(
Mockery::type('int'),
Mockery::type($this->perPage),
Copy link

Copilot AI Jul 6, 2025

Choose a reason for hiding this comment

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

Using Mockery::type($this->perPage) will not match the integer type; use Mockery::type('int') or a more specific matcher instead.

Suggested change
Mockery::type($this->perPage),
Mockery::type('int'),

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

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

See Other Posts Presentation Controller

1 participant