title: codeception laravel seeResponseContainsJson don't match
body: <p>I've got frim the server this response :</p>
  
  <blockquote>
    <p>)]}', {"success":0,"errors":{"error":["Invalid username or
    password."]}}</p>
  </blockquote>
  
  <p>and I'm not able to do work seeResponseContainsJson
  I've tried with:</p>
  
  <pre><code>public function invalidUserShouldBe200AndJsonTest(AcceptanceTester $I)
      {
          $I-&gt;wantTo('To see a 200 status code and a json response');
          $I-&gt;sendAjaxPostRequest('/api/v1/signin',array('email'=&gt;'user@users.com','password'=&gt;'user'));
          $I-&gt;seeResponseCodeIs('200');
          $I-&gt;seeResponseIsJson();
          $I-&gt;seeResponseContainsJson(array('errors' =&gt; array('error' =&gt; array('Invalid username or password.'))));
      }
  </code></pre>
  
  <p>but I've got</p>
  
  <blockquote>
    <p>I see response contains json {"errors":{"error":["Invalid username or
    password."]}}</p>
  </blockquote>
  
  <p>and it's the same also if the response is</p>
  
  <blockquote>
    <p>{"success":0,"errors":{"error":["Invalid username orpassword."]}}</p>
  </blockquote>
  
  <p>mmm should be something wrong if I try</p>
  
  <pre><code>$I-&gt;seeResponseIsJson();
  dd($I-&gt;grabResponse());
  </code></pre>
  
  <p>seeResponseIsJson give me a green bar but grabResponse get me "" :(</p>
  
  <h2>my test</h2>
  
  <pre><code>use \AcceptanceTester;
  
  class SessionControllerCest
  {
  
      public function _before(\AcceptanceTester $I)
      {
          $I-&gt;wantTo('Grab the XSRF-TOKEN cookie value');
          $I-&gt;amOnPage('/');
          $text = $I-&gt;grabTextFrom('body &gt; div &gt; script');
          $chunks1 = explode("\n", trim($text));
          $chunks2 = explode("=", trim($chunks1[1]));
          $cookieValue = rtrim($chunks2[2], ';"');
          $I-&gt;setCookie('XSRF-TOKEN',$cookieValue);
          $I-&gt;setHeader('X-XSRF-TOKEN',$cookieValue);
      }
  
      public function _after()
      {
      }
  
      // tests
      public function invalidUserShouldBe200AndJsonTest(AcceptanceTester $I)
      {
          $I-&gt;wantTo('To see a 200 status code and a json response');
          $I-&gt;sendAjaxPostRequest('/api/v1/signin',array('email'=&gt;'user@user.com','password'=&gt;'sentryuser'));
          $I-&gt;seeCookie('XSRF-TOKEN');
          $I-&gt;seeResponseCodeIs('200');
          $I-&gt;seeResponseIsJson();// until here green bar
         // dd($I-&gt;grabResponse()); // empty string
          //$I-&gt;seeResponseContainsJson(array('success' =&gt; 0,'errors' =&gt; array('error' =&gt; array('Invalid username or password.'))));
  
          $I-&gt;seeResponseContains(""); // red bar 
      }
  }
  </code></pre>
  
  <p>I set like that in _before because of Cross Site Request Forgery (XSRF) Protection
  it's like</p>
  
  <pre><code>Route::filter('xhr', function()
  {
      if(!Request::ajax()){
          return Response::make('Not Found', 404);
      } 
  
  });
  
  Route::filter('xsrf', function()
  {
      if((!isset($_COOKIE['XSRF-TOKEN']) || is_null(Request::header('X-XSRF-TOKEN'))) || ($_COOKIE['XSRF-TOKEN'] !== Request::header('X-XSRF-TOKEN'))){
          return Response::make('Not Found', 404);
      }
  });
  </code></pre>
  
  <h2>the route</h2>
  
  <pre><code>Route::group(array('prefix' =&gt; 'api/v1', 'before' =&gt; 'xhr|xsrf'), function() {
      /* Session */
      Route::post('signin', array('as' =&gt; 'session.store', 'uses' =&gt; 'App\Controllers\SessionController@store'));
  });
  </code></pre>
  
  <h2>DEBUG</h2>
  
  <p>There is something wrong if I comment the _before block
  trying to send a cUrl request like:</p>
  
  <pre><code>curl -H 'X-Requested-With: XMLHttpRequest' -d "email=user@user.com" \
  -d "password=mysentryuser" \
  http://lama.io/api/v1/signin
  </code></pre>
  
  <p>I get </p>
  
  <blockquote>
    <p>{"success":0,"errors":{"error":["Invalid username or password."]}}</p>
  </blockquote>
  
  <p>but when I run this</p>
  
  <pre><code>// tests
      public function invalidUserShouldBe200AndJsonTest(AcceptanceTester $I)
      {
          $I-&gt;wantTo('To see a 200 status code and a json response');
          $I-&gt;sendAjaxPostRequest('/api/v1/signin',array('email'=&gt;'user@user.com','password'=&gt;'mysentryuser'));
         // $I-&gt;seeCookie('XSRF-TOKEN');
          $I-&gt;seeResponseCodeIs('200');
         //$I-&gt;seeResponseIsJson();// until here green bar
         //dd($I-&gt;grabResponse()); // empty string
         $I-&gt;seeResponseContainsJson(array('success' =&gt; 0,'errors' =&gt; array('error' =&gt; array('Invalid username or password.'))));
  
          //$I-&gt;seeResponseContains(""); // red bar 
      }
  </code></pre>
  
  <p>I got</p>
  
  <blockquote>
    <p>I see response contains json {"success":0,"errors":{"error":["Invalid
    username or password."]}}</p>
  </blockquote>
  
  <p>so may be something wrong but WHAT !</p>