1
0
mirror of synced 2024-11-26 15:26:08 +03:00
bitrix-module/tests/lib/component/converter/DateTimeConverterTest.php
Сергей Чазов 34e8105583
Loyalty (#241)
* Loyalty program
* fix dot bug for shops-exoprt option
* delete credantials request from services
* add CurlException for credentials catch
* add catching CurlException
* edit error msgs
* add supportind double bonuses
* add any step for bonus-input field in sale.order.ajax template
* recalculate bonuses
* fix bonus rounded
* strtoupper for params in icml
* change delivery service code
2022-03-02 15:40:53 +03:00

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)
);
}
}