mirror of
https://git.yoomoney.ru/scm/sdk/yookassa-sdk-php.git
synced 2026-09-03 05:57:29 +00:00
123 lines
3.6 KiB
PHP
123 lines
3.6 KiB
PHP
<?php
|
||
/*
|
||
* The MIT License
|
||
*
|
||
* Copyright (c) 2026 "YooMoney", NBСO LLC
|
||
*
|
||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||
* of this software and associated documentation files (the "Software"), to deal
|
||
* in the Software without restriction, including without limitation the rights
|
||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||
* copies of the Software, and to permit persons to whom the Software is
|
||
* furnished to do so, subject to the following conditions:
|
||
*
|
||
* The above copyright notice and this permission notice shall be included in
|
||
* all copies or substantial portions of the Software.
|
||
*
|
||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||
* THE SOFTWARE.
|
||
*/
|
||
|
||
namespace Tests\YooKassa\Model\Deal;
|
||
|
||
use PHPUnit\Framework\TestCase;
|
||
use YooKassa\Helpers\Random;
|
||
use YooKassa\Model\Deal\PayoutDealInfo;
|
||
|
||
class PayoutDealInfoTest extends TestCase
|
||
{
|
||
/**
|
||
* @dataProvider validDataProvider
|
||
* @param array $options
|
||
*/
|
||
public function testGetSetId($options)
|
||
{
|
||
$instance = new PayoutDealInfo();
|
||
|
||
self::assertNull($instance->getId());
|
||
self::assertNull($instance->id);
|
||
|
||
$instance->setId($options['id']);
|
||
self::assertEquals($options['id'], $instance->getId());
|
||
self::assertEquals($options['id'], $instance->id);
|
||
|
||
$instance = new PayoutDealInfo();
|
||
$instance->id = $options['id'];
|
||
self::assertEquals($options['id'], $instance->getId());
|
||
self::assertEquals($options['id'], $instance->id);
|
||
}
|
||
|
||
/**
|
||
* @dataProvider fromArrayDataProvider
|
||
* @param array $source
|
||
* @param PayoutDealInfo $expected
|
||
*/
|
||
public function testFromArray($source, $expected)
|
||
{
|
||
$deal = new PayoutDealInfo($source);
|
||
$dealArray = $expected->toArray();
|
||
|
||
if (!empty($source)) {
|
||
foreach ($source as $property => $value) {
|
||
self::assertEquals($value, $dealArray[$property]);
|
||
}
|
||
}
|
||
}
|
||
|
||
public function validDataProvider()
|
||
{
|
||
$result = array();
|
||
for ($i = 0; $i < 10; $i++) {
|
||
$payment = array(
|
||
'id' => Random::str(36, 50),
|
||
);
|
||
$result[] = array($payment);
|
||
}
|
||
return $result;
|
||
}
|
||
|
||
public function invalidDataProvider()
|
||
{
|
||
$result = array(
|
||
array(
|
||
array(
|
||
'id' => null,
|
||
)
|
||
),
|
||
array(
|
||
array(
|
||
'id' => '',
|
||
),
|
||
),
|
||
);
|
||
|
||
for ($i = 0; $i < 9; $i++) {
|
||
$payment = array(
|
||
'id' => Random::str($i < 5 ? mt_rand(1, 35) : mt_rand(51, 64)),
|
||
);
|
||
$result[] = array($payment);
|
||
}
|
||
return $result;
|
||
}
|
||
|
||
public function fromArrayDataProvider()
|
||
{
|
||
$customer = new PayoutDealInfo();
|
||
$customer->setId('dl-285e5ee7-0022-5000-8000-01516a44b147');
|
||
|
||
return array(
|
||
array(
|
||
array(
|
||
'id' => 'dl-285e5ee7-0022-5000-8000-01516a44b147',
|
||
),
|
||
$customer
|
||
),
|
||
);
|
||
}
|
||
}
|