Laravel unit testing function seeJsonStructure not working as expected
<p>Laravel <a href="https://laravel.com/docs/5.2/testing#testing-json-apis" rel="nofollow">docs</a> give an example of using function <code>seeJsonStructure</code> in PHPUnit testing:</p>

<pre><code>  public function testBasicExample() {
    $this-&gt;get('/user/1')
      -&gt;seeJsonStructure([
        'name',
        'pet' =&gt; [
          'name', 'age'
        ]
      ]);
  }
</code></pre>

<p>In my case, it seems that this function doesn't work as it's written in the docs. This is working for me:</p>

<pre><code>public function testShow() {
    $this-&gt;get('api/mymodel/1');
    $this-&gt;seeJsonStructure([[
      'id',
      'name'
    ]]);
  }
</code></pre>

<p>The structural difference is the double square brackets instead of single. If I use it with single brackets as non-nested array, there is an error: "Failed asserting that an array has the key 'id'."</p>

<p>My controller is simple:</p>

<pre><code>  public function show($id)
  {
    $items = MyModel::orderBy('name', 'ASC')
      -&gt;where('id', '=', $id)
      -&gt;get();
    return json_encode($items);
  }
</code></pre>

<p>I tried testing it also without <code>json_encode</code> in controller (returning just <code>$items</code>), but it was the same (worked only with double brackets)</p>

<p>I'd like to know whether it's a typo in the docs, or my controller is not returning what normally a controller should return as json api.</p>