function it_builds_api_http_path_and_query()
 {
     $this->setLimit(10)->setOffset(100)->setHotnessFrom(50)->setHotnessTo(100)->setLifetimeFrom(10)->setLifetimeTo(30)->setSince('2016-01-01')->setUntil('2016-11-11');
     $path = sprintf(self::URL_PATTERN, self::PUBLICATION_ID, self::SECTION_NAME);
     $query = 'limit=10&offset=100&hotnessFrom=50&hotnessTo=100&lifetimeFrom=10&lifetimeTo=30&since=2016-01-01&until=2016-11-11';
     $this->buildApiHttpPathAndQuery()->shouldBeLike(ApiHttpPathAndQuery::createForPathAndQuery($path, $query));
 }
 function it_builds_api_http_path_and_query()
 {
     $this->setLimit(10)->setOffset(100);
     $path = sprintf(self::URL_PATTERN, PublicationId::SA, self::DEFAULT_DESKED_SECTION);
     $query = 'limit=10&offset=100';
     $this->buildApiHttpPathAndQuery()->shouldBeLike(ApiHttpPathAndQuery::createForPathAndQuery($path, $query));
 }
 function it_builds_api_http_path_and_query()
 {
     $timeRange = new TimeRangeParameter(new DateTime('2016-03-01'), new DateTime('2016-04-01'));
     $limit = 5;
     $this->beConstructedThrough('createForPublicationIdWithTimeRangeAndLimit', [PublicationId::AP, $timeRange, $limit]);
     $path = sprintf('changelog/%s/search', PublicationId::AP);
     $expectedApiHttpPathAndQuery = ApiHttpPathAndQuery::createForPathAndQuery($path, 'limit=5&since=2016-03-01+00%3A00%3A00&until=2016-04-01+00%3A00%3A00');
     $this->buildApiHttpPathAndQuery()->shouldBeLike($expectedApiHttpPathAndQuery);
 }
 function it_makes_http_get_request(HttpClientInterface $httpClient, RequestFactoryInterface $requestFactory, RequestInterface $request, ResponseInterface $response, StreamInterface $stream)
 {
     $expectedResponse = 'response';
     $apiHttpPathAndQuery = ApiHttpPathAndQuery::createForPathAndQuery(self::API_PATH, self::API_QUERY);
     $uri = sprintf('%s/%s', self::API_ENDPOINT, $apiHttpPathAndQuery->getPathAndQuery());
     $requestFactory->createRequest(ApiHttpClient::GET_REQUEST, $uri, $this->apiHttpClientConfiguration->buildHeaders())->shouldBeCalled()->willReturn($request);
     $httpClient->sendRequest($request)->willReturn($response);
     $response->getBody()->willReturn($stream);
     $response->getStatusCode()->willReturn(200);
     $stream->getContents()->willReturn($expectedResponse);
     $this->get($apiHttpPathAndQuery)->shouldReturn($expectedResponse);
 }
 /**
  * {@inheritdoc}
  */
 public function buildApiHttpPathAndQuery()
 {
     $path = sprintf(static::URL_PATTERN, $this->publicationId, implode(',', $this->sections));
     $query = http_build_query($this->parameters);
     return ApiHttpPathAndQuery::createForPathAndQuery($path, $query);
 }
 function it_builds_api_client_uri()
 {
     $expectedUri = sprintf('%s/%s?%s', self::API_ENDPOINT, self::API_PATH, self::API_QUERY);
     $apiHttpPathAndQuery = ApiHttpPathAndQuery::createForPathAndQuery(self::API_PATH, self::API_QUERY);
     $this->buildUri($apiHttpPathAndQuery)->shouldReturn($expectedUri);
 }
 /**
  * @codingStandardsIgnoreStart
  * @Given there is articles changelog for :publicationId publication with time range since :since until :until and :limit limit in API:
  * @codingStandardsIgnoreEnd
  *
  * @param string $publicationId
  * @param DateTime $since
  * @param DateTime $until
  * @param string $limit
  * @param PyStringNode $changelogFromApi
  */
 public function thereIsArticlesChangelogForPublicationWithTimeRangeFromToAndLimitInApi($publicationId, DateTime $since, DateTime $until, $limit, PyStringNode $changelogFromApi)
 {
     $articlesChangeFromApi = str_replace('PUBLICATION_ID', $publicationId, $changelogFromApi);
     $changelogApiResponse = json_decode($articlesChangeFromApi, true);
     $this->articleChangelogFromApi[$publicationId] = $changelogApiResponse;
     $path = sprintf(self::ARTICLES_CHANGELOG_PATH_PATTERN, $publicationId);
     $query = http_build_query(['limit' => $limit, 'since' => $since->format('Y-m-d H:i:s'), 'until' => $until->format('Y-m-d H:i:s')]);
     $this->apihttpClient->shouldReceive('get')->with(Mockery::on(function (ApiHttpPathAndQuery $apiHttpPathAndQuery) use($path, $query) {
         return $apiHttpPathAndQuery == ApiHttpPathAndQuery::createForPathAndQuery($path, $query);
     }))->andReturn($articlesChangeFromApi);
 }
 /**
  * {@inheritdoc}
  */
 public function buildApiHttpPathAndQuery()
 {
     $path = sprintf(self::ARTICLES_CHANGELOG_PATTERN, $this->publicationId);
     return ApiHttpPathAndQuery::createForPathAndQuery($path, $this->buildQuery());
 }