/**
  * @dataProvider parametersProvider
  */
 public function testNeedsConversion($parameters, $output, $expected)
 {
     $converter = new ArticlesListParametersConverter();
     if ($expected) {
         $this->assertSame($output, $converter->convert($parameters));
     } else {
         $this->assertNotSame($output, $converter->convert($parameters));
     }
 }
Ejemplo n.º 2
0
 /**
  * @param int|string $sectionId Section id or uniqueName
  * @param string $method
  * @param array $parameters
  * @return array|bool|float|int|string
  * @throws InvalidMethodException
  * @throws InvalidMethodParametersException
  * @throws ItemDoesNotExistsException
  * @throws UnsatisfactoryResponseCodeException
  */
 public function getArticlesBySectionId($sectionId, $method, $parameters = [])
 {
     $methodValidator = new ArticleListMethodValidator($method);
     if (!$methodValidator->isValid()) {
         throw new InvalidMethodException(sprintf('Method "%s" is not allowed', $method));
     }
     $parametersConverter = new ArticlesListParametersConverter();
     $parameters = $parametersConverter->convert($parameters);
     $parametersValidator = new ArticlesListParametersValidator($method, $parameters);
     if (!$parametersValidator->isValid()) {
         throw new InvalidMethodParametersException(sprintf('Invalid parameter name or value used for "%s" method', $method));
     }
     $url = sprintf('/publication/{publicationId}/sections/%s/%s?%s', $sectionId, $method, http_build_query($parameters));
     $url = rtrim($url, '?&');
     $response = $this->apiGet($url);
     return $response->json();
 }