Files
Антон Н. Николаев 2db9951ff6 Валидация payment_order.recipient.bank.name и payment_order.payment_period.year. Выплаты самозанятым теперь deprecated
Информация про чеки самозанятых в платежах и возвратах удалена - больше не поддерживаем сервисы для самозанятых
Добавлена возможность выставления счета по смс и email
Добавлена поддержка работы со списками выплат
Обновлен Copyright
2026-02-05 15:36:37 +03:00

296 lines
9.5 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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\Payout;
use Exception;
use Tests\YooKassa\AbstractTestCase;
use Datetime;
use YooKassa\Model\Metadata;
use YooKassa\Model\Payout\IncomeReceipt;
/**
* IncomeReceiptTest
*
* @category ClassTest
* @author cms@yoomoney.ru
* @link https://yookassa.ru/developers/api
*/
class IncomeReceiptTest extends AbstractTestCase
{
protected IncomeReceipt $object;
/**
* @return IncomeReceipt
*/
protected function getTestInstance(): IncomeReceipt
{
return new IncomeReceipt();
}
/**
* @return void
*/
public function testIncomeReceiptClassExists(): void
{
$this->object = $this->getMockBuilder(IncomeReceipt::class)->getMockForAbstractClass();
$this->assertTrue(class_exists(IncomeReceipt::class));
$this->assertInstanceOf(IncomeReceipt::class, $this->object);
}
/**
* Test property "service_name"
* @dataProvider validServiceNameDataProvider
* @param mixed $value
*
* @return void
* @throws Exception
*/
public function testServiceName(mixed $value): void
{
$instance = $this->getTestInstance();
$instance->setServiceName($value);
self::assertNotNull($instance->getServiceName());
self::assertNotNull($instance->service_name);
self::assertEquals($value, is_array($value) ? $instance->getServiceName()->toArray() : $instance->getServiceName());
self::assertEquals($value, is_array($value) ? $instance->service_name->toArray() : $instance->service_name);
self::assertLessThanOrEqual(50, is_string($instance->getServiceName()) ? mb_strlen($instance->getServiceName()) : $instance->getServiceName());
self::assertLessThanOrEqual(50, is_string($instance->service_name) ? mb_strlen($instance->service_name) : $instance->service_name);
self::assertGreaterThanOrEqual(1, is_string($instance->getServiceName()) ? mb_strlen($instance->getServiceName()) : $instance->getServiceName());
self::assertGreaterThanOrEqual(1, is_string($instance->service_name) ? mb_strlen($instance->service_name) : $instance->service_name);
}
/**
* Test invalid property "service_name"
* @dataProvider invalidServiceNameDataProvider
* @param mixed $value
* @param string $exceptionClass
*
* @return void
*/
public function testInvalidServiceName(mixed $value, string $exceptionClass): void
{
$instance = $this->getTestInstance();
$this->expectException($exceptionClass);
$instance->setServiceName($value);
}
/**
* @return array[]
* @throws Exception
*/
public function validServiceNameDataProvider(): array
{
$instance = $this->getTestInstance();
return $this->getValidDataProviderByType($instance->getValidator()->getRulesByPropName('_service_name'));
}
/**
* @return array[]
* @throws Exception
*/
public function invalidServiceNameDataProvider(): array
{
$instance = $this->getTestInstance();
return $this->getInvalidDataProviderByType($instance->getValidator()->getRulesByPropName('_service_name'));
}
/**
* Test property "npd_receipt_id"
* @dataProvider validNpdReceiptIdDataProvider
* @param mixed $value
*
* @return void
* @throws Exception
*/
public function testNpdReceiptId(mixed $value): void
{
$instance = $this->getTestInstance();
self::assertEmpty($instance->getNpdReceiptId());
self::assertEmpty($instance->npd_receipt_id);
$instance->setNpdReceiptId($value);
self::assertEquals($value, is_array($value) ? $instance->getNpdReceiptId()->toArray() : $instance->getNpdReceiptId());
self::assertEquals($value, is_array($value) ? $instance->npd_receipt_id->toArray() : $instance->npd_receipt_id);
if (!empty($value)) {
self::assertNotNull($instance->getNpdReceiptId());
self::assertNotNull($instance->npd_receipt_id);
}
}
/**
* Test invalid property "npd_receipt_id"
* @dataProvider invalidNpdReceiptIdDataProvider
* @param mixed $value
* @param string $exceptionClass
*
* @return void
*/
public function testInvalidNpdReceiptId(mixed $value, string $exceptionClass): void
{
$instance = $this->getTestInstance();
$this->expectException($exceptionClass);
$instance->setNpdReceiptId($value);
}
/**
* @return array[]
* @throws Exception
*/
public function validNpdReceiptIdDataProvider(): array
{
$instance = $this->getTestInstance();
return $this->getValidDataProviderByType($instance->getValidator()->getRulesByPropName('_npd_receipt_id'));
}
/**
* @return array[]
* @throws Exception
*/
public function invalidNpdReceiptIdDataProvider(): array
{
$instance = $this->getTestInstance();
return $this->getInvalidDataProviderByType($instance->getValidator()->getRulesByPropName('_npd_receipt_id'));
}
/**
* Test property "url"
* @dataProvider validUrlDataProvider
* @param mixed $value
*
* @return void
* @throws Exception
*/
public function testUrl(mixed $value): void
{
$instance = $this->getTestInstance();
self::assertEmpty($instance->getUrl());
self::assertEmpty($instance->url);
$instance->setUrl($value);
self::assertEquals($value, is_array($value) ? $instance->getUrl()->toArray() : $instance->getUrl());
self::assertEquals($value, is_array($value) ? $instance->url->toArray() : $instance->url);
if (!empty($value)) {
self::assertNotNull($instance->getUrl());
self::assertNotNull($instance->url);
}
}
/**
* Test invalid property "url"
* @dataProvider invalidUrlDataProvider
* @param mixed $value
* @param string $exceptionClass
*
* @return void
*/
public function testInvalidUrl(mixed $value, string $exceptionClass): void
{
$instance = $this->getTestInstance();
$this->expectException($exceptionClass);
$instance->setUrl($value);
}
/**
* @return array[]
* @throws Exception
*/
public function validUrlDataProvider(): array
{
$instance = $this->getTestInstance();
return $this->getValidDataProviderByType($instance->getValidator()->getRulesByPropName('_url'));
}
/**
* @return array[]
* @throws Exception
*/
public function invalidUrlDataProvider(): array
{
$instance = $this->getTestInstance();
return $this->getInvalidDataProviderByType($instance->getValidator()->getRulesByPropName('_url'));
}
/**
* Test property "amount"
* @dataProvider validAmountDataProvider
* @param mixed $value
*
* @return void
* @throws Exception
*/
public function testAmount(mixed $value): void
{
$instance = $this->getTestInstance();
self::assertEmpty($instance->getAmount());
self::assertEmpty($instance->amount);
$instance->setAmount($value);
self::assertEquals($value, is_array($value) ? $instance->getAmount()->toArray() : $instance->getAmount());
self::assertEquals($value, is_array($value) ? $instance->amount->toArray() : $instance->amount);
if (!empty($value)) {
self::assertNotNull($instance->getAmount());
self::assertNotNull($instance->amount);
}
}
/**
* Test invalid property "amount"
* @dataProvider invalidAmountDataProvider
* @param mixed $value
* @param string $exceptionClass
*
* @return void
*/
public function testInvalidAmount(mixed $value, string $exceptionClass): void
{
$instance = $this->getTestInstance();
$this->expectException($exceptionClass);
$instance->setAmount($value);
}
/**
* @return array[]
* @throws Exception
*/
public function validAmountDataProvider(): array
{
$instance = $this->getTestInstance();
return $this->getValidDataProviderByType($instance->getValidator()->getRulesByPropName('_amount'));
}
/**
* @return array[]
* @throws Exception
*/
public function invalidAmountDataProvider(): array
{
$instance = $this->getTestInstance();
return $this->getInvalidDataProviderByType($instance->getValidator()->getRulesByPropName('_amount'));
}
}