-
Notifications
You must be signed in to change notification settings - Fork 0
Add GetOthersPostsController action and its feature test #345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GetOthersPostsController action and its feature test #345
Conversation
There was a problem hiding this 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_pagehandled 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
There was a problem hiding this 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()inPostControllerwith pagination, mapping, and error handling - Add
PostController_getOthersPostsTestto verify JSON response type - Clean up
GetPostViewModelCollectionTestby removing the unusedmockEntityCollectionmethod
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
Throwableis not imported in this file; adduse Throwable;at the top to prevent an undefined class error.
} catch (Throwable $e) {
src/app/Post/Presentation/Controller/PostController.php:179
PaginationViewModelFactoryis referenced but not imported; adduse App\Post\Presentation\ViewModel\PaginationViewModelFactory;to the imports.
$paginationViewModel = PaginationViewModelFactory::build(
src/app/Post/Presentation/Controller/PostController.php:175
GetUserEachPostDtoandGetAllUserPostViewModelmay not be imported; ensure you add theirusestatements (use App\Post\Application\Dto\GetUserEachPostDto;anduse App\Post\Presentation\ViewModel\GetAllUserPostViewModel;).
fn(GetUserEachPostDto $dto) => GetAllUserPostViewModel::build($dto)->toArray(),
| $request = Mockery::mock(Request::class); | ||
|
|
||
| $request->shouldReceive('input') | ||
| ->with('perPage') |
Copilot
AI
Jul 6, 2025
There was a problem hiding this comment.
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.
| ->with('perPage') | |
| ->with('per_page') |
| ->andReturn($this->perPage); | ||
|
|
||
| $request->shouldReceive('input') | ||
| ->with('currentPage') |
Copilot
AI
Jul 6, 2025
There was a problem hiding this comment.
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.
| ->with('currentPage') | |
| ->with('current_page') |
| $useCase->shouldReceive('handle') | ||
| ->with( | ||
| Mockery::type('int'), | ||
| Mockery::type($this->perPage), |
Copilot
AI
Jul 6, 2025
There was a problem hiding this comment.
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.
| Mockery::type($this->perPage), | |
| Mockery::type('int'), |
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:per_page,current_page)GetOthersAllPostsUseCaseGetUserEachPostDto→GetAllUserPostViewModel)PaginationViewModelFactorystatus,data, andmetaThrowableexception catch and error response