Доработки Item

- поддержка `excise`, покрыта тестами
- фикс `setVat()`
- улучшен `jsonSerialize()`
This commit is contained in:
2021-12-02 00:23:37 +08:00
parent 650b46923e
commit 11646113b6
3 changed files with 134 additions and 15 deletions

View File

@@ -28,6 +28,7 @@ use AtolOnline\{
Exceptions\InvalidInnLengthException,
Exceptions\InvalidOKSMCodeException,
Exceptions\InvalidPhoneException,
Exceptions\NegativeItemExciseException,
Exceptions\NegativeItemPriceException,
Exceptions\NegativeItemQuantityException,
Exceptions\TooHighItemQuantityException,
@@ -390,15 +391,16 @@ class ItemTest extends BasicTestCase
*
* @param mixed $vat
* @dataProvider providerNullableStrings
* @covers \AtolOnline\Entities\Item::setVat
* @covers \AtolOnline\Entities\Item::getVat
* @covers \AtolOnline\Entities\Item::jsonSerialize
* @covers \AtolOnline\Entities\Item::setVat
* @covers \AtolOnline\Entities\Item::getVat
* @covers \AtolOnline\Entities\Item::jsonSerialize
* @throws EmptyItemNameException
* @throws NegativeItemPriceException
* @throws NegativeItemQuantityException
* @throws TooHighPriceException
* @throws TooLongItemNameException
* @throws TooManyException
* @throws InvalidEnumValueException
*/
public function testNullableVatByString(mixed $vat): void
{
@@ -656,4 +658,52 @@ class ItemTest extends BasicTestCase
(new Item('test item', 2, 3))
->setDeclarationNumber(Helpers::randomStr(Constraints::MAX_LENGTH_DECLARATION_NUMBER + 1));
}
/**
* Тестирует установку акциза и расчёт суммы с его учётом
*
* @covers \AtolOnline\Entities\Item::setExcise
* @covers \AtolOnline\Entities\Item::getExcise
* @covers \AtolOnline\Entities\Item::getSum
* @covers \AtolOnline\Entities\Item::jsonSerialize
* @throws TooLongItemNameException
* @throws TooHighPriceException
* @throws TooManyException
* @throws NegativeItemPriceException
* @throws EmptyItemNameException
* @throws NegativeItemQuantityException
* @throws NegativeItemExciseException
*/
public function testExcise(): void
{
$this->assertAtolable(
(new Item('test item', 2, 3))->setExcise(1),
[
'name' => 'test item',
'price' => 2,
'quantity' => 3,
'sum' => 7,
'excise' => 1,
]
);
}
/**
* Тестирует установку акциза и расчёт суммы с его учётом
*
* @covers \AtolOnline\Entities\Item::setExcise
* @covers \AtolOnline\Exceptions\NegativeItemExciseException
* @throws TooLongItemNameException
* @throws TooHighPriceException
* @throws TooManyException
* @throws NegativeItemPriceException
* @throws EmptyItemNameException
* @throws NegativeItemQuantityException
* @throws NegativeItemExciseException
*/
public function testNegativeItemExciseException(): void
{
$this->expectException(NegativeItemExciseException::class);
(new Item('test item', 2, 3))->setExcise(-1);
}
}