Доработка коллекций и не только

- коллекция `Items` с покрытием
- вынос коллекций из `AtolOnline\Entities` в `AtolOnline\Collections`
- фикс ] в `AtolException`
- финализирован `CorrectionInfo`
- фиксы по тестам коллекций
- прочие мелочи по phpdoc
pull/15/head
Anthony Axenov 2021-12-06 16:14:19 +08:00
parent bf09641c8b
commit 557c76fefa
25 changed files with 441 additions and 120 deletions

View File

@ -9,16 +9,14 @@
declare(strict_types = 1); declare(strict_types = 1);
namespace AtolOnline\Entities; namespace AtolOnline\Collections;
use Illuminate\Contracts\Support\Arrayable; use AtolOnline\Exceptions\InvalidEntityInCollectionException;
use Illuminate\Contracts\Support\Jsonable; use Exception;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** /**
* Абстрактное описание коллекции любых сущностей * Абстрактное описание коллекции любых сущностей
*
* @todo вот бы ещё проверять классы добавляемых объектов через static.... ммм мякотка
*/ */
abstract class EntityCollection extends Collection abstract class EntityCollection extends Collection
{ {
@ -69,21 +67,14 @@ abstract class EntityCollection extends Collection
/** /**
* @inheritDoc * @inheritDoc
* @throws \Exception * @throws Exception
*/ */
public function jsonSerialize(): array public function jsonSerialize(): array
{ {
return array_map(function ($value) { $this->each(function ($item) {
$this->checkEntityClass($value); $this->checkClass($item);
if ($value instanceof \JsonSerializable) { });
return $value->jsonSerialize(); return parent::jsonSerialize();
} elseif ($value instanceof Jsonable) {
return json_decode($value->toJson(), true);
} elseif ($value instanceof Arrayable) {
return $value->toArray();
}
return $value;
}, $this->all());
} }
/** /**
@ -94,26 +85,20 @@ abstract class EntityCollection extends Collection
*/ */
private function checkCount(array $items = []): void private function checkCount(array $items = []): void
{ {
if ( if (count($items) > static::MAX_COUNT || $this->count() === static::MAX_COUNT) {
count($items) > static::MAX_COUNT || throw new (static::EXCEPTION_CLASS)(static::MAX_COUNT);
$this->count() === static::MAX_COUNT
) {
$exception = static::EXCEPTION_CLASS;
throw new $exception(static::MAX_COUNT);
} }
} }
/** /**
* @throws \Exception * Проверяет корректность класса объекта
*
* @throws InvalidEntityInCollectionException
*/ */
private function checkEntityClass(mixed $item): void private function checkClass(mixed $item): void
{ {
if (!is_object($item) || $item::class !== static::ENTITY_CLASS) { if (!is_object($item) || $item::class !== static::ENTITY_CLASS) {
//TODO proper exception throw new InvalidEntityInCollectionException(static::class, static::ENTITY_CLASS, $item);
throw new \Exception(
'Коллекция должна содержать только объекты класса ' .
static::ENTITY_CLASS . ', найден ' . $item::class
);
} }
} }
} }

View File

@ -0,0 +1,35 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
* This code is licensed under MIT.
* Этот код распространяется по лицензии MIT.
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
*/
namespace AtolOnline\Collections;
use AtolOnline\Constants\Constraints;
use AtolOnline\Entities\Item;
use AtolOnline\Exceptions\TooManyItemsException;
/**
* Класс, описывающий коллекцию предметов расчёта для документа
*/
final class Items extends EntityCollection
{
/**
* Класс объектов, находящихся в коллекции
*/
protected const ENTITY_CLASS = Item::class;
/**
* Максмальное количество объектов в коллекции
*/
protected const MAX_COUNT = Constraints::MAX_COUNT_DOC_ITEMS;
/**
* Класс-наследник TooManyException для выброса при превышении количества
*/
protected const EXCEPTION_CLASS = TooManyItemsException::class;
}

View File

@ -7,9 +7,10 @@
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE * https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
*/ */
namespace AtolOnline\Entities; namespace AtolOnline\Collections;
use AtolOnline\Constants\Constraints; use AtolOnline\Constants\Constraints;
use AtolOnline\Entities\Payment;
use AtolOnline\Exceptions\TooManyPaymentsException; use AtolOnline\Exceptions\TooManyPaymentsException;
/** /**

View File

@ -7,9 +7,10 @@
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE * https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
*/ */
namespace AtolOnline\Entities; namespace AtolOnline\Collections;
use AtolOnline\Constants\Constraints; use AtolOnline\Constants\Constraints;
use AtolOnline\Entities\Vat;
use AtolOnline\Exceptions\TooManyVatsException; use AtolOnline\Exceptions\TooManyVatsException;
/** /**
@ -18,7 +19,12 @@ use AtolOnline\Exceptions\TooManyVatsException;
final class Vats extends EntityCollection final class Vats extends EntityCollection
{ {
/** /**
* Максмальное количество ставок НДС * Класс объектов, находящихся в коллекции
*/
protected const ENTITY_CLASS = Vat::class;
/**
* Максмальное количество объектов в коллекции
*/ */
protected const MAX_COUNT = Constraints::MAX_COUNT_DOC_VATS; protected const MAX_COUNT = Constraints::MAX_COUNT_DOC_VATS;

View File

