parent
703c5178f5
commit
16d1146826
|
@ -17,12 +17,10 @@ use AtolOnline\Exceptions\{
|
||||||
InvalidInnLengthException,
|
InvalidInnLengthException,
|
||||||
InvalidPhoneException,
|
InvalidPhoneException,
|
||||||
TooLongClientNameException,
|
TooLongClientNameException,
|
||||||
TooLongEmailException
|
TooLongEmailException};
|
||||||
};
|
|
||||||
use AtolOnline\Traits\{
|
use AtolOnline\Traits\{
|
||||||
HasEmail,
|
HasEmail,
|
||||||
HasInn
|
HasInn};
|
||||||
};
|
|
||||||
use JetBrains\PhpStorm\Pure;
|
use JetBrains\PhpStorm\Pure;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,7 +92,7 @@ final class Client extends Entity
|
||||||
throw new TooLongClientNameException($name);
|
throw new TooLongClientNameException($name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->name = empty($name) ? null : $name;
|
$this->name = $name ?: null;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,7 @@ namespace AtolOnline\Entities;
|
||||||
use AtolOnline\Constants\Constraints;
|
use AtolOnline\Constants\Constraints;
|
||||||
use AtolOnline\Exceptions\{
|
use AtolOnline\Exceptions\{
|
||||||
InvalidPhoneException,
|
InvalidPhoneException,
|
||||||
TooLongPayingAgentOperationException
|
TooLongPayingAgentOperationException};
|
||||||
};
|
|
||||||
use AtolOnline\Traits\HasPhones;
|
use AtolOnline\Traits\HasPhones;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
@ -64,7 +63,7 @@ final class PayingAgent extends Entity
|
||||||
throw new TooLongPayingAgentOperationException($operation);
|
throw new TooLongPayingAgentOperationException($operation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->operation = empty($operation) ? null : $operation;
|
$this->operation = $operation ?: null;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -340,7 +340,7 @@ class Receipt extends Entity
|
||||||
throw new TooLongAddCheckPropException($add_check_props);
|
throw new TooLongAddCheckPropException($add_check_props);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->add_check_props = empty($add_check_props) ? null : $add_check_props;
|
$this->add_check_props = $add_check_props ?: null;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ trait HasEmail
|
||||||
throw new InvalidEmailException($email);
|
throw new InvalidEmailException($email);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->email = empty($email) ? null : $email;
|
$this->email = $email ?: null;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ trait HasInn
|
||||||
throw new InvalidInnLengthException($inn);
|
throw new InvalidInnLengthException($inn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->inn = empty($inn) ? null : $inn;
|
$this->inn = $inn ?: null;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,22 +10,28 @@
|
||||||
namespace AtolOnline\Tests\Entities;
|
namespace AtolOnline\Tests\Entities;
|
||||||
|
|
||||||
use AtolOnline\{
|
use AtolOnline\{
|
||||||
Collections\Items,
|
Constants\Constraints,
|
||||||
Collections\Payments,
|
Helpers,
|
||||||
Collections\Vats,
|
|
||||||
Entities\AgentInfo,
|
|
||||||
Entities\Client,
|
|
||||||
Entities\Company,
|
|
||||||
Entities\Item,
|
|
||||||
Entities\MoneyTransferOperator,
|
|
||||||
Entities\PayingAgent,
|
|
||||||
Entities\Receipt,
|
|
||||||
Entities\ReceivePaymentsOperator,
|
|
||||||
Entities\Supplier,
|
|
||||||
Entities\Vat,
|
|
||||||
Enums\AgentTypes,
|
|
||||||
Enums\SnoTypes,
|
|
||||||
Tests\BasicTestCase};
|
Tests\BasicTestCase};
|
||||||
|
use AtolOnline\Collections\{
|
||||||
|
Items,
|
||||||
|
Payments,
|
||||||
|
Vats,};
|
||||||
|
use AtolOnline\Entities\{
|
||||||
|
AdditionalUserProps,
|
||||||
|
AgentInfo,
|
||||||
|
Client,
|
||||||
|
Company,
|
||||||
|
Item,
|
||||||
|
MoneyTransferOperator,
|
||||||
|
PayingAgent,
|
||||||
|
Receipt,
|
||||||
|
ReceivePaymentsOperator,
|
||||||
|
Supplier,
|
||||||
|
Vat,};
|
||||||
|
use AtolOnline\Enums\{
|
||||||
|
AgentTypes,
|
||||||
|
SnoTypes,};
|
||||||
use AtolOnline\Exceptions\{
|
use AtolOnline\Exceptions\{
|
||||||
EmptyItemNameException,
|
EmptyItemNameException,
|
||||||
EmptyItemsException,
|
EmptyItemsException,
|
||||||
|
@ -41,6 +47,8 @@ use AtolOnline\Exceptions\{
|
||||||
TooHighItemPriceException,
|
TooHighItemPriceException,
|
||||||
TooHighItemSumException,
|
TooHighItemSumException,
|
||||||
TooHighPaymentSumException,
|
TooHighPaymentSumException,
|
||||||
|
TooLongAddCheckPropException,
|
||||||
|
TooLongCashierException,
|
||||||
TooLongItemNameException,
|
TooLongItemNameException,
|
||||||
TooLongPayingAgentOperationException,
|
TooLongPayingAgentOperationException,
|
||||||
TooManyException};
|
TooManyException};
|
||||||
|
@ -83,7 +91,6 @@ class ReceiptTest extends BasicTestCase
|
||||||
{
|
{
|
||||||
$receipt = $this->newReceipt();
|
$receipt = $this->newReceipt();
|
||||||
$this->assertIsAtolable($receipt);
|
$this->assertIsAtolable($receipt);
|
||||||
$receipt->getItems();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -363,7 +370,201 @@ class ReceiptTest extends BasicTestCase
|
||||||
|
|
||||||
/** @var Vat $vat */
|
/** @var Vat $vat */
|
||||||
$receipt->setVats(new Vats($this->generateVatObjects(2)))->getVats()
|
$receipt->setVats(new Vats($this->generateVatObjects(2)))->getVats()
|
||||||
->each(fn ($vat) => $this->assertEquals($items_total, $vat->getSum()));
|
->each(fn($vat) => $this->assertEquals($items_total, $vat->getSum()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Тестирует установку валидного кассира
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @covers \AtolOnline\Entities\Receipt::setCashier
|
||||||
|
* @covers \AtolOnline\Entities\Receipt::getCashier
|
||||||
|
* @covers \AtolOnline\Entities\Receipt::jsonSerialize
|
||||||
|
* @throws EmptyItemNameException
|
||||||
|
* @throws EmptyItemsException
|
||||||
|
* @throws EmptyPaymentsException
|
||||||
|
* @throws InvalidEntityInCollectionException
|
||||||
|
* @throws InvalidEnumValueException
|
||||||
|
* @throws NegativeItemPriceException
|
||||||
|
* @throws NegativeItemQuantityException
|
||||||
|
* @throws NegativePaymentSumException
|
||||||
|
* @throws TooHighItemPriceException
|
||||||
|
* @throws TooHighPaymentSumException
|
||||||
|
* @throws TooLongItemNameException
|
||||||
|
* @throws TooManyException
|
||||||
|
* @throws TooLongCashierException
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function testCashier(): void
|
||||||
|
{
|
||||||
|
$receipt = $this->newReceipt()->setCashier(Helpers::randomStr());
|
||||||
|
$this->assertArrayHasKey('cashier', $receipt->jsonSerialize());
|
||||||
|
$this->assertEquals($receipt->getCashier(), $receipt->jsonSerialize()['cashier']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Тестирует обнуление кассира
|
||||||
|
*
|
||||||
|
* @param mixed $param
|
||||||
|
* @return void
|
||||||
|
* @dataProvider providerNullableStrings
|
||||||
|
* @covers \AtolOnline\Entities\Receipt::setCashier
|
||||||
|
* @covers \AtolOnline\Entities\Receipt::getCashier
|
||||||
|
* @throws EmptyItemNameException
|
||||||
|
* @throws EmptyItemsException
|
||||||
|
* @throws EmptyPaymentsException
|
||||||
|
* @throws InvalidEntityInCollectionException
|
||||||
|
* @throws InvalidEnumValueException
|
||||||
|
* @throws NegativeItemPriceException
|
||||||
|
* @throws NegativeItemQuantityException
|
||||||
|
* @throws NegativePaymentSumException
|
||||||
|
* @throws TooHighItemPriceException
|
||||||
|
* @throws TooHighPaymentSumException
|
||||||
|
* @throws TooLongCashierException
|
||||||
|
* @throws TooLongItemNameException
|
||||||
|
* @throws TooManyException
|
||||||
|
*/
|
||||||
|
public function testNullableCashier(mixed $param): void
|
||||||
|
{
|
||||||
|
$this->assertNull($this->newReceipt()->setCashier($param)->getCashier());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Тестирует выброс исключения при установке слишком длинного кассира (лол)
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @covers \AtolOnline\Entities\Receipt::setCashier
|
||||||
|
* @covers \AtolOnline\Exceptions\TooLongCashierException
|
||||||
|
* @throws EmptyItemNameException
|
||||||
|
* @throws EmptyItemsException
|
||||||
|
* @throws EmptyPaymentsException
|
||||||
|
* @throws InvalidEntityInCollectionException
|
||||||
|
* @throws InvalidEnumValueException
|
||||||
|
* @throws NegativeItemPriceException
|
||||||
|
* @throws NegativeItemQuantityException
|
||||||
|
* @throws NegativePaymentSumException
|
||||||
|
* @throws TooHighItemPriceException
|
||||||
|
* @throws TooHighPaymentSumException
|
||||||
|
* @throws TooLongCashierException
|
||||||
|
* @throws TooLongItemNameException
|
||||||
|
* @throws TooManyException
|
||||||
|
*/
|
||||||
|
public function testTooLongCashierException(): void
|
||||||
|
{
|
||||||
|
$this->expectException(TooLongCashierException::class);
|
||||||
|
$this->newReceipt()->setCashier(Helpers::randomStr(Constraints::MAX_LENGTH_CASHIER_NAME + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Тестирует установку дополнительного реквизита чека
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @covers \AtolOnline\Entities\Receipt::setAddCheckProps
|
||||||
|
* @covers \AtolOnline\Entities\Receipt::getAddCheckProps
|
||||||
|
* @covers \AtolOnline\Entities\Receipt::jsonSerialize
|
||||||
|
* @throws EmptyItemNameException
|
||||||
|
* @throws EmptyItemsException
|
||||||
|
* @throws EmptyPaymentsException
|
||||||
|
* @throws InvalidEntityInCollectionException
|
||||||
|
* @throws InvalidEnumValueException
|
||||||
|
* @throws NegativeItemPriceException
|
||||||
|
* @throws NegativeItemQuantityException
|
||||||
|
* @throws NegativePaymentSumException
|
||||||
|
* @throws TooHighItemPriceException
|
||||||
|
* @throws TooHighPaymentSumException
|
||||||
|
* @throws TooLongItemNameException
|
||||||
|
* @throws TooManyException
|
||||||
|
* @throws TooLongAddCheckPropException
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function testAddCheckProps(): void
|
||||||
|
{
|
||||||
|
$receipt = $this->newReceipt()->setAddCheckProps(Helpers::randomStr());
|
||||||
|
$this->assertArrayHasKey('additional_check_props', $receipt->jsonSerialize());
|
||||||
|
$this->assertEquals($receipt->getAddCheckProps(), $receipt->jsonSerialize()['additional_check_props']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Тестирует обнуление дополнительного реквизита чека
|
||||||
|
*
|
||||||
|
* @param mixed $param
|
||||||
|
* @return void
|
||||||
|
* @dataProvider providerNullableStrings
|
||||||
|
* @covers \AtolOnline\Entities\Receipt::setAddCheckProps
|
||||||
|
* @covers \AtolOnline\Entities\Receipt::getAddCheckProps
|
||||||
|
* @throws EmptyItemNameException
|
||||||
|
* @throws EmptyItemsException
|
||||||
|
* @throws EmptyPaymentsException
|
||||||
|
* @throws InvalidEntityInCollectionException
|
||||||
|
* @throws InvalidEnumValueException
|
||||||
|
* @throws NegativeItemPriceException
|
||||||
|
* @throws NegativeItemQuantityException
|
||||||
|
* @throws NegativePaymentSumException
|
||||||
|
* @throws TooHighItemPriceException
|
||||||
|
* @throws TooHighPaymentSumException
|
||||||
|
* @throws TooLongAddCheckPropException
|
||||||
|
* @throws TooLongItemNameException
|
||||||
|
* @throws TooManyException
|
||||||
|
*/
|
||||||
|
public function testNullableAddCheckProps(mixed $param): void
|
||||||
|
{
|
||||||
|
$this->assertNull($this->newReceipt()->setAddCheckProps($param)->getAddCheckProps());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Тестирует выброс исключения при установке слишком длинного дополнительного реквизита чека
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @covers \AtolOnline\Entities\Receipt::setAddCheckProps
|
||||||
|
* @covers \AtolOnline\Exceptions\TooLongAddCheckPropException
|
||||||
|
* @throws EmptyItemNameException
|
||||||
|
* @throws EmptyItemsException
|
||||||
|
* @throws EmptyPaymentsException
|
||||||
|
* @throws InvalidEntityInCollectionException
|
||||||
|
* @throws InvalidEnumValueException
|
||||||
|
* @throws NegativeItemPriceException
|
||||||
|
* @throws NegativeItemQuantityException
|
||||||
|
* @throws NegativePaymentSumException
|
||||||
|
* @throws TooHighItemPriceException
|
||||||
|
* @throws TooHighPaymentSumException
|
||||||
|
* @throws TooLongAddCheckPropException
|
||||||
|
* @throws TooLongItemNameException
|
||||||
|
* @throws TooManyException
|
||||||
|
*/
|
||||||
|
public function testTooLongAddCheckPropException(): void
|
||||||
|
{
|
||||||
|
$this->expectException(TooLongAddCheckPropException::class);
|
||||||
|
$this->newReceipt()->setAddCheckProps(Helpers::randomStr(Constraints::MAX_LENGTH_ADD_CHECK_PROP + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Тестирует установку дополнительного реквизита пользователя
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @covers \AtolOnline\Entities\Receipt::setAddUserProps
|
||||||
|
* @covers \AtolOnline\Entities\Receipt::getAddUserProps
|
||||||
|
* @covers \AtolOnline\Entities\Receipt::jsonSerialize
|
||||||
|
* @throws EmptyItemNameException
|
||||||
|
* @throws EmptyItemsException
|
||||||
|
* @throws EmptyPaymentsException
|
||||||
|
* @throws InvalidEntityInCollectionException
|
||||||
|
* @throws InvalidEnumValueException
|
||||||
|
* @throws NegativeItemPriceException
|
||||||
|
* @throws NegativeItemQuantityException
|
||||||
|
* @throws NegativePaymentSumException
|
||||||
|
* @throws TooHighItemPriceException
|
||||||
|
* @throws TooHighPaymentSumException
|
||||||
|
* @throws TooLongItemNameException
|
||||||
|
* @throws TooManyException
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function testAdditionalUserProps(): void
|
||||||
|
{
|
||||||
|
$aup = new AdditionalUserProps('name', 'value');
|
||||||
|
$receipt = $this->newReceipt()->setAddUserProps($aup);
|
||||||
|
$this->assertArrayHasKey('additional_user_props', $receipt->jsonSerialize());
|
||||||
|
$this->assertEquals($receipt->getAddUserProps(), $receipt->jsonSerialize()['additional_user_props']);
|
||||||
|
$this->assertArrayNotHasKey('additional_user_props', $receipt->setAddUserProps(null)->jsonSerialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue