function bodyMatchesJson($constraints)
{
    return Assert::logicalAnd(hasContentType('application/json'), bodyMatches(Assert::logicalAnd(Assert::isJson(), new JsonValueMatchesMany($constraints))));
}
 /**
  * @expectedException \PHPUnit_Framework_AssertionFailedError
  */
 public function testBodyMatchesCanFail()
 {
     $request = new Request('GET', '/', [], 'foobar');
     assertThat($request, bodyMatches(equalTo('barbaz')));
 }