diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e457ab9..f42ca87 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,6 @@ composer install:php56: - apt-get update - apt-get install -y git - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" - - php -r "if (hash_file('SHA384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" - php composer-setup.php - php -r "unlink('composer-setup.php');" script: diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f810f1..5713502 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 7.0.1 +*(2019-05-24)* + +* Fixed bugs: + * Issue with updating order + ## 7.0.0 *(2018-12-04)* diff --git a/composer.json b/composer.json index 2857481..9a5a857 100644 --- a/composer.json +++ b/composer.json @@ -3,6 +3,7 @@ "license": "MIT", "description": "Share code plugin", "type": "library", + "version": "7.0.1", "authors": [ { "name": "GetResponse", diff --git a/src/Order/OrderService.php b/src/Order/OrderService.php index 9cf935a..f6ddaa2 100644 --- a/src/Order/OrderService.php +++ b/src/Order/OrderService.php @@ -107,6 +107,15 @@ public function updateOrder(EditOrderCommand $editOrderCommand) { $order = $editOrderCommand->getOrder(); + $grOrderId = $this->dbRepository->getGrOrderIdFromMapping( + $editOrderCommand->getShopId(), + $order->getExternalOrderId() + ); + + if (!$grOrderId) { + return; + } + $orderPayload = $this->orderPayloadFactory->create( $order, $this->productService->getProductsVariants( @@ -115,11 +124,6 @@ public function updateOrder(EditOrderCommand $editOrderCommand) ) ); - $grOrderId = $this->dbRepository->getGrOrderIdFromMapping( - $editOrderCommand->getShopId(), - $order->getExternalOrderId() - ); - if ($this->hasPayloadChanged($orderPayload, $editOrderCommand->getShopId(), $order->getExternalOrderId())) { return; } diff --git a/tests/Unit/Domain/Order/OrderServiceTest.php b/tests/Unit/Domain/Order/OrderServiceTest.php index b77eeba..ae36ba2 100644 --- a/tests/Unit/Domain/Order/OrderServiceTest.php +++ b/tests/Unit/Domain/Order/OrderServiceTest.php @@ -189,4 +189,25 @@ public function shouldNotUpdateOrderIfPayloadDoesntChange() $this->sut->updateOrder($editOrderCommand); } + /** + * @test + * @throws GetresponseApiException + */ + public function shouldNotUpdateOrderIfOrderIsNotMapped() + { + $editOrderCommand = Generator::createEditOrderCommand(); + + $this->dbRepositoryMock + ->expects(self::once()) + ->method('getGrOrderIdFromMapping') + ->with($editOrderCommand->getShopId(), $editOrderCommand->getOrder()->getExternalOrderId()) + ->willReturn(null); + + $this->grApiClientMock + ->expects(self::never()) + ->method('updateOrder'); + + $this->sut->updateOrder($editOrderCommand); + } + }