/**
  * @expectedException Exception
  */
 function testJSONTypeMismatch()
 {
     $req = $this->genRequest(null, self::$json_body);
     $parser = RESTParser::get_parser($req);
     $res = new stdClass();
     $parser->parseInto($req, array('Foo', 'Bar'), $res);
 }
 protected function parseRequest($args)
 {
     // Make args' keys lowercase
     $args = array_combine(array_map('strtolower', array_keys($args)), array_values($args));
     // Deal with request specially, since we need it to determine the default noun in the next step
     $request = isset($args['request']) ? $args['request'] : $this->request;
     // Add defaults
     $args = array_merge(array('noun' => $request->httpMethod() == 'PATCH' ? $this->failover : null, 'defaulttype' => null, 'fields' => array('*')), $args);
     $parser = RESTParser::get_parser($request);
     if (!$parser) {
         $this->respondWithError(array('code' => 415, 'exception' => new Exception('Couldnt find parser for body')));
     }
     $noun = $parser->parseInto($request, $args['fields'], $args['noun'], $args['defaulttype']);
     return $noun;
 }