Skip to content

Commit

Permalink
Use QueryResult::setFromCache
Browse files Browse the repository at this point in the history
  • Loading branch information
mwjames committed May 12, 2016
1 parent 86c4c53 commit 49aca92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/ByHttpRequest/QueryResultFetcher.php
Expand Up @@ -110,7 +110,7 @@ public function fetchQueryResult( Query $query ) {

$this->doResetPrintRequestsToQuerySource( $query );

$result = $this->doMakeHttpRequestFor( $query );
list( $result, $isFromCache ) = $this->doMakeHttpRequestFor( $query );

if ( $result === array() || $result === false || $result === null ) {
return $this->queryResultFactory->newEmptyQueryResult( $query );
Expand All @@ -126,13 +126,15 @@ public function fetchQueryResult( Query $query ) {
$result['query']['meta']['source'] = $query->getQuerySource();
}

$this->jsonResponseParser->doParse( $result );
$this->jsonResponseParser->doParse( $result );

$queryResult = $this->queryResultFactory->newByHttpRequestQueryResult(
$query,
$this->jsonResponseParser
);

$queryResult->setFromCache( $isFromCache );

$queryResult->setRemoteTargetUrl(
str_replace( '$1', '', $this->repositoryTargetUrl )
);
Expand Down Expand Up @@ -182,7 +184,7 @@ private function doMakeHttpRequestFor( $query ) {

$response = $httpRequest->execute();

return json_decode( $response, true );
return array( json_decode( $response, true ), $httpRequest->isFromCache() );
}

}
Expand Up @@ -29,7 +29,7 @@ protected function setUp() {
->disableOriginalConstructor()
->getMockForAbstractClass();

$this->httpRequest = $this->getMockBuilder( '\Onoi\HttpRequest\HttpRequest' )
$this->httpRequest = $this->getMockBuilder( '\Onoi\HttpRequest\CachedCurlRequest' )
->disableOriginalConstructor()
->getMock();

Expand Down

0 comments on commit 49aca92

Please sign in to comment.