* New module structure (refactoring) * Simple serializer and deserializer with models, new architecture * Move logic to strategies * Partial api client facade implementation (full implementation is not necessary for now) * Loyalty feature installer * Sms verification order (#167) * Make updater self-sufficient * Fix for order submit & fix for incorrect component rendering in the constructor * Fix for loyalty personal area error handling * Fix for cart component identity * Fix for softlock when customer cannot be registered in loyalty Co-authored-by: Сергей Чазов <45812598+Chazovs@users.noreply.github.com> Co-authored-by: Sergey Chazov <oitv18@gmail.com>
43 lines
1.2 KiB
PHP
Executable File
43 lines
1.2 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Tests\Intaro\RetailCrm\Component\Converter;
|
|
|
|
use Bitrix\Main\Type\DateTime;
|
|
use PHPUnit\Framework\TestCase;
|
|
use Intaro\RetailCrm\Component\Converter\DateTimeConverter;
|
|
|
|
class DateTimeConverterTest extends TestCase
|
|
{
|
|
/**
|
|
* Better rely on preconfigured format & data
|
|
*/
|
|
public const FORMAT = 'Y-m-d\TH:i:s';
|
|
|
|
/** @var string */
|
|
public const FORMAT_DATE = '1970-01-01T12:30:45';
|
|
|
|
public function testPhpToBitrix(): void
|
|
{
|
|
$dateTime = \DateTime::createFromFormat(self::FORMAT, self::FORMAT_DATE);
|
|
$bitrixDateTime = DateTimeConverter::phpToBitrix($dateTime);
|
|
|
|
self::assertEquals(
|
|
$dateTime->format(\DateTime::RFC3339),
|
|
$bitrixDateTime->format(\DateTime::RFC3339)
|
|
);
|
|
}
|
|
|
|
public function testBitrixToPhp(): void
|
|
{
|
|
$timeZone = new \DateTimeZone('+00:00');
|
|
$dateTime = \DateTime::createFromFormat(self::FORMAT, self::FORMAT_DATE, $timeZone);
|
|
$bitrixDateTime = DateTime::createFromPhp($dateTime);
|
|
$dateTime = DateTimeConverter::bitrixToPhp($bitrixDateTime);
|
|
|
|
self::assertEquals(
|
|
$bitrixDateTime->format(\DateTime::RFC3339),
|
|
$dateTime->format(\DateTime::RFC3339)
|
|
);
|
|
}
|
|
}
|