Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
fix(ShippingMethod): fix response object class of shipping method req…
Browse files Browse the repository at this point in the history
…uest by cart or location
  • Loading branch information
Jens Schulze committed Oct 26, 2016
1 parent 178596b commit 76b18bc
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Commercetools\Core\Request\ShippingMethods;

use Commercetools\Core\Response\ResourceResponse;
use Psr\Http\Message\ResponseInterface;
use Commercetools\Core\Client\HttpMethod;
use Commercetools\Core\Client\HttpRequest;
Expand Down Expand Up @@ -74,6 +75,6 @@ public function httpRequest()
*/
public function buildResponse(ResponseInterface $response)
{
return new PagedQueryResponse($response, $this, $this->getContext());
return new ResourceResponse($response, $this, $this->getContext());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Commercetools\Core\Request\ShippingMethods;

use Commercetools\Core\Response\ResourceResponse;
use Psr\Http\Message\ResponseInterface;
use Commercetools\Core\Client\HttpMethod;
use Commercetools\Core\Client\HttpRequest;
Expand Down Expand Up @@ -102,6 +103,6 @@ public function httpRequest()
*/
public function buildResponse(ResponseInterface $response)
{
return new PagedQueryResponse($response, $this, $this->getContext());
return new ResourceResponse($response, $this, $this->getContext());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Commercetools\Core\Model\ShippingMethod\ZoneRate;
use Commercetools\Core\Model\ShippingMethod\ZoneRateCollection;
use Commercetools\Core\Request\ShippingMethods\ShippingMethodByIdGetRequest;
use Commercetools\Core\Request\ShippingMethods\ShippingMethodByLocationGetRequest;
use Commercetools\Core\Request\ShippingMethods\ShippingMethodCreateRequest;
use Commercetools\Core\Request\ShippingMethods\ShippingMethodDeleteRequest;
use Commercetools\Core\Request\ShippingMethods\ShippingMethodQueryRequest;
Expand Down Expand Up @@ -81,6 +82,18 @@ public function testGetById()

$this->assertInstanceOf('\Commercetools\Core\Model\ShippingMethod\ShippingMethod', $shippingMethod);
$this->assertSame($shippingMethod->getId(), $result->getId());
}

public function testByLocation()
{
$draft = $this->getDraft();
$shippingMethod = $this->createShippingMethod($draft);

$request = ShippingMethodByLocationGetRequest::ofCountry('DE')->withState($this->getRegion());
$response = $request->executeWithClient($this->getClient());
$result = $request->mapResponse($response);

$this->assertInstanceOf('\Commercetools\Core\Model\ShippingMethod\ShippingMethodCollection', $result);
$this->assertSame($shippingMethod->getId(), $result->current()->getId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ public function testBuildResponse()
$request = ShippingMethodByCartIdGetRequest::ofCartId('id');
$response = $request->buildResponse($guzzleResponse);

$this->assertInstanceOf('\Commercetools\Core\Response\PagedQueryResponse', $response);
$this->assertInstanceOf('\Commercetools\Core\Response\ResourceResponse', $response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ public function testBuildResponse()
$request = ShippingMethodByLocationGetRequest::ofCountry('DE');
$response = $request->buildResponse($guzzleResponse);

$this->assertInstanceOf('\Commercetools\Core\Response\PagedQueryResponse', $response);
$this->assertInstanceOf('\Commercetools\Core\Response\ResourceResponse', $response);
}
}

0 comments on commit 76b18bc

Please # to comment.