@ -15,16 +15,14 @@ use AtolOnline\{
Constants\Constraints, Constants\Constraints,
Enums\SnoTypes, Enums\SnoTypes,
Traits\HasEmail, Traits\HasEmail,
Traits\HasInn Traits\HasInn};
};
use AtolOnline\Exceptions\{ use AtolOnline\Exceptions\{
InvalidEmailException, InvalidEmailException,
InvalidEnumValueException, InvalidEnumValueException,
InvalidInnLengthException, InvalidInnLengthException,
InvalidPaymentAddressException, InvalidPaymentAddressException,
TooLongEmailException, TooLongEmailException,
TooLongPaymentAddressException TooLongPaymentAddressException};
};
use JetBrains\PhpStorm\ArrayShape; use JetBrains\PhpStorm\ArrayShape;
/** /**
@ -131,10 +129,10 @@ final class Company extends Entity
* @throws InvalidPaymentAddressException * @throws InvalidPaymentAddressException
*/ */
#[ArrayShape([ #[ArrayShape([
'email' => "string", 'email' => 'string',
'sno' => "string", 'sno' => 'string',
'inn' => "string", 'inn' => 'string',
'payment_address' => "string", 'payment_address' => 'string',
])] ])]
public function jsonSerialize(): array public function jsonSerialize(): array
{ {

View File

@ -16,21 +16,19 @@ use AtolOnline\Enums\CorrectionTypes;
use AtolOnline\Exceptions\{ use AtolOnline\Exceptions\{
EmptyCorrectionNumberException, EmptyCorrectionNumberException,
InvalidCorrectionDateException, InvalidCorrectionDateException,
InvalidEnumValueException InvalidEnumValueException};
};
use DateTime; use DateTime;
use Exception; use Exception;
use JetBrains\PhpStorm\{ use JetBrains\PhpStorm\{
ArrayShape, ArrayShape,
Pure Pure};
};
/** /**
* Класс, описывающий данные коррекции * Класс, описывающий данные коррекции
* *
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 35 * @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 35
*/ */
class CorrectionInfo extends Entity final class CorrectionInfo extends Entity
{ {
/** /**
* @var string|null Тип коррекции (1173) * @var string|null Тип коррекции (1173)

View File

@ -13,11 +13,13 @@ namespace AtolOnline\Entities;
use AtolOnline\Constants\Constraints; use AtolOnline\Constants\Constraints;
use AtolOnline\Enums\PaymentTypes; use AtolOnline\Enums\PaymentTypes;
use AtolOnline\Exceptions\InvalidEnumValueException; use AtolOnline\Exceptions\{
use AtolOnline\Exceptions\NegativePaymentSumException; InvalidEnumValueException,
use AtolOnline\Exceptions\TooHighPaymentSumException; NegativePaymentSumException,
use JetBrains\PhpStorm\ArrayShape; TooHighPaymentSumException,};
use JetBrains\PhpStorm\Pure; use JetBrains\PhpStorm\{
ArrayShape,
Pure};
/** /**
* Класс, описывающий оплату * Класс, описывающий оплату
@ -41,9 +43,9 @@ class Payment extends Entity
* *
* @param int $type Тип оплаты * @param int $type Тип оплаты
* @param float $sum Сумма оплаты * @param float $sum Сумма оплаты
* @throws InvalidEnumValueException
* @throws NegativePaymentSumException * @throws NegativePaymentSumException
* @throws TooHighPaymentSumException * @throws TooHighPaymentSumException
* @throws InvalidEnumValueException
*/ */
public function __construct(int $type, float $sum) public function __construct(int $type, float $sum)
{ {

View File

@ -33,7 +33,7 @@ class AtolException extends Exception
{ {
$tags = implode(', ', $ffd_tags ?: $this->ffd_tags); $tags = implode(', ', $ffd_tags ?: $this->ffd_tags);
parent::__construct( parent::__construct(
($message ?: $this->message) . ($tags ? ' [Теги ФФД: ' . $tags : '') . ']' ($message ?: $this->message) . ($tags ? ' [Теги ФФД: ' . $tags . ']' : '')
); );
} }
} }

View File

@ -0,0 +1,37 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
* This code is licensed under MIT.
* Этот код распространяется по лицензии MIT.
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
*/
declare(strict_types = 1);
namespace AtolOnline\Exceptions;
/**
* Исключение, возникающее при наличии некорректных объектов в коллекции
*/
class InvalidEntityInCollectionException extends AtolException
{
/**
* Конструктор
*
* @param string $collection_class
* @param string $expected_class
* @param mixed $actual
*/
public function __construct(string $collection_class, string $expected_class, mixed $actual)
{
if (is_object($actual)) {
$actual = $actual::class;
} elseif (is_scalar($actual)) {
$actual = '(' . gettype($actual) . ')' . var_export($actual, true);
}
parent::__construct(
"Коллекция $collection_class должна содержать объекты $expected_class, найден $actual"
);
}
}

View File

@ -23,6 +23,7 @@ use AtolOnline\Exceptions\TooLongPasswordException;
use AtolOnline\Helpers; use AtolOnline\Helpers;
use AtolOnline\TestEnvParams; use AtolOnline\TestEnvParams;
use AtolOnline\Tests\BasicTestCase; use AtolOnline\Tests\BasicTestCase;
use Exception;
use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Exception\GuzzleException;
/** /**
@ -327,6 +328,7 @@ class KktMonitorTest extends BasicTestCase
* @throws TooLongPasswordException * @throws TooLongPasswordException
* @throws EmptyMonitorDataException * @throws EmptyMonitorDataException
* @throws NotEnoughMonitorDataException * @throws NotEnoughMonitorDataException
* @throws Exception
*/ */
public function testMonitorGetOne(): void public function testMonitorGetOne(): void
{ {

View File

@ -11,8 +11,10 @@ declare(strict_types = 1);
namespace AtolOnline\Tests; namespace AtolOnline\Tests;
use AtolOnline\Collections\EntityCollection;
use AtolOnline\Entities\Entity; use AtolOnline\Entities\Entity;
use AtolOnline\Helpers; use AtolOnline\Helpers;
use Exception;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@ -66,12 +68,14 @@ class BasicTestCase extends TestCase
/** /**
* Тестирует является ли объект приводимым к json-строке согласно схеме АТОЛ Онлайн * Тестирует является ли объект приводимым к json-строке согласно схеме АТОЛ Онлайн
* *
* @param Entity $entity * @param Entity|EntityCollection $entity
* @param array|null $json_structure * @param array|null $json_structure
* @covers \AtolOnline\Entities\Entity::jsonSerialize
* @covers \AtolOnline\Entities\Entity::__toString * @covers \AtolOnline\Entities\Entity::__toString
* @covers \AtolOnline\Entities\Entity::jsonSerialize
* @covers \AtolOnline\Collections\EntityCollection::jsonSerialize
* @throws Exception
*/ */
public function assertAtolable(Entity $entity, ?array $json_structure = null): void public function assertAtolable(Entity|EntityCollection $entity, ?array $json_structure = null): void
{ {
$this->assertIsArray($entity->jsonSerialize()); $this->assertIsArray($entity->jsonSerialize());
$this->assertIsString((string)$entity); $this->assertIsString((string)$entity);
@ -204,7 +208,7 @@ class BasicTestCase extends TestCase
/** /**
* Провайдер строк, которые приводятся к null * Провайдер строк, которые приводятся к null
* *
* @return array<array<string|null>> * @return array
*/ */
public function providerNullableStrings(): array public function providerNullableStrings(): array
{ {

View File

@ -0,0 +1,156 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
* This code is licensed under MIT.
* Этот код распространяется по лицензии MIT.
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
*/
namespace AtolOnline\Tests\Collections;
use AtolOnline\{
Collections\Items,
Constants\Constraints,
Entities\Item,
Helpers,
Tests\BasicTestCase};
use AtolOnline\Exceptions\{
EmptyItemNameException,
NegativeItemPriceException,
NegativeItemQuantityException,
TooHighItemPriceException,
TooLongItemNameException,
TooManyException,
TooManyItemsException,};
use Exception;
/**
* Набор тестов для проверки работы класса коллекции предметов расчёта
*/
class ItemsTest extends BasicTestCase
{
/**
* Тестирует выброс исключения при установке слишком большого количества оплат через конструктор
*
* @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Collections\EntityCollection::checkCount
* @covers \AtolOnline\Exceptions\TooManyItemsException
* @throws EmptyItemNameException
* @throws NegativeItemPriceException
* @throws NegativeItemQuantityException
* @throws TooHighItemPriceException
* @throws TooLongItemNameException
* @throws TooManyException
*/
public function testTooManyItemsExceptionByConstructor()
{
$this->expectException(TooManyItemsException::class);
new Items($this->generateObjects(Constraints::MAX_COUNT_DOC_ITEMS + 1));
}
/**
* Тестирует выброс исключения при добавлении лишней ставки в начало коллекции
*
* @covers \AtolOnline\Collections\EntityCollection::prepend
* @covers \AtolOnline\Collections\EntityCollection::checkCount
* @covers \AtolOnline\Exceptions\TooManyItemsException
* @throws EmptyItemNameException
* @throws NegativeItemPriceException
* @throws NegativeItemQuantityException
* @throws TooHighItemPriceException
* @throws TooLongItemNameException
* @throws TooManyException
*/
public function testTooManyItemsExceptionByPrepend()
{
$this->expectException(TooManyItemsException::class);
(new Items($this->generateObjects(Constraints::MAX_COUNT_DOC_ITEMS)))
->prepend($this->generateObjects());
}
/**
* Тестирует выброс исключения при добавлении лишней ставки в конец коллекции
*
* @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Collections\EntityCollection::add
* @covers \AtolOnline\Collections\EntityCollection::checkCount
* @covers \AtolOnline\Exceptions\TooManyItemsException
* @throws EmptyItemNameException
* @throws NegativeItemPriceException
* @throws NegativeItemQuantityException
* @throws TooHighItemPriceException
* @throws TooLongItemNameException
* @throws TooManyException
*/
public function testTooManyItemsExceptionByAdd()
{
$this->expectException(TooManyItemsException::class);
(new Items($this->generateObjects(Constraints::MAX_COUNT_DOC_ITEMS)))
->add($this->generateObjects());
}
/**
* Тестирует выброс исключения при добавлении лишних оплат в конец коллекции
*
* @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Collections\EntityCollection::push
* @covers \AtolOnline\Collections\EntityCollection::checkCount
* @covers \AtolOnline\Exceptions\TooManyItemsException
* @throws EmptyItemNameException
* @throws NegativeItemPriceException
* @throws NegativeItemQuantityException
* @throws TooHighItemPriceException
* @throws TooLongItemNameException
* @throws TooManyException
*/
public function testTooManyItemsExceptionByPush()
{
$this->expectException(TooManyItemsException::class);
(new Items($this->generateObjects(Constraints::MAX_COUNT_DOC_ITEMS)))
->push(...$this->generateObjects());
}
/**
* Тестирует выброс исключения при добавлении лишней ставки в начало коллекции
*
* @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Collections\EntityCollection::merge
* @covers \AtolOnline\Collections\EntityCollection::checkCount
* @covers \AtolOnline\Exceptions\TooManyItemsException
* @throws EmptyItemNameException
* @throws NegativeItemPriceException
* @throws NegativeItemQuantityException
* @throws TooHighItemPriceException
* @throws TooLongItemNameException
* @throws TooManyException
*/
public function testTooManyItemsExceptionByMerge()
{
$this->expectException(TooManyItemsException::class);
(new Items($this->generateObjects(Constraints::MAX_COUNT_DOC_ITEMS)))
->merge($this->generateObjects(2));
}
/**
* Генерирует массив тестовых объектов предметов расчёта
*
* @param int $count
* @return Item[]
* @throws EmptyItemNameException
* @throws NegativeItemPriceException
* @throws NegativeItemQuantityException
* @throws TooHighItemPriceException
* @throws TooLongItemNameException
* @throws TooManyException
* @throws Exception
*/
protected function generateObjects(int $count = 1): array
{
$result = [];
for ($i = 0; $i < abs($count); ++$i) {
$result[] = new Item(Helpers::randomStr(), random_int(1, 100), random_int(1, 10));
}
return $result;
}
}

View File

@ -7,12 +7,12 @@
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE * https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
*/ */
namespace AtolOnline\Tests\Entities; namespace AtolOnline\Tests\Collections;
use AtolOnline\{ use AtolOnline\{
Collections\Payments,
Constants\Constraints, Constants\Constraints,
Entities\Payment, Entities\Payment,
Entities\Payments,
Enums\PaymentTypes, Enums\PaymentTypes,
Exceptions\InvalidEnumValueException, Exceptions\InvalidEnumValueException,
Exceptions\NegativePaymentSumException, Exceptions\NegativePaymentSumException,
@ -29,8 +29,8 @@ class PaymentsTest extends BasicTestCase
/** /**
* Тестирует выброс исключения при установке слишком большого количества оплат через конструктор * Тестирует выброс исключения при установке слишком большого количества оплат через конструктор
* *
* @covers \AtolOnline\Entities\EntityCollection * @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Entities\EntityCollection::checkCount * @covers \AtolOnline\Collections\EntityCollection::checkCount
* @covers \AtolOnline\Exceptions\TooManyPaymentsException * @covers \AtolOnline\Exceptions\TooManyPaymentsException
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
* @throws NegativePaymentSumException * @throws NegativePaymentSumException
@ -45,8 +45,8 @@ class PaymentsTest extends BasicTestCase
/** /**
* Тестирует выброс исключения при добавлении лишней ставки в начало коллекции * Тестирует выброс исключения при добавлении лишней ставки в начало коллекции
* *
* @covers \AtolOnline\Entities\EntityCollection::prepend * @covers \AtolOnline\Collections\EntityCollection::prepend
* @covers \AtolOnline\Entities\EntityCollection::checkCount * @covers \AtolOnline\Collections\EntityCollection::checkCount
* @covers \AtolOnline\Exceptions\TooManyPaymentsException * @covers \AtolOnline\Exceptions\TooManyPaymentsException
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
* @throws NegativePaymentSumException * @throws NegativePaymentSumException
@ -55,16 +55,16 @@ class PaymentsTest extends BasicTestCase
public function testTooManyPaymentsExceptionByPrepend() public function testTooManyPaymentsExceptionByPrepend()
{ {
$this->expectException(TooManyPaymentsException::class); $this->expectException(TooManyPaymentsException::class);
(new Payments($this->generateObjects(10))) (new Payments($this->generateObjects(Constraints::MAX_COUNT_DOC_PAYMENTS)))
->prepend($this->generateObjects()); ->prepend($this->generateObjects());
} }
/** /**
* Тестирует выброс исключения при добавлении лишней ставки в конец коллекции * Тестирует выброс исключения при добавлении лишней ставки в конец коллекции
* *
* @covers \AtolOnline\Entities\Payments * @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Entities\Payments::add * @covers \AtolOnline\Collections\EntityCollection::add
* @covers \AtolOnline\Entities\EntityCollection::checkCount * @covers \AtolOnline\Collections\EntityCollection::checkCount
* @covers \AtolOnline\Exceptions\TooManyPaymentsException * @covers \AtolOnline\Exceptions\TooManyPaymentsException
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
* @throws NegativePaymentSumException * @throws NegativePaymentSumException
@ -73,16 +73,16 @@ class PaymentsTest extends BasicTestCase
public function testTooManyPaymentsExceptionByAdd() public function testTooManyPaymentsExceptionByAdd()
{ {
$this->expectException(TooManyPaymentsException::class); $this->expectException(TooManyPaymentsException::class);
(new Payments($this->generateObjects(10))) (new Payments($this->generateObjects(Constraints::MAX_COUNT_DOC_PAYMENTS)))
->add($this->generateObjects()); ->add($this->generateObjects());
} }
/** /**
* Тестирует выброс исключения при добавлении лишних оплат в конец коллекции * Тестирует выброс исключения при добавлении лишних оплат в конец коллекции
* *
* @covers \AtolOnline\Entities\EntityCollection * @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Entities\EntityCollection::push * @covers \AtolOnline\Collections\EntityCollection::push
* @covers \AtolOnline\Entities\EntityCollection::checkCount * @covers \AtolOnline\Collections\EntityCollection::checkCount
* @covers \AtolOnline\Exceptions\TooManyPaymentsException * @covers \AtolOnline\Exceptions\TooManyPaymentsException
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
* @throws NegativePaymentSumException * @throws NegativePaymentSumException
@ -91,16 +91,16 @@ class PaymentsTest extends BasicTestCase
public function testTooManyPaymentsExceptionByPush() public function testTooManyPaymentsExceptionByPush()
{ {
$this->expectException(TooManyPaymentsException::class); $this->expectException(TooManyPaymentsException::class);
(new Payments($this->generateObjects(10))) (new Payments($this->generateObjects(Constraints::MAX_COUNT_DOC_PAYMENTS + 1)))
->push(...$this->generateObjects()); ->push(...$this->generateObjects());
} }
/** /**
* Тестирует выброс исключения при добавлении лишней ставки в начало коллекции * Тестирует выброс исключения при добавлении лишней ставки в начало коллекции
* *
* @covers \AtolOnline\Entities\EntityCollection * @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Entities\EntityCollection::merge * @covers \AtolOnline\Collections\EntityCollection::merge
* @covers \AtolOnline\Entities\EntityCollection::checkCount * @covers \AtolOnline\Collections\EntityCollection::checkCount
* @covers \AtolOnline\Exceptions\TooManyPaymentsException * @covers \AtolOnline\Exceptions\TooManyPaymentsException
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
* @throws NegativePaymentSumException * @throws NegativePaymentSumException
@ -109,13 +109,15 @@ class PaymentsTest extends BasicTestCase
public function testTooManyPaymentsExceptionByMerge() public function testTooManyPaymentsExceptionByMerge()
{ {
$this->expectException(TooManyPaymentsException::class); $this->expectException(TooManyPaymentsException::class);
(new Payments($this->generateObjects(9))) (new Payments($this->generateObjects(Constraints::MAX_COUNT_DOC_PAYMENTS - 1)))
->merge($this->generateObjects(2)); ->merge($this->generateObjects(2));
} }
/** /**
* Генерирует массив тестовых объектов оплаты * Генерирует массив тестовых объектов оплаты
* *
* @param int $count
* @return Payment[]
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
* @throws NegativePaymentSumException * @throws NegativePaymentSumException
* @throws TooHighPaymentSumException * @throws TooHighPaymentSumException

View File

@ -7,14 +7,19 @@
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE * https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
*/ */
namespace AtolOnline\Tests\Entities; namespace AtolOnline\Tests\Collections;
use AtolOnline\{ use AtolOnline\{
Collections\Vats,
Constants\Constraints, Constants\Constraints,
Entities\Payment,
Entities\Vat, Entities\Vat,
Entities\Vats, Enums\PaymentTypes,
Enums\VatTypes, Enums\VatTypes,
Exceptions\InvalidEntityInCollectionException,
Exceptions\InvalidEnumValueException, Exceptions\InvalidEnumValueException,
Exceptions\NegativePaymentSumException,
Exceptions\TooHighPaymentSumException,
Exceptions\TooManyVatsException, Exceptions\TooManyVatsException,
Tests\BasicTestCase}; Tests\BasicTestCase};
use Exception; use Exception;
@ -27,22 +32,24 @@ class VatsTest extends BasicTestCase
/** /**
* Тестирует создание коллекции ставок * Тестирует создание коллекции ставок
* *
* @covers \AtolOnline\Entities\EntityCollection * @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Entities\EntityCollection::checkCount * @covers \AtolOnline\Collections\EntityCollection::checkCount
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
* @throws Exception
*/ */
public function testConstructor() public function testConstructor()
{ {
$vats = new Vats($this->generateObjects(3)); $vats = new Vats($this->generateObjects(3));
$this->assertIsCollection($vats); $this->assertIsCollection($vats);
$this->assertEquals(3, $vats->count()); $this->assertEquals(3, $vats->count());
$this->assertAtolable($vats);
} }
/** /**
* Тестирует выброс исключения при установке слишком большого количества ставок через конструктор * Тестирует выброс исключения при установке слишком большого количества ставок через конструктор
* *
* @covers \AtolOnline\Entities\EntityCollection * @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Entities\EntityCollection::checkCount * @covers \AtolOnline\Collections\EntityCollection::checkCount
* @covers \AtolOnline\Exceptions\TooManyVatsException * @covers \AtolOnline\Exceptions\TooManyVatsException
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
*/ */
@ -55,9 +62,9 @@ class VatsTest extends BasicTestCase
/** /**
* Тестирует добавление ставки в начало коллекции * Тестирует добавление ставки в начало коллекции
* *
* @covers \AtolOnline\Entities\EntityCollection * @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Entities\EntityCollection::prepend * @covers \AtolOnline\Collections\EntityCollection::prepend
* @covers \AtolOnline\Entities\EntityCollection::checkCount * @covers \AtolOnline\Collections\EntityCollection::checkCount
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
*/ */
public function testPrepend() public function testPrepend()
@ -70,25 +77,25 @@ class VatsTest extends BasicTestCase
/** /**
* Тестирует выброс исключения при добавлении лишней ставки в начало коллекции * Тестирует выброс исключения при добавлении лишней ставки в начало коллекции
* *
* @covers \AtolOnline\Entities\EntityCollection * @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Entities\EntityCollection::prepend * @covers \AtolOnline\Collections\EntityCollection::prepend
* @covers \AtolOnline\Entities\EntityCollection::checkCount * @covers \AtolOnline\Collections\EntityCollection::checkCount
* @covers \AtolOnline\Exceptions\TooManyVatsException * @covers \AtolOnline\Exceptions\TooManyVatsException
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
*/ */
public function testTooManyVatsExceptionByPrepend() public function testTooManyVatsExceptionByPrepend()
{ {
$this->expectException(TooManyVatsException::class); $this->expectException(TooManyVatsException::class);
(new Vats($this->generateObjects(Constraints::MAX_COUNT_DOC_VATS + 1))) (new Vats($this->generateObjects(Constraints::MAX_COUNT_DOC_VATS)))
->prepend($this->generateObjects()); ->prepend($this->generateObjects());
} }
/** /**
* Тестирует добавление ставки в конец коллекции * Тестирует добавление ставки в конец коллекции
* *
* @covers \AtolOnline\Entities\EntityCollection * @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Entities\EntityCollection::add * @covers \AtolOnline\Collections\EntityCollection::add
* @covers \AtolOnline\Entities\EntityCollection::checkCount * @covers \AtolOnline\Collections\EntityCollection::checkCount
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
*/ */
public function testAdd() public function testAdd()
@ -101,25 +108,25 @@ class VatsTest extends BasicTestCase
/** /**
* Тестирует выброс исключения при добавлении лишней ставки в конец коллекции * Тестирует выброс исключения при добавлении лишней ставки в конец коллекции
* *
* @covers \AtolOnline\Entities\EntityCollection * @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Entities\EntityCollection::add * @covers \AtolOnline\Collections\EntityCollection::add
* @covers \AtolOnline\Entities\EntityCollection::checkCount * @covers \AtolOnline\Collections\EntityCollection::checkCount
* @covers \AtolOnline\Exceptions\TooManyVatsException * @covers \AtolOnline\Exceptions\TooManyVatsException
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
*/ */
public function testTooManyVatsExceptionByAdd() public function testTooManyVatsExceptionByAdd()
{ {
$this->expectException(TooManyVatsException::class); $this->expectException(TooManyVatsException::class);
(new Vats($this->generateObjects(Constraints::MAX_COUNT_DOC_VATS + 1))) (new Vats($this->generateObjects(Constraints::MAX_COUNT_DOC_VATS)))
->add($this->generateObjects()); ->add($this->generateObjects());
} }
/** /**
* Тестирует добавление лишних ставок в конец коллекции * Тестирует добавление лишних ставок в конец коллекции
* *
* @covers \AtolOnline\Entities\EntityCollection * @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Entities\EntityCollection::push * @covers \AtolOnline\Collections\EntityCollection::push
* @covers \AtolOnline\Entities\EntityCollection::checkCount * @covers \AtolOnline\Collections\EntityCollection::checkCount
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
*/ */
public function testPush() public function testPush()
@ -132,25 +139,25 @@ class VatsTest extends BasicTestCase
/** /**
* Тестирует выброс исключения при добавлении лишних ставок в конец коллекции * Тестирует выброс исключения при добавлении лишних ставок в конец коллекции
* *
* @covers \AtolOnline\Entities\EntityCollection * @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Entities\EntityCollection::push * @covers \AtolOnline\Collections\EntityCollection::push
* @covers \AtolOnline\Entities\EntityCollection::checkCount * @covers \AtolOnline\Collections\EntityCollection::checkCount
* @covers \AtolOnline\Exceptions\TooManyVatsException * @covers \AtolOnline\Exceptions\TooManyVatsException
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
*/ */
public function testTooManyVatsExceptionByPush() public function testTooManyVatsExceptionByPush()
{ {
$this->expectException(TooManyVatsException::class); $this->expectException(TooManyVatsException::class);
(new Vats($this->generateObjects(Constraints::MAX_COUNT_DOC_VATS + 1))) (new Vats($this->generateObjects(Constraints::MAX_COUNT_DOC_VATS)))
->push(...$this->generateObjects()); ->push(...$this->generateObjects());
} }
/** /**
* Тестирует добавление ставки в начало коллекции * Тестирует добавление ставки в начало коллекции
* *
* @covers \AtolOnline\Entities\EntityCollection * @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Entities\EntityCollection::merge * @covers \AtolOnline\Collections\EntityCollection::merge
* @covers \AtolOnline\Entities\EntityCollection::checkCount * @covers \AtolOnline\Collections\EntityCollection::checkCount
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
*/ */
public function testMerge() public function testMerge()
@ -163,22 +170,60 @@ class VatsTest extends BasicTestCase
/** /**
* Тестирует выброс исключения при добавлении лишней ставки в начало коллекции * Тестирует выброс исключения при добавлении лишней ставки в начало коллекции
* *
* @covers \AtolOnline\Entities\EntityCollection * @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Entities\EntityCollection::merge * @covers \AtolOnline\Collections\EntityCollection::merge
* @covers \AtolOnline\Entities\EntityCollection::checkCount * @covers \AtolOnline\Collections\EntityCollection::checkCount
* @covers \AtolOnline\Exceptions\TooManyVatsException * @covers \AtolOnline\Exceptions\TooManyVatsException
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
*/ */
public function testTooManyVatsExceptionByMerge() public function testTooManyVatsExceptionByMerge()
{ {
$this->expectException(TooManyVatsException::class); $this->expectException(TooManyVatsException::class);
(new Vats($this->generateObjects(9))) (new Vats($this->generateObjects(Constraints::MAX_COUNT_DOC_VATS - 1)))
->merge($this->generateObjects(2)); ->merge($this->generateObjects(2));
} }
/**
* Тестирует выброс исключения при наличии скаляров в коллекции
*
* @covers \AtolOnline\Collections\EntityCollection
* @covers \AtolOnline\Collections\EntityCollection::checkClass
* @covers \AtolOnline\Collections\EntityCollection::jsonSerialize
* @covers \AtolOnline\Exceptions\InvalidEntityInCollectionException
* @throws InvalidEnumValueException
* @throws Exception
*/
public function testInvalidCollectionItemExceptionScalar(): void
{
$this->expectException(InvalidEntityInCollectionException::class);
$this->expectExceptionMessage("(string)'bad element'");
(new Vats($this->generateObjects(2)))
->merge('bad element')
->jsonSerialize();
}
/**
* Тестирует выброс исключения при наличии объектов не тех классов в коллекции
*
* @throws InvalidEnumValueException
* @throws NegativePaymentSumException
* @throws TooHighPaymentSumException
* @throws Exception
*/
public function testInvalidCollectionItemExceptionObject(): void
{
$this->expectException(InvalidEntityInCollectionException::class);
$this->expectExceptionMessage(Payment::class);
(new Vats($this->generateObjects()))
->merge([new Payment(PaymentTypes::PREPAID, 1)])
->jsonSerialize();
}
/** /**
* Генерирует массив тестовых объектов ставок НДС * Генерирует массив тестовых объектов ставок НДС
* *
* @param int $count
* @return Vat[]
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
* @throws Exception * @throws Exception
*/ */

View File

@ -19,8 +19,8 @@ use AtolOnline\{
Exceptions\InvalidInnLengthException, Exceptions\InvalidInnLengthException,
Exceptions\InvalidPhoneException, Exceptions\InvalidPhoneException,
Exceptions\TooLongPayingAgentOperationException, Exceptions\TooLongPayingAgentOperationException,
Tests\BasicTestCase Tests\BasicTestCase};
}; use Exception;
/** /**
* Набор тестов для проверки работы класса агента * Набор тестов для проверки работы класса агента
@ -32,6 +32,7 @@ class AgentInfoTest extends BasicTestCase
* *
* @covers \AtolOnline\Entities\AgentInfo * @covers \AtolOnline\Entities\AgentInfo
* @covers \AtolOnline\Entities\AgentInfo::jsonSerialize * @covers \AtolOnline\Entities\AgentInfo::jsonSerialize
* @throws Exception
*/ */
public function testConstructorWithoutArgs(): void public function testConstructorWithoutArgs(): void
{ {
@ -58,6 +59,7 @@ class AgentInfoTest extends BasicTestCase
* @throws TooLongPayingAgentOperationException * @throws TooLongPayingAgentOperationException
* @throws InvalidInnLengthException * @throws InvalidInnLengthException
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
* @throws Exception
*/ */
public function testConstructorWithArgs(): void public function testConstructorWithArgs(): void
{ {

View File

@ -18,6 +18,7 @@ use AtolOnline\{
Exceptions\TooLongEmailException, Exceptions\TooLongEmailException,
Helpers, Helpers,
Tests\BasicTestCase}; Tests\BasicTestCase};
use Exception;
/** /**
* Набор тестов для проверки работы класса покупателя * Набор тестов для проверки работы класса покупателя
@ -29,6 +30,7 @@ class ClientTest extends BasicTestCase
* *
* @covers \AtolOnline\Entities\Client * @covers \AtolOnline\Entities\Client
* @covers \AtolOnline\Entities\Client::jsonSerialize * @covers \AtolOnline\Entities\Client::jsonSerialize
* @throws Exception
*/ */
public function testConstructorWithoutArgs(): void public function testConstructorWithoutArgs(): void
{ {
@ -48,6 +50,7 @@ class ClientTest extends BasicTestCase
* @covers \AtolOnline\Entities\Client::getPhone * @covers \AtolOnline\Entities\Client::getPhone
* @covers \AtolOnline\Entities\Client::getEmail * @covers \AtolOnline\Entities\Client::getEmail
* @covers \AtolOnline\Entities\Client::getInn * @covers \AtolOnline\Entities\Client::getInn
* @throws Exception
*/ */
public function testConstructorWithArgs(): void public function testConstructorWithArgs(): void
{ {

View File

@ -20,6 +20,7 @@ use AtolOnline\{
Exceptions\TooLongPaymentAddressException, Exceptions\TooLongPaymentAddressException,
Helpers, Helpers,
Tests\BasicTestCase}; Tests\BasicTestCase};
use Exception;
/** /**
* Набор тестов для проверки работы класса продавца * Набор тестов для проверки работы класса продавца
@ -39,6 +40,7 @@ class CompanyTest extends BasicTestCase
* @covers \AtolOnline\Entities\Company::getSno * @covers \AtolOnline\Entities\Company::getSno
* @covers \AtolOnline\Entities\Company::getInn * @covers \AtolOnline\Entities\Company::getInn
* @covers \AtolOnline\Entities\Company::getPaymentAddress * @covers \AtolOnline\Entities\Company::getPaymentAddress
* @throws Exception
*/ */
public function testConstructor() public function testConstructor()
{ {
@ -61,6 +63,12 @@ class CompanyTest extends BasicTestCase
* @covers \AtolOnline\Entities\Company * @covers \AtolOnline\Entities\Company
* @covers \AtolOnline\Entities\Company::setEmail * @covers \AtolOnline\Entities\Company::setEmail
* @covers \AtolOnline\Exceptions\TooLongEmailException * @covers \AtolOnline\Exceptions\TooLongEmailException
* @throws InvalidEmailException
* @throws InvalidEnumValueException
* @throws InvalidInnLengthException
* @throws InvalidPaymentAddressException
* @throws TooLongEmailException
* @throws TooLongPaymentAddressException
*/ */
public function testEmailTooLongException() public function testEmailTooLongException()
{ {
@ -100,6 +108,12 @@ class CompanyTest extends BasicTestCase
* @covers \AtolOnline\Entities\Company * @covers \AtolOnline\Entities\Company
* @covers \AtolOnline\Entities\Company::setInn * @covers \AtolOnline\Entities\Company::setInn
* @covers \AtolOnline\Exceptions\InvalidInnLengthException * @covers \AtolOnline\Exceptions\InvalidInnLengthException
* @throws InvalidEmailException
* @throws InvalidEnumValueException
* @throws InvalidInnLengthException
* @throws InvalidPaymentAddressException
* @throws TooLongEmailException
* @throws TooLongPaymentAddressException
*/ */
public function testInvalidInnLengthException() public function testInvalidInnLengthException()
{ {
@ -113,6 +127,12 @@ class CompanyTest extends BasicTestCase
* @covers \AtolOnline\Entities\Company * @covers \AtolOnline\Entities\Company
* @covers \AtolOnline\Entities\Company::setPaymentAddress * @covers \AtolOnline\Entities\Company::setPaymentAddress
* @covers \AtolOnline\Exceptions\TooLongPaymentAddressException * @covers \AtolOnline\Exceptions\TooLongPaymentAddressException
* @throws InvalidEmailException
* @throws InvalidEnumValueException
* @throws InvalidInnLengthException
* @throws InvalidPaymentAddressException
* @throws TooLongEmailException
* @throws TooLongPaymentAddressException
*/ */
public function testTooLongPaymentAddressException() public function testTooLongPaymentAddressException()
{ {

View File

@ -16,8 +16,8 @@ use AtolOnline\{
Exceptions\InvalidCorrectionDateException, Exceptions\InvalidCorrectionDateException,
Exceptions\InvalidEnumValueException, Exceptions\InvalidEnumValueException,
Helpers, Helpers,
Tests\BasicTestCase Tests\BasicTestCase};
}; use Exception;
/** /**
* Набор тестов для проверки работы класса данных коррекции * Набор тестов для проверки работы класса данных коррекции
@ -39,6 +39,7 @@ class CorrectionInfoTest extends BasicTestCase
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
* @throws InvalidCorrectionDateException * @throws InvalidCorrectionDateException
* @throws EmptyCorrectionNumberException * @throws EmptyCorrectionNumberException
* @throws Exception
*/ */
public function testConstructor(): void public function testConstructor(): void
{ {

View File

@ -41,8 +41,8 @@ use AtolOnline\{
Exceptions\TooLongUserdataException, Exceptions\TooLongUserdataException,
Exceptions\TooManyException, Exceptions\TooManyException,
Helpers, Helpers,
Tests\BasicTestCase Tests\BasicTestCase};
}; use Exception;
/** /**
* Набор тестов для проверки работы класс продавца * Набор тестов для проверки работы класс продавца
@ -67,6 +67,7 @@ class ItemTest extends BasicTestCase
* @throws NegativeItemPriceException * @throws NegativeItemPriceException
* @throws EmptyItemNameException * @throws EmptyItemNameException
* @throws NegativeItemQuantityException * @throws NegativeItemQuantityException
* @throws Exception
*/ */
public function testConstructor(): void public function testConstructor(): void
{ {
@ -263,6 +264,7 @@ class ItemTest extends BasicTestCase
* @throws TooHighItemPriceException * @throws TooHighItemPriceException
* @throws NegativeItemQuantityException * @throws NegativeItemQuantityException
* @throws TooLongItemNameException * @throws TooLongItemNameException
* @throws Exception
*/ */
public function testValidEnums(): void public function testValidEnums(): void
{ {
@ -332,11 +334,14 @@ class ItemTest extends BasicTestCase
* @covers \AtolOnline\Entities\Item::getVat * @covers \AtolOnline\Entities\Item::getVat
* @covers \AtolOnline\Entities\Item::jsonSerialize * @covers \AtolOnline\Entities\Item::jsonSerialize
* @throws EmptyItemNameException * @throws EmptyItemNameException
* @throws InvalidEnumValueException
* @throws NegativeItemPriceException * @throws NegativeItemPriceException
* @throws NegativeItemQuantityException * @throws NegativeItemQuantityException
* @throws TooHighItemPriceException * @throws TooHighItemPriceException
* @throws TooHighItemSumException
* @throws TooLongItemNameException * @throws TooLongItemNameException
* @throws TooManyException * @throws TooManyException
* @throws Exception
*/ */
public function testValidVatByString(): void public function testValidVatByString(): void
{ {
@ -363,11 +368,14 @@ class ItemTest extends BasicTestCase
* @covers \AtolOnline\Entities\Item::getVat * @covers \AtolOnline\Entities\Item::getVat
* @covers \AtolOnline\Entities\Item::jsonSerialize * @covers \AtolOnline\Entities\Item::jsonSerialize
* @throws EmptyItemNameException * @throws EmptyItemNameException
* @throws InvalidEnumValueException
* @throws NegativeItemPriceException * @throws NegativeItemPriceException
* @throws NegativeItemQuantityException * @throws NegativeItemQuantityException
* @throws TooHighItemPriceException * @throws TooHighItemPriceException
* @throws TooHighItemSumException
* @throws TooLongItemNameException * @throws TooLongItemNameException
* @throws TooManyException * @throws TooManyException
* @throws Exception
*/ */
public function testValidVatByObject(): void public function testValidVatByObject(): void
{ {
@ -453,6 +461,7 @@ class ItemTest extends BasicTestCase
* @throws TooHighItemPriceException * @throws TooHighItemPriceException
* @throws TooLongItemNameException * @throws TooLongItemNameException
* @throws TooManyException * @throws TooManyException
* @throws Exception
*/ */
public function testSupplier(): void public function testSupplier(): void
{ {
@ -489,6 +498,7 @@ class ItemTest extends BasicTestCase
* @throws TooLongItemNameException * @throws TooLongItemNameException
* @throws TooLongUserdataException * @throws TooLongUserdataException
* @throws TooManyException * @throws TooManyException
* @throws Exception
*/ */
public function testValidUserdata(): void public function testValidUserdata(): void
{ {
@ -558,6 +568,7 @@ class ItemTest extends BasicTestCase
* @throws TooHighItemPriceException * @throws TooHighItemPriceException
* @throws TooLongItemNameException * @throws TooLongItemNameException
* @throws TooManyException * @throws TooManyException
* @throws Exception
*/ */
public function testCountryCode(): void public function testCountryCode(): void
{ {
@ -605,6 +616,7 @@ class ItemTest extends BasicTestCase
* @throws TooLongItemNameException * @throws TooLongItemNameException
* @throws TooManyException * @throws TooManyException
* @throws InvalidDeclarationNumberException * @throws InvalidDeclarationNumberException
* @throws Exception
*/ */
public function testValidDeclarationNumber(): void public function testValidDeclarationNumber(): void
{ {
@ -675,6 +687,7 @@ class ItemTest extends BasicTestCase
* @throws EmptyItemNameException * @throws EmptyItemNameException
* @throws NegativeItemQuantityException * @throws NegativeItemQuantityException
* @throws NegativeItemExciseException * @throws NegativeItemExciseException
* @throws Exception
*/ */
public function testExcise(): void public function testExcise(): void
{ {
@ -723,6 +736,7 @@ class ItemTest extends BasicTestCase
* @throws TooLongItemNameException * @throws TooLongItemNameException
* @throws TooManyException * @throws TooManyException
* @throws TooLongItemCodeException * @throws TooLongItemCodeException
* @throws Exception
*/ */
public function testValidNomenclatureCode(): void public function testValidNomenclatureCode(): void
{ {

View File

@ -14,6 +14,7 @@ use AtolOnline\{
Exceptions\InvalidInnLengthException, Exceptions\InvalidInnLengthException,
Exceptions\InvalidPhoneException, Exceptions\InvalidPhoneException,
Tests\BasicTestCase}; Tests\BasicTestCase};
use Exception;
/** /**
* Набор тестов для проверки работы класса оператора перевода * Набор тестов для проверки работы класса оператора перевода
@ -46,6 +47,7 @@ class MoneyTransferOperatorTest extends BasicTestCase
* @covers \AtolOnline\Entities\MoneyTransferOperator::getAddress * @covers \AtolOnline\Entities\MoneyTransferOperator::getAddress
* @throws InvalidPhoneException * @throws InvalidPhoneException
* @throws InvalidInnLengthException * @throws InvalidInnLengthException
* @throws Exception
*/ */
public function testConstructorWithArgs(): void public function testConstructorWithArgs(): void
{ {

View File

@ -15,6 +15,7 @@ use AtolOnline\{
Exceptions\TooLongPayingAgentOperationException, Exceptions\TooLongPayingAgentOperationException,
Helpers, Helpers,
Tests\BasicTestCase}; Tests\BasicTestCase};
use Exception;
/** /**
* Набор тестов для проверки работы класса платёжного агента * Набор тестов для проверки работы класса платёжного агента
@ -43,6 +44,7 @@ class PayingAgentTest extends BasicTestCase
* @covers \AtolOnline\Entities\PayingAgent::getPhones * @covers \AtolOnline\Entities\PayingAgent::getPhones
* @throws InvalidPhoneException * @throws InvalidPhoneException
* @throws TooLongPayingAgentOperationException * @throws TooLongPayingAgentOperationException
* @throws Exception
*/ */
public function testConstructorWithArgs(): void public function testConstructorWithArgs(): void
{ {

View File

@ -13,13 +13,12 @@ use AtolOnline\{
Constants\Constraints, Constants\Constraints,
Entities\Payment, Entities\Payment,
Enums\PaymentTypes, Enums\PaymentTypes,
Tests\BasicTestCase Tests\BasicTestCase};
};
use AtolOnline\Exceptions\{ use AtolOnline\Exceptions\{
InvalidEnumValueException, InvalidEnumValueException,
NegativePaymentSumException, NegativePaymentSumException,
TooHighPaymentSumException, TooHighPaymentSumException,};
}; use Exception;
/** /**
* Набор тестов для проверки работы класса оплаты * Набор тестов для проверки работы класса оплаты
@ -39,6 +38,7 @@ class PaymentTest extends BasicTestCase
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
* @throws NegativePaymentSumException * @throws NegativePaymentSumException
* @throws TooHighPaymentSumException * @throws TooHighPaymentSumException
* @throws Exception
*/ */
public function testConstructor(): void public function testConstructor(): void
{ {

View File

@ -13,6 +13,7 @@ use AtolOnline\{
Entities\ReceivePaymentsOperator, Entities\ReceivePaymentsOperator,
Exceptions\InvalidPhoneException, Exceptions\InvalidPhoneException,
Tests\BasicTestCase}; Tests\BasicTestCase};
use Exception;
/** /**
* Набор тестов для проверки работы класса оператора по приёму платежей * Набор тестов для проверки работы класса оператора по приёму платежей
@ -38,6 +39,7 @@ class ReceivePaymentsOperatorTest extends BasicTestCase
* @covers \AtolOnline\Entities\ReceivePaymentsOperator::setPhones * @covers \AtolOnline\Entities\ReceivePaymentsOperator::setPhones
* @covers \AtolOnline\Entities\ReceivePaymentsOperator::getPhones * @covers \AtolOnline\Entities\ReceivePaymentsOperator::getPhones
* @throws InvalidPhoneException * @throws InvalidPhoneException
* @throws Exception
*/ */
public function testConstructorWithArgs(): void public function testConstructorWithArgs(): void
{ {

View File

@ -14,6 +14,7 @@ use AtolOnline\{
Exceptions\InvalidInnLengthException, Exceptions\InvalidInnLengthException,
Exceptions\InvalidPhoneException, Exceptions\InvalidPhoneException,
Tests\BasicTestCase}; Tests\BasicTestCase};
use Exception;
/** /**
* Набор тестов для проверки работы класса поставщика * Набор тестов для проверки работы класса поставщика
@ -44,6 +45,7 @@ class SupplierTest extends BasicTestCase
* @covers \AtolOnline\Entities\Supplier::getInn * @covers \AtolOnline\Entities\Supplier::getInn
* @throws InvalidPhoneException * @throws InvalidPhoneException
* @throws InvalidInnLengthException * @throws InvalidInnLengthException
* @throws Exception
*/ */
public function testConstructorWithArgs(): void public function testConstructorWithArgs(): void
{ {

View File

@ -14,6 +14,7 @@ use AtolOnline\{
Enums\VatTypes, Enums\VatTypes,
Exceptions\InvalidEnumValueException, Exceptions\InvalidEnumValueException,
Tests\BasicTestCase}; Tests\BasicTestCase};
use Exception;
/** /**
* Набор тестов для проверки работы класса ставки НДС * Набор тестов для проверки работы класса ставки НДС
@ -70,6 +71,7 @@ class VatTest extends BasicTestCase
* @covers \AtolOnline\Entities\Vat::getCalculated * @covers \AtolOnline\Entities\Vat::getCalculated
* @covers \AtolOnline\Entities\Vat::jsonSerialize * @covers \AtolOnline\Entities\Vat::jsonSerialize
* @throws InvalidEnumValueException * @throws InvalidEnumValueException
* @throws Exception
*/ */
public function testConstructor(string $type, float $sum): void public function testConstructor(string $type, float $sum): void
{ {