Skip to content

Feature/missing apis #55

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

Merged
merged 6 commits into from
Aug 5, 2025
Merged

Feature/missing apis #55

merged 6 commits into from
Aug 5, 2025

Conversation

mubbi
Copy link
Owner

@mubbi mubbi commented Aug 3, 2025

This pull request introduces several new features and improvements, primarily focusing on the addition of enums for statuses, new API controllers for managing articles and comments, and enhancements to the UserRole enum. The changes aim to improve code organization, readability, and functionality for admin-related operations.

Enum Enhancements

  • ArticleStatus enum: Added REVIEW and TRASHED statuses, along with utility methods displayName, isPublished, and isDraft for better status handling.
  • CommentStatus enum: Introduced a new enum with statuses (PENDING, APPROVED, REJECTED, SPAM) and utility methods displayName, isPublished, and isDraft.
  • UserRole enum: Updated role values to lowercase and added a displayName method for consistent display formatting.

Article Management API Controllers

  • ApproveArticleController: Enables approving and publishing articles, with error handling for not found and server issues.
  • FeatureArticleController: Allows marking articles as featured, with structured responses and error handling.
  • GetArticlesController: Provides a paginated list of articles with admin filters and metadata.
  • ReportArticleController: Adds functionality to report articles with a reason.
  • ShowArticleController: Retrieves a single article with detailed admin-related information.

Comment Management API Controllers

  • ApproveCommentController: Approves pending comments for publication, with error handling for missing comments.
  • DeleteCommentController: Permanently deletes comments and handles errors for non-existent comments.
  • GetCommentsController: Retrieves a paginated list of comments with filters and metadata.

Newsletter Management

  • DeleteSubscriberController: Adds functionality to remove a newsletter subscriber, with error handling for missing subscribers.

mubbi and others added 5 commits July 31, 2025 02:52
- Add strict type declarations and comprehensive PHPDoc annotations to all models
- Enhance enum implementations with proper type safety and display methods
- Improve API resources with better data transformation and conditional loading
- Update factories with realistic data generation and proper relationships
- Add comprehensive test coverage for authentication and user endpoints
- Implement proper validation rules and language file improvements
- Add new admin and user controller tests for complete API coverage
- Update middleware and request validation for better security
- Enhance service layer with improved business logic implementation
- Add missing API routes and improve existing endpoint functionality

This commit establishes PHPStan level 10 compliance across all models and
implements comprehensive testing to achieve 80%+ coverage requirements.
@mubbi mubbi requested a review from Copilot August 3, 2025 20:11
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 pull request introduces comprehensive API controllers for admin-related functionality, including user management, comment moderation, newsletter subscriber management, notification handling, and article administration. The main purpose is to expand the admin API capabilities with proper authorization, validation, and error handling.

  • Adds new API controllers for managing users (CRUD operations, ban/unban, block/unblock)
  • Implements comment moderation features (approval, deletion with admin notes)
  • Introduces newsletter subscriber management and notification system controllers
  • Updates existing test files to use named routes instead of hardcoded URLs
  • Adds comprehensive test coverage for all new admin functionality

Reviewed Changes

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

Show a summary per file
File Description
tests/Feature/Providers/AuthServiceProviderTest.php Updates error message to use localization function
tests/Feature/API/V1/User/UpdateProfileControllerTest.php New comprehensive test suite for user profile updates
tests/Feature/API/V1/User/MeControllerTest.php Enhanced test coverage with additional edge cases and route usage
tests/Feature/API/V1/Tag/GetTagsControllerTest.php Updated to use named routes
tests/Feature/API/V1/Category/GetCategoriesControllerTest.php Updated to use named routes
tests/Feature/API/V1/Auth/RefreshTokenControllerTest.php Updates error message to use localization
tests/Feature/API/V1/Auth/LogoutControllerTest.php Updates error message to use localization
tests/Feature/API/V1/Auth/LoginControllerTest.php Updates error message to use localization
tests/Feature/API/V1/Article/ShowArticleControllerTest.php Removes duplicate test line
tests/Feature/API/V1/Admin/User/*.php New comprehensive admin user management test suites
tests/Feature/API/V1/Admin/Comment/*.php New comment moderation test suites
tests/Feature/API/V1/Admin/Newsletter/*.php New newsletter management test suites
tests/Feature/API/V1/Admin/Notification/*.php New notification system test suites
tests/Feature/API/V1/Admin/Article/ShowArticleControllerTest.php New admin article management test suite
Comments suppressed due to low confidence (2)

tests/Feature/API/V1/Admin/Comment/ApproveCommentControllerTest.php:225

  • The test assumes admin_note validation will return 422, but the comment on line 211 suggests admin_note is optional and not strictly validated. This creates inconsistent test expectations.
        // Assert - admin_note should be validated and return 422 for exceeding max length

tests/Feature/API/V1/Admin/Comment/DeleteCommentControllerTest.php:210

  • The test comment indicates admin_note is not validated, but then asserts a 200 response. This suggests the validation logic may not be properly tested or implemented consistently across comment controllers.
        // Assert - admin_note is optional and not strictly validated

@mubbi mubbi merged commit bc52c54 into main Aug 5, 2025
4 checks passed
@mubbi mubbi deleted the feature/missing-apis branch August 5, 2025 22:30
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.

1 participant