/**
  * Adds given request handler to collection
  *
  * @param RequestHandlerInterface $requestHandler
  */
 public function add(RequestHandlerInterface $requestHandler)
 {
     if ($this->has($requestHandler->getResourceType())) {
         throw new NonUniqueRequestHandlerException($requestHandler->getResourceType());
     }
     $this->items[$requestHandler->getResourceType()] = $requestHandler;
 }
Ejemplo n.º 2
0
 protected function runRequestHandlerGetTest(RequestHandlerInterface $requestHandler)
 {
     $result = $requestHandler->getManager()->getRepository()->findOneBy([]);
     if (null !== $result) {
         $data = $requestHandler->getSerializer()->serialize($result, 'json', ['group' => $requestHandler->getResourceType()]);
         $url = $this->generateUrl('api.resource.get', ['resourceType' => $requestHandler->getResourceType(), 'identifier' => $result->getId(), 'apiKey' => $this->apiKey]);
         $this->client->request('GET', $url);
         $this->assertTrue($this->client->getResponse()->isSuccessful());
         $this->assertEquals($data, $this->client->getResponse()->getContent(), sprintf('Wrong "get" response received for %s', $requestHandler->getResourceType()));
     }
 }