1
0
mirror of synced 2024-11-22 05:16:07 +03:00

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 <andrey.muriy@gmail.com>
This commit is contained in:
Andrey 2022-02-09 12:33:06 +03:00 committed by GitHub
parent 7124c816b5
commit 2ada519c10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 82 additions and 0 deletions

View File

@ -42,4 +42,20 @@ class Status
* @JMS\SerializedName("isEditable") * @JMS\SerializedName("isEditable")
*/ */
public $isEditable; public $isEditable;
/**
* @var bool
*
* @JMS\Type("bool")
* @JMS\SerializedName("isError")
*/
public $isError;
/**
* @var bool
*
* @JMS\Type("bool")
* @JMS\SerializedName("isPreprocessing")
*/
public $isPreprocessing;
} }

View File

@ -0,0 +1,28 @@
<?php
namespace RetailCrm\Tests\Model\Entity\Integration\Delivery;
use PHPUnit\Framework\TestCase;
use RetailCrm\Api\Factory\SerializerFactory;
use RetailCrm\Api\Model\Entity\Integration\Delivery\Status;
class StatusTest extends TestCase
{
public function testDeserialize(): void
{
$status = SerializerFactory::create()->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);
}
}

View File

@ -13,6 +13,7 @@ use RetailCrm\Api\Enum\Currency;
use RetailCrm\Api\Enum\RequestMethod; use RetailCrm\Api\Enum\RequestMethod;
use RetailCrm\Api\Model\Entity\Integration\Delivery\DeliveryConfiguration; use RetailCrm\Api\Model\Entity\Integration\Delivery\DeliveryConfiguration;
use RetailCrm\Api\Model\Entity\Integration\Delivery\Plate; 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\IntegrationModule;
use RetailCrm\Api\Model\Entity\Integration\Integrations; use RetailCrm\Api\Model\Entity\Integration\Integrations;
use RetailCrm\Api\Model\Entity\Integration\Payment\Actions; use RetailCrm\Api\Model\Entity\Integration\Payment\Actions;
@ -206,6 +207,7 @@ EOF;
$deliveryConfiguration->allowPackages = false; $deliveryConfiguration->allowPackages = false;
$deliveryConfiguration->codAvailable = false; $deliveryConfiguration->codAvailable = false;
$deliveryConfiguration->plateList = $this->createPlateList(); $deliveryConfiguration->plateList = $this->createPlateList();
$deliveryConfiguration->statusList = $this->createStatusList();
$integrations = new Integrations(); $integrations = new Integrations();
$integrations->delivery = $deliveryConfiguration; $integrations->delivery = $deliveryConfiguration;
@ -255,4 +257,40 @@ EOF;
return $plateList; 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;
}
} }