test form json dto
This commit is contained in:
parent
eeba164aba
commit
3caa7e7afa
@ -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;
|
||||
}
|
||||
}
|
||||
|
37
tests/RetailCrm/Test/TestDto.php
Normal file
37
tests/RetailCrm/Test/TestDto.php
Normal 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';
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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"}'));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user