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'));
 }
 public function testNormalize()
 {
     $collection = new Collection();
     $collection->setId('foo');
     $request = new Request();
     $request->setId(42);
     $folder = new Folder();
     $folder->setId('bar');
     $folder->setCollection($collection);
     $folder->setName('Foo');
     $folder->setRequests([$request]);
     $normalizer = new FolderNormalizer();
     $this->assertEquals(['id' => 'bar', 'collectionId' => 'foo', 'name' => 'Foo', 'owner' => 0, 'order' => [42]], $normalizer->normalize($folder, 'json'));
 }
 /**
  * {@inheritdoc}
  *
  * @return Collection
  */
 public function generate(ResourceInterface $resource = null)
 {
     $collection = new Collection();
     $collection->setId((string) Uuid::uuid4());
     $collection->setName($this->name);
     $collection->setDescription($this->description);
     $collection->setPublic($this->public);
     foreach ($this->resourceCollection as $resource) {
         $folder = $this->folderGenerator->generate($resource);
         $folder->setRequests($this->requestGenerator->generate($resource));
         $collection->addFolder($folder);
     }
     return $collection;
 }