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:
parent
7124c816b5
commit
2ada519c10
@ -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;
|
||||
}
|
||||
|
28
tests/src/Model/Entity/Integration/Delivery/StatusTest.php
Normal file
28
tests/src/Model/Entity/Integration/Delivery/StatusTest.php
Normal 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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user