Skip to content

The json delete method in PHPUnit does not work #45403

Closed

Description

@thomas-tahmasebi
  • Laravel Version: 9.19
  • PHP Version: 8.1.13
  • Database Driver & Version:

Description:

In PHPunit, I would like to send a delete request using a json method as follows:
$this->json('delete', '/api/roles/99', [])
But it will return this:

  1. Tests\Unit\RoleTest::test_delete_a_role
    Error: Call to undefined method Tests\Unit\RoleTest::json()

/var/www/html/tests/Unit/RoleTest.php:16

ERRORS!
Tests: 2, Assertions: 1, Errors: 1.

Steps To Reproduce:

Activity

  1. changed the title [-]PHPUnit delete method doesn't work[/-] [+]The json delete method in PHPUnit does not work[/+] on Dec 22, 2022
  2. johanrosenson commented on Dec 23, 2022

    @johanrosenson
    Contributor

    unit tests extend PHPUnit\Framework\TestCase by default, you need to extend Tests\TestCase instead to get the http test helpers.

  3. locked and limited conversation to collaborators on Dec 23, 2022
  4. converted this issue into a discussion #45408 on Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions