Skip to content

Conversation

zigzagdev
Copy link
Owner

Description

This PR addresses a routing issue in the User_RegisterTest class where the endpoint was incorrectly defined as api/user/register instead of the intended api/users/register, which aligns with the actual route defined in the routes/api.php file.

The correction ensures that the tests hit the proper registration endpoint and avoids false-negative test results caused by 404 Not Found responses.

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

  • Replaced 'api/user/register' with 'api/users/register' in both test methods
  • Verified the corresponding route exists: Route::post('register', [UserController::class, 'createUser'])->name('register'); within the users prefix group
  • Ensured that the tests now return status code 201 as expected
  • Retained the structure and assertions to preserve original intent
  • Confirmed that this change does not introduce side-effects to other test suites

@zigzagdev zigzagdev requested a review from Copilot July 7, 2025 11:07
@zigzagdev zigzagdev self-assigned this Jul 7, 2025
@zigzagdev zigzagdev linked an issue Jul 7, 2025 that may be closed by this pull request
@zigzagdev zigzagdev merged commit 4534291 into feature/fix-user-api-tests Jul 7, 2025
@zigzagdev zigzagdev deleted the feature/fix-user-api-test-register branch July 7, 2025 11:07
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 corrects the API endpoint used in user registration tests and improves test method names for clarity.

  • Renamed test methods to descriptive names
  • Updated endpoint from api/user/register to api/users/register
Comments suppressed due to low confidence (4)

src/app/User/Tests/User_RegisterTest.php:32

  • [nitpick] The method name is verbose and slightly inconsistent; consider renaming to test_register_user_with_nullable_properties to follow a clearer word order and match naming conventions.
    public function test_register_user_with_properties_nullable(): void

src/app/User/Tests/User_RegisterTest.php:54

  • [nitpick] This name could better communicate its purpose; e.g., test_registration_fails_with_invalid_data to make it clear that registration is what fails.
    public function test_failed_with_invalid_data(): void

src/app/User/Tests/User_RegisterTest.php:51

  • After checking the status code, you may want to assert key parts of the JSON response (e.g., user ID or success message) to ensure the endpoint returns the expected payload structure.
        $this->assertEquals(201, $response->getStatusCode());

src/app/User/Tests/User_RegisterTest.php:47

  • The endpoint string is duplicated across tests; consider extracting it into a class constant or helper method to avoid repetition and ease future updates.
                'api/users/register',

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User Register Test

1 participant