2021-12-06 08:14:19 +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
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace AtolOnline\Tests\Collections;
|
|
|
|
|
|
|
|
|
|
use AtolOnline\{
|
|
|
|
|
Collections\Items,
|
|
|
|
|
Constants\Constraints,
|
|
|
|
|
Tests\BasicTestCase};
|
|
|
|
|
use AtolOnline\Exceptions\{
|
|
|
|
|
EmptyItemNameException,
|
2021-12-09 12:13:43 +00:00
|
|
|
|
EmptyItemsException,
|
2021-12-07 12:04:03 +00:00
|
|
|
|
InvalidEntityInCollectionException,
|
2021-12-06 08:14:19 +00:00
|
|
|
|
NegativeItemPriceException,
|
|
|
|
|
NegativeItemQuantityException,
|
|
|
|
|
TooHighItemPriceException,
|
|
|
|
|
TooLongItemNameException,
|
|
|
|
|
TooManyException,
|
2021-12-07 12:04:03 +00:00
|
|
|
|
TooManyItemsException};
|
2021-12-06 08:14:19 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Набор тестов для проверки работы класса коллекции предметов расчёта
|
|
|
|
|
*/
|
|
|
|
|
class ItemsTest extends BasicTestCase
|
|
|
|
|
{
|
|
|
|
|
/**
|
2021-12-09 12:13:43 +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::checkItemsClasses
|
|
|
|
|
* @covers \AtolOnline\Collections\EntityCollection::jsonSerialize
|
2021-12-06 08:14:19 +00:00
|
|
|
|
* @covers \AtolOnline\Exceptions\TooManyItemsException
|
|
|
|
|
* @throws EmptyItemNameException
|
|
|
|
|
* @throws NegativeItemPriceException
|
|
|
|
|
* @throws NegativeItemQuantityException
|
|
|
|
|
* @throws TooHighItemPriceException
|
|
|
|
|
* @throws TooLongItemNameException
|
|
|
|
|
* @throws TooManyException
|
2021-12-07 12:04:03 +00:00
|
|
|
|
* @throws InvalidEntityInCollectionException
|
2021-12-06 08:14:19 +00:00
|
|
|
|
*/
|
2021-12-09 12:13:43 +00:00
|
|
|
|
public function testTooManyItemsException()
|
2021-12-06 08:14:19 +00:00
|
|
|
|
{
|
|
|
|
|
$this->expectException(TooManyItemsException::class);
|
2021-12-09 12:13:43 +00:00
|
|
|
|
(new Items($this->generateItemObjects(Constraints::MAX_COUNT_DOC_ITEMS + 1)))->jsonSerialize();
|
2021-12-06 08:14:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-12-09 12:13:43 +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::checkItemsClasses
|
|
|
|
|
* @covers \AtolOnline\Collections\EntityCollection::jsonSerialize
|
|
|
|
|
* @covers \AtolOnline\Exceptions\EmptyItemsException
|
2021-12-07 12:04:03 +00:00
|
|
|
|
* @throws InvalidEntityInCollectionException
|
2021-12-06 08:14:19 +00:00
|
|
|
|
*/
|
2021-12-09 12:13:43 +00:00
|
|
|
|
public function testEmptyItemsException()
|
2021-12-06 08:14:19 +00:00
|
|
|
|
{
|
2021-12-09 12:13:43 +00:00
|
|
|
|
$this->expectException(EmptyItemsException::class);
|
|
|
|
|
(new Items([]))->jsonSerialize();
|
2021-12-06 08:14:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|