mirror of
https://git.yoomoney.ru/scm/sdk/yookassa-sdk-php.git
synced 2026-09-01 04:58:45 +00:00
105 lines
3.5 KiB
PHP
105 lines
3.5 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\Request\Receipts;
|
||
|
||
use Exception;
|
||
use stdClass;
|
||
use YooKassa\Common\Exceptions\InvalidPropertyValueException;
|
||
use YooKassa\Common\Exceptions\InvalidPropertyValueTypeException;
|
||
use YooKassa\Helpers\Random;
|
||
use YooKassa\Model\Airline;
|
||
use YooKassa\Request\Receipts\RefundReceiptResponse;
|
||
|
||
class RefundReceiptResponseTest extends AbstractReceiptResponseTestCase
|
||
{
|
||
protected $type = 'refund';
|
||
|
||
protected function getTestInstance($options)
|
||
{
|
||
return new RefundReceiptResponse($options);
|
||
}
|
||
|
||
protected function addSpecificProperties($options, $i)
|
||
{
|
||
$array = array(
|
||
Random::str(30),
|
||
new stdClass(),
|
||
array(),
|
||
new stdClass(),
|
||
new Exception(),
|
||
new Airline(),
|
||
Random::str(40),
|
||
array(new Airline())
|
||
);
|
||
$options['refund_id'] = !$this->valid
|
||
? (Random::value($array))
|
||
: Random::value(array(null, '', Random::str(RefundReceiptResponse::LENGTH_REFUND_ID)));
|
||
return $options;
|
||
}
|
||
|
||
/**
|
||
* @dataProvider validDataProvider
|
||
* @param array $options
|
||
*/
|
||
public function testSpecificProperties($options)
|
||
{
|
||
$instance = $this->getTestInstance($options);
|
||
self::assertEquals($options['refund_id'], $instance->getRefundId());
|
||
}
|
||
|
||
/**
|
||
* @dataProvider invalidDataProvider
|
||
* @param array $options
|
||
*/
|
||
public function testInvalidSpecificProperties($options)
|
||
{
|
||
$this->valid = false;
|
||
$catch = false;
|
||
try {
|
||
$instance = $this->getTestInstance($options);
|
||
$instance->setRefundId($options['refund_id']);
|
||
} catch (InvalidPropertyValueException $e) {
|
||
$catch = true;
|
||
} catch (InvalidPropertyValueTypeException $e) {
|
||
$catch = true;
|
||
}
|
||
self::assertTrue($catch);
|
||
|
||
$catch = false;
|
||
try {
|
||
$refundId = $options['refund_id'];
|
||
$options['refund_id'] = Random::str(RefundReceiptResponse::LENGTH_REFUND_ID);
|
||
$instance = $this->getTestInstance($options);
|
||
$instance->setRefundId($refundId);
|
||
} catch (InvalidPropertyValueException $e) {
|
||
$catch = true;
|
||
} catch (InvalidPropertyValueTypeException $e) {
|
||
$catch = true;
|
||
}
|
||
self::assertTrue($catch);
|
||
}
|
||
}
|