Skip to content

[5.4] TestResponse::assertJsonMissing() not working for nested keys #20431

@behzadsh

Description

@behzadsh
  • Laravel Version: 5.4.28
  • PHP Version: 7.1.5

Description:

Let's say we have an API that would return a json like this:

{ "foo": "bar", "baz": { "qux": "quux", "corge": "uier" } }

and we want to test that corge inside baz object is missing

<?php class ExampleTest extends TestCase { public function testJsonMissing() { $response = $this->json('GET', "/api/foobar"); $response->assertJsonMissing(['foo']) // this is ok and will be failed ->assertJsonMissing(['baz' => ['corge']]); // this should fail but will pass } }

The test should fail but it will pass!

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