public function testNormalize()
 {
     $collection = new Collection();
     $collection->setId('foo');
     $folder = new Folder();
     $folder->setId('bar');
     $request = new Request();
     $request->setId(42);
     $request->setName('Get users list');
     $request->setCollection($collection);
     $request->setDataMode(Request::DATA_MODE_RAW);
     $request->setDescription('This request returns a users list');
     $request->setFolder($folder);
     $request->setFromCollection(true);
     $request->addHeader('Authorization', 'Bearer access-token-admin');
     $request->addTest(new Test('Successful GET request', 'responseCode.code === 200'));
     $request->setResource($this->prophesize('Dunglas\\ApiBundle\\Api\\ResourceInterface')->reveal());
     $request->setMethod('GET');
     $request->setUrl('http://127.0.0.1/users');
     $request->setTime(12345);
     $normalizer = new RequestNormalizer();
     $this->assertEquals(['id' => 42, 'url' => 'http://127.0.0.1/users', 'method' => 'GET', 'tests' => 'tests["Successful GET request"] = responseCode.code === 200;', 'folder' => 'bar', 'name' => 'Get users list', 'description' => 'This request returns a users list', 'preRequestScript' => '', 'pathVariables' => new \stdClass(), 'data' => [], 'dataMode' => 'raw', 'rawModeData' => '{}', 'version' => 2, 'currentHelper' => 'normal', 'helperAttributes' => new \stdClass(), 'time' => 12345, 'fromCollection' => true, 'collectionRequest' => null, 'collectionId' => 'foo', 'headers' => "Authorization: Bearer access-token-admin\n"], $normalizer->normalize($request, 'json'));
     $request->setRawModeData(['foo' => 'bar']);
     $this->assertEquals(['id' => 42, 'url' => 'http://127.0.0.1/users', 'method' => 'GET', 'tests' => 'tests["Successful GET request"] = responseCode.code === 200;', 'folder' => 'bar', 'name' => 'Get users list', 'description' => 'This request returns a users list', 'preRequestScript' => '', 'pathVariables' => new \stdClass(), 'data' => [], 'dataMode' => 'raw', 'rawModeData' => "{\n    \"foo\":\"bar\"\n}", 'version' => 2, 'currentHelper' => 'normal', 'helperAttributes' => new \stdClass(), 'time' => 12345, 'fromCollection' => true, 'collectionRequest' => null, 'collectionId' => 'foo', 'headers' => "Authorization: Bearer access-token-admin\n"], $normalizer->normalize($request, 'json'));
 }
 /**
  * {@inheritdoc}
  */
 public function parse(Request $request)
 {
     switch ($request->getMethod()) {
         case 'POST':
             $request->addTest(new Test('Successful POST request', 'responseCode.code === 201 || responseCode.code === 202'));
             $request->addTest(new Test('Content-Type is correct', 'postman.getResponseHeader("Content-Type") === "application/ld+json"'));
             break;
         case 'PUT':
         case 'PATCH':
         case 'GET':
             $request->addTest(new Test(sprintf('Successful %s request', $request->getMethod()), 'responseCode.code === 200'));
             $request->addTest(new Test('Content-Type is correct', 'postman.getResponseHeader("Content-Type") === "application/ld+json"'));
             break;
         case 'DELETE':
             $request->addTest(new Test('Successful DELETE request', 'responseCode.code === 204'));
             break;
     }
 }