1
0
mirror of synced 2025-02-16 20:23:15 +03:00

test form json dto

This commit is contained in:
Pavel 2020-09-29 13:18:18 +03:00
parent eeba164aba
commit 3caa7e7afa
4 changed files with 54 additions and 4 deletions

View File

@ -64,11 +64,12 @@ class TestCase extends \PHPUnit\Framework\TestCase
/**
* @param string $signMethod
*
* @param bool $withFile
* @param bool $withFile
* @param bool $withDto
*
* @return \RetailCrm\Test\TestSignerRequest
*/
protected function getTestRequest(string $signMethod, bool $withFile = false): TestSignerRequest
protected function getTestRequest(string $signMethod, bool $withFile = false, bool $withDto = false): TestSignerRequest
{
$request = new TestSignerRequest();
$request->method = 'aliexpress.solution.order.fulfill';
@ -90,6 +91,10 @@ class TestCase extends \PHPUnit\Framework\TestCase
);
}
if ($withDto) {
$request->dto = new TestDto();
}
return $request;
}
}

View File

@ -0,0 +1,37 @@
<?php
/**
* PHP version 7.3
*
* @category TestDto
* @package RetailCrm\Test
* @author RetailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://help.retailcrm.ru
*/
namespace RetailCrm\Test;
use JMS\Serializer\Annotation as JMS;
use RetailCrm\Interfaces\RequestDtoInterface;
/**
* Class TestDto
*
* @category TestDto
* @package RetailCrm\Test
* @author RetailDriver LLC <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see https://help.retailcrm.ru
*/
class TestDto implements RequestDtoInterface
{
/**
* @var string $modelContent
*
* @JMS\Type("string")
* @JMS\SerializedName("modelContent")
*/
public $modelContent = 'contentData';
}

View File

@ -13,7 +13,6 @@
namespace RetailCrm\Test;
use JMS\Serializer\Annotation as JMS;
use Psr\Http\Message\UploadedFileInterface;
use RetailCrm\Interfaces\FileItemInterface;
use RetailCrm\Model\Request\BaseRequest;
use Symfony\Component\Validator\Constraints as Assert;
@ -73,4 +72,12 @@ class TestSignerRequest extends BaseRequest
* @JMS\SerializedName("document")
*/
public $document;
/**
* @var \RetailCrm\Interfaces\RequestDtoInterface
*
* @JMS\Type("RequestDtoInterface")
* @JMS\SerializedName("dto")
*/
public $dto;
}

View File

@ -54,7 +54,7 @@ class RequestFactoryTest extends TestCase
$factory = $this->getContainer()->get(RequestFactory::class);
$request = $factory->fromModel(
AppData::OVERSEAS_ENDPOINT,
$this->getTestRequest(Constants::SIGN_TYPE_HMAC, true),
$this->getTestRequest(Constants::SIGN_TYPE_HMAC, true, true),
$this->getAppData(),
$this->getAuthenticator()
);
@ -63,5 +63,6 @@ class RequestFactoryTest extends TestCase
self::assertEmpty($uri->getQuery());
self::assertNotFalse(stripos($contents, 'The quick brown fox jumps over the lazy dog'));
self::assertNotFalse(stripos($contents, '{"modelContent":"contentData"}'));
}
}