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

Commit 76b18bc

Browse files
author
Jens Schulze
committed
fix(ShippingMethod): fix response object class of shipping method request by cart or location
1 parent 178596b commit 76b18bc

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

src/Request/ShippingMethods/ShippingMethodByCartIdGetRequest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Commercetools\Core\Request\ShippingMethods;
77

8+
use Commercetools\Core\Response\ResourceResponse;
89
use Psr\Http\Message\ResponseInterface;
910
use Commercetools\Core\Client\HttpMethod;
1011
use Commercetools\Core\Client\HttpRequest;
@@ -74,6 +75,6 @@ public function httpRequest()
7475
*/
7576
public function buildResponse(ResponseInterface $response)
7677
{
77-
return new PagedQueryResponse($response, $this, $this->getContext());
78+
return new ResourceResponse($response, $this, $this->getContext());
7879
}
7980
}

src/Request/ShippingMethods/ShippingMethodByLocationGetRequest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Commercetools\Core\Request\ShippingMethods;
77

8+
use Commercetools\Core\Response\ResourceResponse;
89
use Psr\Http\Message\ResponseInterface;
910
use Commercetools\Core\Client\HttpMethod;
1011
use Commercetools\Core\Client\HttpRequest;
@@ -102,6 +103,6 @@ public function httpRequest()
102103
*/
103104
public function buildResponse(ResponseInterface $response)
104105
{
105-
return new PagedQueryResponse($response, $this, $this->getContext());
106+
return new ResourceResponse($response, $this, $this->getContext());
106107
}
107108
}

tests/integration/ShippingMethod/ShippingMethodQueryRequestTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Commercetools\Core\Model\ShippingMethod\ZoneRate;
1515
use Commercetools\Core\Model\ShippingMethod\ZoneRateCollection;
1616
use Commercetools\Core\Request\ShippingMethods\ShippingMethodByIdGetRequest;
17+
use Commercetools\Core\Request\ShippingMethods\ShippingMethodByLocationGetRequest;
1718
use Commercetools\Core\Request\ShippingMethods\ShippingMethodCreateRequest;
1819
use Commercetools\Core\Request\ShippingMethods\ShippingMethodDeleteRequest;
1920
use Commercetools\Core\Request\ShippingMethods\ShippingMethodQueryRequest;
@@ -81,6 +82,18 @@ public function testGetById()
8182

8283
$this->assertInstanceOf('\Commercetools\Core\Model\ShippingMethod\ShippingMethod', $shippingMethod);
8384
$this->assertSame($shippingMethod->getId(), $result->getId());
85+
}
86+
87+
public function testByLocation()
88+
{
89+
$draft = $this->getDraft();
90+
$shippingMethod = $this->createShippingMethod($draft);
91+
92+
$request = ShippingMethodByLocationGetRequest::ofCountry('DE')->withState($this->getRegion());
93+
$response = $request->executeWithClient($this->getClient());
94+
$result = $request->mapResponse($response);
8495

96+
$this->assertInstanceOf('\Commercetools\Core\Model\ShippingMethod\ShippingMethodCollection', $result);
97+
$this->assertSame($shippingMethod->getId(), $result->current()->getId());
8598
}
8699
}

tests/unit/Request/ShippingMethods/ShippingMethodByCartIdGetRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ public function testBuildResponse()
5858
$request = ShippingMethodByCartIdGetRequest::ofCartId('id');
5959
$response = $request->buildResponse($guzzleResponse);
6060

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

tests/unit/Request/ShippingMethods/ShippingMethodByLocationGetRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,6 @@ public function testBuildResponse()
8282
$request = ShippingMethodByLocationGetRequest::ofCountry('DE');
8383
$response = $request->buildResponse($guzzleResponse);
8484

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

0 commit comments

Comments
 (0)