mirror of
https://git.yoomoney.ru/scm/sdk/yookassa-sdk-php.git
synced 2026-08-29 19:48:43 +00:00
cbcdbc8ae1
Отказ от поддержки PHP < 8 Изменена структура файлов Переработана логика работы с моделями Добавлено использование валидатора данных в моделях Массивы объектов заменены на объекты-коллекции
73 lines
2.1 KiB
PHP
73 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\YooKassa\Request\SelfEmployed;
|
|
|
|
use Exception;
|
|
use PHPUnit\Framework\TestCase;
|
|
use YooKassa\Helpers\Random;
|
|
use YooKassa\Model\SelfEmployed\SelfEmployedConfirmationType;
|
|
use YooKassa\Request\SelfEmployed\SelfEmployedRequest;
|
|
use YooKassa\Request\SelfEmployed\SelfEmployedRequestSerializer;
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
class SelfEmployedRequestSerializerTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider validDataProvider
|
|
*
|
|
* @param mixed $options
|
|
*/
|
|
public function testSerialize($options): void
|
|
{
|
|
$serializer = new SelfEmployedRequestSerializer();
|
|
$instance = SelfEmployedRequest::builder()->build($options);
|
|
$data = $serializer->serialize($instance);
|
|
|
|
$expected = [
|
|
'itn' => $options['itn'],
|
|
'phone' => $options['phone'],
|
|
];
|
|
|
|
if (!empty($options['confirmation'])) {
|
|
$expected['confirmation'] = $options['confirmation'];
|
|
}
|
|
|
|
self::assertEquals($expected, $data);
|
|
}
|
|
|
|
/**
|
|
* @throws Exception
|
|
*/
|
|
public static function validDataProvider(): array
|
|
{
|
|
$result = [
|
|
[
|
|
[
|
|
'itn' => Random::str(12, '0123456789'),
|
|
'phone' => Random::str(4, 15, '0123456789'),
|
|
'confirmation' => ['type' => Random::value(SelfEmployedConfirmationType::getEnabledValues())],
|
|
],
|
|
],
|
|
[
|
|
[
|
|
'itn' => Random::str(12, '0123456789'),
|
|
'phone' => Random::str(4, 15, '0123456789'),
|
|
'confirmation' => ['type' => Random::value(SelfEmployedConfirmationType::getEnabledValues())],
|
|
],
|
|
],
|
|
];
|
|
for ($i = 0; $i < 10; $i++) {
|
|
$request = [
|
|
'itn' => Random::str(12, '0123456789'),
|
|
'phone' => Random::str(4, 15, '0123456789'),
|
|
'confirmation' => ['type' => Random::value(SelfEmployedConfirmationType::getEnabledValues())],
|
|
];
|
|
$result[] = [$request];
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
}
|