Доработки коллекций, чека и тестов
- `EntityCollection` сильно упрощён, добавлен выброс исключений при пустом содержимом - `Receipt::setItems(), setPayments() и setVats()` получили одинаковые проверки входящих данных - округление в `Vat::setSum()` - доработаны тесты коллекций
This commit is contained in:
@@ -15,6 +15,7 @@ use AtolOnline\{
|
||||
Tests\BasicTestCase};
|
||||
use AtolOnline\Exceptions\{
|
||||
EmptyItemNameException,
|
||||
EmptyItemsException,
|
||||
InvalidEntityInCollectionException,
|
||||
NegativeItemPriceException,
|
||||
NegativeItemQuantityException,
|
||||
@@ -29,10 +30,12 @@ use AtolOnline\Exceptions\{
|
||||
class ItemsTest extends BasicTestCase
|
||||
{
|
||||
/**
|
||||
* Тестирует выброс исключения при установке слишком большого количества оплат через конструктор
|
||||
* Тестирует выброс исключения при установке слишком большого количества предметов расчёта
|
||||
*
|
||||
* @covers \AtolOnline\Collections\EntityCollection
|
||||
* @covers \AtolOnline\Collections\EntityCollection::checkCount
|
||||
* @covers \AtolOnline\Collections\EntityCollection::checkItemsClasses
|
||||
* @covers \AtolOnline\Collections\EntityCollection::jsonSerialize
|
||||
* @covers \AtolOnline\Exceptions\TooManyItemsException
|
||||
* @throws EmptyItemNameException
|
||||
* @throws NegativeItemPriceException
|
||||
@@ -42,96 +45,25 @@ class ItemsTest extends BasicTestCase
|
||||
* @throws TooManyException
|
||||
* @throws InvalidEntityInCollectionException
|
||||
*/
|
||||
public function testTooManyItemsExceptionByConstructor()
|
||||
public function testTooManyItemsException()
|
||||
{
|
||||
$this->expectException(TooManyItemsException::class);
|
||||
new Items($this->generateItemObjects(Constraints::MAX_COUNT_DOC_ITEMS + 1));
|
||||
(new Items($this->generateItemObjects(Constraints::MAX_COUNT_DOC_ITEMS + 1)))->jsonSerialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Тестирует выброс исключения при добавлении лишней ставки в начало коллекции
|
||||
*
|
||||
* @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
|
||||
* @throws InvalidEntityInCollectionException
|
||||
*/
|
||||
public function testTooManyItemsExceptionByPrepend()
|
||||
{
|
||||
$this->expectException(TooManyItemsException::class);
|
||||
(new Items($this->generateItemObjects(Constraints::MAX_COUNT_DOC_ITEMS)))
|
||||
->prepend($this->generateItemObjects());
|
||||
}
|
||||
|
||||
/**
|
||||
* Тестирует выброс исключения при добавлении лишней ставки в конец коллекции
|
||||
* Тестирует выброс исключения при установке нулевого количества предметов расчёта
|
||||
*
|
||||
* @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
|
||||
* @covers \AtolOnline\Collections\EntityCollection::checkItemsClasses
|
||||
* @covers \AtolOnline\Collections\EntityCollection::jsonSerialize
|
||||
* @covers \AtolOnline\Exceptions\EmptyItemsException
|
||||
* @throws InvalidEntityInCollectionException
|
||||
*/
|
||||
public function testTooManyItemsExceptionByAdd()
|
||||
public function testEmptyItemsException()
|
||||
{
|
||||
$this->expectException(TooManyItemsException::class);
|
||||
(new Items($this->generateItemObjects(Constraints::MAX_COUNT_DOC_ITEMS)))
|
||||
->add($this->generateItemObjects());
|
||||
}
|
||||
|
||||
/**
|
||||
* Тестирует выброс исключения при добавлении лишних оплат в конец коллекции
|
||||
*
|
||||
* @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
|
||||
* @throws InvalidEntityInCollectionException
|
||||
*/
|
||||
public function testTooManyItemsExceptionByPush()
|
||||
{
|
||||
$this->expectException(TooManyItemsException::class);
|
||||
(new Items($this->generateItemObjects(Constraints::MAX_COUNT_DOC_ITEMS)))
|
||||
->push(...$this->generateItemObjects());
|
||||
}
|
||||
|
||||
/**
|
||||
* Тестирует выброс исключения при добавлении лишней ставки в начало коллекции
|
||||
*
|
||||
* @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
|
||||
* @throws InvalidEntityInCollectionException
|
||||
*/
|
||||
public function testTooManyItemsExceptionByMerge()
|
||||
{
|
||||
$this->expectException(TooManyItemsException::class);
|
||||
(new Items($this->generateItemObjects(Constraints::MAX_COUNT_DOC_ITEMS)))
|
||||
->merge($this->generateItemObjects(2));
|
||||
$this->expectException(EmptyItemsException::class);
|
||||
(new Items([]))->jsonSerialize();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user