From 2ada519c100fa901af3e34ea1d1d0c77a9308ffa Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 9 Feb 2022 12:33:06 +0300 Subject: [PATCH] Add `isError` and `isPreprocessing` fields to delivery status (#140) * Add `isError` and `isPreprocessing` fields to delivery status * Add test of the status entity * Add test for integration editing Co-authored-by: Andrey Muriy --- .../Entity/Integration/Delivery/Status.php | 16 ++++++++ .../Integration/Delivery/StatusTest.php | 28 ++++++++++++++ tests/src/ResourceGroup/IntegrationTests.php | 38 +++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 tests/src/Model/Entity/Integration/Delivery/StatusTest.php diff --git a/src/Model/Entity/Integration/Delivery/Status.php b/src/Model/Entity/Integration/Delivery/Status.php index 9dc06bc..142aff0 100644 --- a/src/Model/Entity/Integration/Delivery/Status.php +++ b/src/Model/Entity/Integration/Delivery/Status.php @@ -42,4 +42,20 @@ class Status * @JMS\SerializedName("isEditable") */ public $isEditable; + + /** + * @var bool + * + * @JMS\Type("bool") + * @JMS\SerializedName("isError") + */ + public $isError; + + /** + * @var bool + * + * @JMS\Type("bool") + * @JMS\SerializedName("isPreprocessing") + */ + public $isPreprocessing; } diff --git a/tests/src/Model/Entity/Integration/Delivery/StatusTest.php b/tests/src/Model/Entity/Integration/Delivery/StatusTest.php new file mode 100644 index 0000000..7cda021 --- /dev/null +++ b/tests/src/Model/Entity/Integration/Delivery/StatusTest.php @@ -0,0 +1,28 @@ +fromArray([ + 'code' => 'statusCode', + 'name' => 'statusName', + 'isEditable' => true, + 'isError' => false, + 'isPreprocessing' => true, + ], Status::class); + + self::assertInstanceOf(Status::class, $status); + self::assertEquals('statusCode', $status->code); + self::assertEquals('statusName', $status->name); + self::assertTrue($status->isEditable); + self::assertFalse($status->isError); + self::assertTrue($status->isPreprocessing); + } +} diff --git a/tests/src/ResourceGroup/IntegrationTests.php b/tests/src/ResourceGroup/IntegrationTests.php index bbec7bc..28adc0e 100644 --- a/tests/src/ResourceGroup/IntegrationTests.php +++ b/tests/src/ResourceGroup/IntegrationTests.php @@ -13,6 +13,7 @@ use RetailCrm\Api\Enum\Currency; use RetailCrm\Api\Enum\RequestMethod; use RetailCrm\Api\Model\Entity\Integration\Delivery\DeliveryConfiguration; use RetailCrm\Api\Model\Entity\Integration\Delivery\Plate; +use RetailCrm\Api\Model\Entity\Integration\Delivery\Status; use RetailCrm\Api\Model\Entity\Integration\IntegrationModule; use RetailCrm\Api\Model\Entity\Integration\Integrations; use RetailCrm\Api\Model\Entity\Integration\Payment\Actions; @@ -206,6 +207,7 @@ EOF; $deliveryConfiguration->allowPackages = false; $deliveryConfiguration->codAvailable = false; $deliveryConfiguration->plateList = $this->createPlateList(); + $deliveryConfiguration->statusList = $this->createStatusList(); $integrations = new Integrations(); $integrations->delivery = $deliveryConfiguration; @@ -255,4 +257,40 @@ EOF; return $plateList; } + + /** + * @return Status[] + */ + private function createStatusList(): array + { + $statusList = []; + $statuses = [ + [ + 'code' => 'status_01', + 'name' => 'Status 01', + 'isEditable' => true, + 'isError' => true, + 'isPreprocessing' => true, + ], + [ + 'code' => 'status_02', + 'name' => 'Status 02', + 'isEditable' => false, + 'isError' => false, + 'isPreprocessing' => false, + ], + ]; + + foreach ($statuses as $item) { + $status = new Status(); + $status->code = $item['code']; + $status->name = $item['name']; + $status->isEditable = $item['isEditable']; + $status->isError = $item['isError']; + $status->isPreprocessing = $item['isPreprocessing']; + $statusList[] = $status; + } + + return $statusList; + } }