2020-09-29 13:10:54 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP version 7.3
|
|
|
|
*
|
2020-09-30 13:18:35 +03:00
|
|
|
* @category TopRequestFactoryTest
|
2020-09-29 13:10:54 +03:00
|
|
|
* @package RetailCrm\Tests\Factory
|
|
|
|
* @author RetailCRM <integration@retailcrm.ru>
|
|
|
|
* @license MIT
|
|
|
|
* @link http://retailcrm.ru
|
|
|
|
* @see http://help.retailcrm.ru
|
|
|
|
*/
|
|
|
|
namespace RetailCrm\Tests\Factory;
|
|
|
|
|
|
|
|
use RetailCrm\Component\Constants;
|
2020-09-30 13:18:35 +03:00
|
|
|
use RetailCrm\Factory\TopRequestFactory;
|
|
|
|
use RetailCrm\Interfaces\TopRequestFactoryInterface;
|
2020-09-29 13:10:54 +03:00
|
|
|
use RetailCrm\Test\TestCase;
|
|
|
|
|
|
|
|
/**
|
2020-09-30 13:18:35 +03:00
|
|
|
* Class TopRequestFactoryTest
|
2020-09-29 13:10:54 +03:00
|
|
|
*
|
2020-09-30 13:18:35 +03:00
|
|
|
* @category TopRequestFactoryTest
|
2020-09-29 13:10:54 +03:00
|
|
|
* @package RetailCrm\Tests\Factory
|
|
|
|
* @author RetailDriver LLC <integration@retailcrm.ru>
|
|
|
|
* @license MIT
|
|
|
|
* @link http://retailcrm.ru
|
|
|
|
* @see https://help.retailcrm.ru
|
|
|
|
*/
|
2020-09-30 13:18:35 +03:00
|
|
|
class TopRequestFactoryTest extends TestCase
|
2020-09-29 13:10:54 +03:00
|
|
|
{
|
|
|
|
public function testFromModelGet(): void
|
|
|
|
{
|
2020-09-30 13:18:35 +03:00
|
|
|
/** @var TopRequestFactory $factory */
|
|
|
|
$factory = $this->getContainer()->get(TopRequestFactoryInterface::class);
|
2020-09-29 13:10:54 +03:00
|
|
|
$request = $factory->fromModel(
|
|
|
|
$this->getTestRequest(Constants::SIGN_TYPE_HMAC),
|
2020-09-30 17:50:44 +03:00
|
|
|
$this->getAppData()
|
2020-09-29 13:10:54 +03:00
|
|
|
);
|
|
|
|
$uri = $request->getUri();
|
2020-09-30 13:18:35 +03:00
|
|
|
$contents = self::getStreamData($request->getBody());
|
2020-09-29 13:10:54 +03:00
|
|
|
|
|
|
|
self::assertEmpty($contents);
|
|
|
|
self::assertNotEmpty($uri->getQuery());
|
|
|
|
self::assertNotFalse(stripos($uri->getQuery(), 'SPAIN_LOCAL_CORREOS'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testFromModelPost(): void
|
|
|
|
{
|
2020-09-30 13:18:35 +03:00
|
|
|
/** @var TopRequestFactory $factory */
|
|
|
|
$factory = $this->getContainer()->get(TopRequestFactoryInterface::class);
|
2020-09-29 13:10:54 +03:00
|
|
|
$request = $factory->fromModel(
|
2020-09-29 13:18:18 +03:00
|
|
|
$this->getTestRequest(Constants::SIGN_TYPE_HMAC, true, true),
|
2020-09-30 17:50:44 +03:00
|
|
|
$this->getAppData()
|
2020-09-29 13:10:54 +03:00
|
|
|
);
|
|
|
|
$uri = $request->getUri();
|
2020-09-30 13:18:35 +03:00
|
|
|
$contents = self::getStreamData($request->getBody());
|
2020-09-29 13:10:54 +03:00
|
|
|
|
|
|
|
self::assertEmpty($uri->getQuery());
|
|
|
|
self::assertNotFalse(stripos($contents, 'The quick brown fox jumps over the lazy dog'));
|
2020-09-29 13:18:18 +03:00
|
|
|
self::assertNotFalse(stripos($contents, '{"modelContent":"contentData"}'));
|
2020-09-29 13:10:54 +03:00
|
|
|
}
|
|
|
|
}
|