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
|
|
|
|
*/
|
|
|
|
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-10-02 12:19:50 +03:00
|
|
|
use RetailCrm\Model\Enum\AvailableSignMethods;
|
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
|
|
|
|
*/
|
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(
|
2020-10-02 12:19:50 +03:00
|
|
|
$this->getTestRequest(AvailableSignMethods::HMAC_MD5),
|
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
|
|
|
|
2020-10-06 17:39:02 +03:00
|
|
|
self::assertNotEmpty($contents);
|
|
|
|
self::assertFalse(stripos($contents, 'simplify'), $uri->getQuery());
|
|
|
|
self::assertNotFalse(stripos($contents, 'SPAIN_LOCAL_CORREOS'));
|
2020-09-29 13:10:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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-10-02 12:19:50 +03:00
|
|
|
$this->getTestRequest(AvailableSignMethods::HMAC_MD5, 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
|
|
|
}
|
|
|
|
}
|