2021-12-06 06:16:58 +00:00
|
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
|
|
|
|
|
*
|
|
|
|
|
* This code is licensed under MIT.
|
|
|
|
|
* Этот код распространяется по лицензии MIT.
|
|
|
|
|
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
|
|
|
|
|
*/
|
|
|
|
|
|
2021-12-06 08:14:19 +00:00
|
|
|
|
namespace AtolOnline\Tests\Collections;
|
2021-12-06 06:16:58 +00:00
|
|
|
|
|
|
|
|
|
use AtolOnline\{
|
2021-12-06 08:14:19 +00:00
|
|
|
|
Collections\Payments,
|
2021-12-06 06:16:58 +00:00
|
|
|
|
Constants\Constraints,
|
2021-12-09 12:13:43 +00:00
|
|
|
|
Exceptions\EmptyPaymentsException,
|
2021-12-07 12:04:03 +00:00
|
|
|
|
Exceptions\InvalidEntityInCollectionException,
|
2021-12-06 06:16:58 +00:00
|
|
|
|
Exceptions\InvalidEnumValueException,
|
|
|
|
|
Exceptions\NegativePaymentSumException,
|
|
|
|
|
Exceptions\TooHighPaymentSumException,
|
|
|
|
|
Exceptions\TooManyPaymentsException,
|
|
|
|
|
Tests\BasicTestCase};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Набор тестов для проверки работы класса коллекции оплат
|
|
|
|
|
*/
|
|
|
|
|
class PaymentsTest extends BasicTestCase
|
|
|
|
|
{
|
|
|
|
|
/**
|
2021-12-09 12:13:43 +00:00
|
|
|
|
* Тестирует выброс исключения при установке слишком большого количества оплат
|
2021-12-06 06:16:58 +00:00
|
|
|
|
*
|
2021-12-06 08:14:19 +00:00
|
|
|
|
* @covers \AtolOnline\Collections\EntityCollection
|
|
|
|
|
* @covers \AtolOnline\Collections\EntityCollection::checkCount
|
2021-12-06 06:16:58 +00:00
|
|
|
|
* @covers \AtolOnline\Exceptions\TooManyPaymentsException
|
|
|
|
|
* @throws InvalidEnumValueException
|
|
|
|
|
* @throws NegativePaymentSumException
|
|
|
|
|
* @throws TooHighPaymentSumException
|
2021-12-07 12:04:03 +00:00
|
|
|
|
* @throws InvalidEntityInCollectionException
|
2021-12-06 06:16:58 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testTooManyPaymentsExceptionByConstructor()
|
|
|
|
|
{
|
|
|
|
|
$this->expectException(TooManyPaymentsException::class);
|
2021-12-09 12:13:43 +00:00
|
|
|
|
(new Payments($this->generatePaymentObjects(Constraints::MAX_COUNT_DOC_PAYMENTS + 1)))->jsonSerialize();
|
2021-12-06 06:16:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-12-09 12:13:43 +00:00
|
|
|
|
* Тестирует выброс исключения при установке нулевого количества оплат
|
2021-12-06 06:16:58 +00:00
|
|
|
|
*
|
2021-12-06 08:14:19 +00:00
|
|
|
|
* @covers \AtolOnline\Collections\EntityCollection
|
|
|
|
|
* @covers \AtolOnline\Collections\EntityCollection::checkCount
|
2021-12-09 12:13:43 +00:00
|
|
|
|
* @covers \AtolOnline\Collections\EntityCollection::jsonSerialize
|
|
|
|
|
* @covers \AtolOnline\Exceptions\EmptyPaymentsException
|
2021-12-07 12:04:03 +00:00
|
|
|
|
* @throws InvalidEntityInCollectionException
|
2021-12-06 06:16:58 +00:00
|
|
|
|
*/
|
2021-12-09 12:13:43 +00:00
|
|
|
|
public function testEmptyPaymentsException()
|
2021-12-06 06:16:58 +00:00
|
|
|
|
{
|
2021-12-09 12:13:43 +00:00
|
|
|
|
$this->expectException(EmptyPaymentsException::class);
|
|
|
|
|
(new Payments([]))->jsonSerialize();
|
2021-12-06 06:16:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|