Миграция на php8.1

* enum-ы теперь enum-ы, а не говно -- теперь всё переведено на них, где это было возможно
* некоторые свойства классов объявлены в конструкторе
* некоторые классы перемещены в корневой неймспейс
* исправлен код-стайл, вычищен некоторый мусор, выправлены тесты... работы над этим продолжаются
This commit is contained in:
2022-12-15 00:19:55 +08:00
parent 692ae43f9f
commit 4157ab68f5
120 changed files with 1098 additions and 1401 deletions

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -10,7 +11,7 @@
namespace AtolOnline\Tests\Entities;
use AtolOnline\{
Constants\Constraints,
Constraints,
Entities\AdditionalUserProps,
Exceptions\EmptyAddUserPropNameException,
Exceptions\EmptyAddUserPropValueException,

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -14,8 +15,7 @@ use AtolOnline\{
Entities\MoneyTransferOperator,
Entities\PayingAgent,
Entities\ReceivePaymentsOperator,
Enums\AgentTypes,
Exceptions\InvalidEnumValueException,
Enums\AgentType,
Exceptions\InvalidInnLengthException,
Exceptions\InvalidPhoneException,
Exceptions\TooLongPayingAgentOperationException,
@@ -36,7 +36,7 @@ class AgentInfoTest extends BasicTestCase
*/
public function testConstructorWithoutArgs(): void
{
$this->assertIsAtolable(new AgentInfo(), []);
$this->assertIsAtolable(new AgentInfo());
}
/**
@@ -58,63 +58,64 @@ class AgentInfoTest extends BasicTestCase
* @throws InvalidPhoneException
* @throws TooLongPayingAgentOperationException
* @throws InvalidInnLengthException
* @throws InvalidEnumValueException
* @throws Exception
*/
public function testConstructorWithArgs(): void
{
$this->assertIsAtolable(new AgentInfo(null), []);
$this->assertIsAtolable(new AgentInfo(AgentTypes::ANOTHER), ['type' => AgentTypes::ANOTHER]);
$this->assertIsAtolable(new AgentInfo(pagent: new PayingAgent()), []);
$this->assertIsAtolable(new AgentInfo(mt_operator: new MoneyTransferOperator()), []);
$this->assertIsAtolable(new AgentInfo(rp_operator: new ReceivePaymentsOperator()), []);
$this->assertIsAtolable(new AgentInfo(null));
$this->assertIsAtolable(
new AgentInfo(AgentType::ANOTHER),
['type' => AgentType::ANOTHER]
);
$this->assertIsAtolable(
new AgentInfo(payingAgent: new PayingAgent())
);
$this->assertIsAtolable(
new AgentInfo(moneyTransferOperator: new MoneyTransferOperator())
);
$this->assertIsAtolable(
new AgentInfo(receivePaymentsOperator: new ReceivePaymentsOperator())
);
$this->assertIsAtolable(new AgentInfo(
AgentTypes::ANOTHER,
new PayingAgent(),
new ReceivePaymentsOperator(),
new MoneyTransferOperator(),
), ['type' => AgentTypes::ANOTHER]);
$this->assertIsAtolable(
new AgentInfo(
AgentType::ANOTHER,
new PayingAgent(),
new ReceivePaymentsOperator(),
new MoneyTransferOperator(),
),
['type' => AgentType::ANOTHER]
);
$this->assertIsAtolable(new AgentInfo(
AgentTypes::ANOTHER,
new PayingAgent('test', ['+79518888888']),
new ReceivePaymentsOperator(['+79519999999']),
new MoneyTransferOperator('MTO Name', '9876543210', 'London', ['+79517777777']),
), [
'type' => AgentTypes::ANOTHER,
'paying_agent' => [
'operation' => 'test',
'phones' => [
'+79518888888',
$this->assertIsAtolable(
new AgentInfo(
AgentType::ANOTHER,
new PayingAgent('test', ['+79518888888']),
new ReceivePaymentsOperator(['+79519999999']),
new MoneyTransferOperator('MTO Name', '9876543210', 'London', ['+79517777777']),
),
[
'type' => AgentType::ANOTHER,
'paying_agent' => [
'operation' => 'test',
'phones' => [
'+79518888888',
],
],
],
'receive_payments_operator' => [
'phones' => [
'+79519999999',
'receive_payments_operator' => [
'phones' => [
'+79519999999',
],
],
],
'money_transfer_operator' => [
'name' => 'MTO Name',
'inn' => '9876543210',
'address' => 'London',
'phones' => [
"+79517777777",
'money_transfer_operator' => [
'name' => 'MTO Name',
'inn' => '9876543210',
'address' => 'London',
'phones' => [
'+79517777777',
],
],
],
]);
}
/**
* Тестирует исключение при некорректном типе
*
* @covers \AtolOnline\Entities\AgentInfo
* @covers \AtolOnline\Enums\AgentTypes::isValid
* @covers \AtolOnline\Exceptions\InvalidEnumValueException
*/
public function testInvalidEnumValueException(): void
{
$this->expectException(InvalidEnumValueException::class);
new AgentInfo('qwerty');
]
);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -9,15 +10,15 @@
namespace AtolOnline\Tests\Entities;
use AtolOnline\{Entities\Client,
use AtolOnline\{
Entities\Client,
Exceptions\InvalidEmailException,
Exceptions\InvalidInnLengthException,
Exceptions\InvalidPhoneException,
Exceptions\TooLongClientNameException,
Exceptions\TooLongEmailException,
Helpers,
Tests\BasicTestCase
};
Tests\BasicTestCase};
use BadMethodCallException;
use Exception;
@@ -35,7 +36,7 @@ class ClientTest extends BasicTestCase
*/
public function testConstructorWithoutArgs(): void
{
$this->assertIsAtolable(new Client(), []);
$this->assertIsAtolable(new Client());
}
/**
@@ -56,19 +57,20 @@ class ClientTest extends BasicTestCase
public function testConstructorWithArgs(): void
{
$this->assertIsAtolable(new Client('John Doe'), ['name' => 'John Doe']);
$this->assertIsAtolable(new Client(email: 'john@example.com'), ['email' => 'john@example.com']);
$this->assertIsAtolable(new Client(phone: '+1/22/99*73s dsdas654 5s6'), ['phone' => '+122997365456']);
$this->assertIsAtolable(new Client(email: 'john@example.com'), ['email' => 'john@example.com']);
$this->assertIsAtolable(new Client(inn: '+fasd3\qe3fs_=nac99013928czc'), ['inn' => '3399013928']);
$this->assertIsAtolable(
new Client(
'John Doe',
'john@example.com',
'+1/22/99*73s dsdas654 5s6', // +122997365456
'john@example.com',
'+fasd3\qe3fs_=nac99013928czc' // 3399013928
), [
),
[
'name' => 'John Doe',
'email' => 'john@example.com',
'phone' => '+122997365456',
'email' => 'john@example.com',
'inn' => '3399013928',
]
);
@@ -100,7 +102,7 @@ class ClientTest extends BasicTestCase
public function testValidName(): void
{
$name = Helpers::randomStr();
$this->assertEquals($name, (new Client())->setName($name)->getName());
$this->assertSame($name, (new Client())->setName($name)->getName());
}
/**
@@ -143,7 +145,7 @@ class ClientTest extends BasicTestCase
*/
public function testValidPhone(string $input, string $output): void
{
$this->assertEquals($output, (new Client())->setPhone($input)->getPhone());
$this->assertSame($output, (new Client())->setPhone($input)->getPhone());
}
/**
@@ -174,7 +176,7 @@ class ClientTest extends BasicTestCase
*/
public function testValidEmails(mixed $email): void
{
$this->assertEquals($email, (new Client())->setEmail($email)->getEmail());
$this->assertSame($email, (new Client())->setEmail($email)->getEmail());
}
/**
@@ -219,8 +221,8 @@ class ClientTest extends BasicTestCase
*/
public function testValidInn(): void
{
$this->assertEquals('1234567890', (new Client())->setInn('1234567890')->getInn());
$this->assertEquals('123456789012', (new Client())->setInn('123456789012')->getInn());
$this->assertSame('1234567890', (new Client())->setInn('1234567890')->getInn());
$this->assertSame('123456789012', (new Client())->setInn('123456789012')->getInn());
}
/**
@@ -261,7 +263,7 @@ class ClientTest extends BasicTestCase
public function testOffsetGetExists(): void
{
$client = new Client('John Doe');
$this->assertEquals('John Doe', $client['name']);
$this->assertSame('John Doe', $client['name']);
$this->assertTrue(isset($client['name']));
$this->assertFalse(isset($client['qwerty']));
}

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -11,9 +12,8 @@ namespace AtolOnline\Tests\Entities;
use AtolOnline\{
Entities\Company,
Enums\SnoTypes,
Enums\SnoType,
Exceptions\InvalidEmailException,
Exceptions\InvalidEnumValueException,
Exceptions\InvalidInnLengthException,
Exceptions\InvalidPaymentAddressException,
Exceptions\TooLongEmailException,
@@ -44,17 +44,20 @@ class CompanyTest extends BasicTestCase
*/
public function testConstructor()
{
$this->assertIsAtolable(new Company(
$email = 'company@example.com',
$sno = SnoTypes::OSN,
$inn = '1234567890',
$payment_address = 'https://example.com',
), [
'email' => $email,
'sno' => $sno,
'inn' => $inn,
'payment_address' => $payment_address,
]);
$this->assertIsAtolable(
new Company(
$inn = '1234567890',
$sno = SnoType::OSN,
$paymentAddress = 'https://example.com',
$email = 'company@example.com',
),
[
'inn' => $inn,
'sno' => $sno,
'payment_address' => $paymentAddress,
'email' => $email,
]
);
}
/**
@@ -64,7 +67,6 @@ class CompanyTest extends BasicTestCase
* @covers \AtolOnline\Entities\Company::setEmail
* @covers \AtolOnline\Exceptions\TooLongEmailException
* @throws InvalidEmailException
* @throws InvalidEnumValueException
* @throws InvalidInnLengthException
* @throws InvalidPaymentAddressException
* @throws TooLongEmailException
@@ -73,7 +75,7 @@ class CompanyTest extends BasicTestCase
public function testEmailTooLongException()
{
$this->expectException(TooLongEmailException::class);
new Company(Helpers::randomStr(65), SnoTypes::OSN, '1234567890', 'https://example.com');
new Company('1234567890', SnoType::OSN, 'https://example.com', Helpers::randomStr(65));
}
/**
@@ -86,20 +88,7 @@ class CompanyTest extends BasicTestCase
public function testInvalidEmailException()
{
$this->expectException(InvalidEmailException::class);
new Company('company@examas%^*.com', SnoTypes::OSN, '1234567890', 'https://example.com');
}
/**
* Тестирует исключение о слишком длинном платёжном адресе
*
* @covers \AtolOnline\Entities\Company
* @covers \AtolOnline\Entities\Company::setSno
* @covers \AtolOnline\Exceptions\InvalidEnumValueException
*/
public function testInvalidSnoException()
{
$this->expectException(InvalidEnumValueException::class);
new Company('company@example.com', 'test', '1234567890', 'https://example.com');
new Company('1234567890', SnoType::OSN, 'https://example.com', 'company@examas%^*.com');
}
/**
@@ -109,7 +98,6 @@ class CompanyTest extends BasicTestCase
* @covers \AtolOnline\Entities\Company::setInn
* @covers \AtolOnline\Exceptions\InvalidInnLengthException
* @throws InvalidEmailException
* @throws InvalidEnumValueException
* @throws InvalidInnLengthException
* @throws InvalidPaymentAddressException
* @throws TooLongEmailException
@@ -118,7 +106,7 @@ class CompanyTest extends BasicTestCase
public function testInvalidInnLengthException()
{
$this->expectException(InvalidInnLengthException::class);
new Company('company@example.com', SnoTypes::OSN, Helpers::randomStr(13), 'https://example.com');
new Company(Helpers::randomStr(13), SnoType::OSN, 'https://example.com', 'company@example.com');
}
/**
@@ -128,7 +116,6 @@ class CompanyTest extends BasicTestCase
* @covers \AtolOnline\Entities\Company::setPaymentAddress
* @covers \AtolOnline\Exceptions\TooLongPaymentAddressException
* @throws InvalidEmailException
* @throws InvalidEnumValueException
* @throws InvalidInnLengthException
* @throws InvalidPaymentAddressException
* @throws TooLongEmailException
@@ -137,7 +124,7 @@ class CompanyTest extends BasicTestCase
public function testTooLongPaymentAddressException()
{
$this->expectException(TooLongPaymentAddressException::class);
new Company('company@example.com', SnoTypes::OSN, '1234567890', Helpers::randomStr(257));
new Company('1234567890', SnoType::OSN, Helpers::randomStr(257), 'company@example.com');
}
/**
@@ -150,6 +137,6 @@ class CompanyTest extends BasicTestCase
public function testInvalidPaymentAddressException()
{
$this->expectException(InvalidPaymentAddressException::class);
new Company('company@example.com', SnoTypes::OSN, '1234567890', '');
new Company('1234567890', SnoType::OSN, '', 'company@example.com');
}
}

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -11,12 +12,13 @@ namespace AtolOnline\Tests\Entities;
use AtolOnline\{
Entities\CorrectionInfo,
Enums\CorrectionTypes,
Enums\CorrectionType,
Exceptions\EmptyCorrectionNumberException,
Exceptions\InvalidCorrectionDateException,
Exceptions\InvalidEnumValueException,
Helpers,
Tests\BasicTestCase};
use DateTime;
use DateTimeImmutable;
use Exception;
/**
@@ -36,7 +38,6 @@ class CorrectionInfoTest extends BasicTestCase
* @covers \AtolOnline\Entities\CorrectionInfo::getNumber
* @covers \AtolOnline\Entities\CorrectionInfo::jsonSerialize
* @return void
* @throws InvalidEnumValueException
* @throws InvalidCorrectionDateException
* @throws EmptyCorrectionNumberException
* @throws Exception
@@ -44,32 +45,35 @@ class CorrectionInfoTest extends BasicTestCase
public function testConstructor(): void
{
$this->assertIsAtolable(
new CorrectionInfo(CorrectionTypes::SELF, '01.01.2021', $number = Helpers::randomStr()),
new CorrectionInfo(CorrectionType::SELF, '01.01.2021', $number = Helpers::randomStr()),
[
'type' => CorrectionTypes::SELF,
'type' => CorrectionType::SELF,
'base_date' => '01.01.2021',
'base_number' => $number,
]
);
}
/**
* Тестирует исключение при некорректном типе
*
* @covers \AtolOnline\Entities\CorrectionInfo
* @covers \AtolOnline\Entities\CorrectionInfo::setType
* @covers \AtolOnline\Enums\CorrectionTypes::isValid
* @covers \AtolOnline\Exceptions\InvalidEnumValueException
* @return void
* @throws EmptyCorrectionNumberException
* @throws InvalidCorrectionDateException
* @throws InvalidEnumValueException
*/
public function testInvalidEnumValueException(): void
{
$this->expectException(InvalidEnumValueException::class);
$this->expectExceptionMessage('Некорректное значение AtolOnline\Enums\CorrectionTypes::wrong_value');
new CorrectionInfo('wrong_value', '01.01.2021', Helpers::randomStr());
$this->assertIsAtolable(
new CorrectionInfo(CorrectionType::SELF, new DateTime('02.02.2022'), $number = Helpers::randomStr()),
[
'type' => CorrectionType::SELF,
'base_date' => '02.02.2022',
'base_number' => $number,
]
);
$this->assertIsAtolable(
new CorrectionInfo(
CorrectionType::SELF,
new DateTimeImmutable('03.03.2023'),
$number = Helpers::randomStr()
),
[
'type' => CorrectionType::SELF,
'base_date' => '03.03.2023',
'base_number' => $number,
]
);
}
/**
@@ -77,17 +81,15 @@ class CorrectionInfoTest extends BasicTestCase
*
* @covers \AtolOnline\Entities\CorrectionInfo
* @covers \AtolOnline\Entities\CorrectionInfo::setDate
* @covers \AtolOnline\Enums\CorrectionTypes::isValid
* @covers \AtolOnline\Exceptions\InvalidCorrectionDateException
* @return void
* @throws EmptyCorrectionNumberException
* @throws InvalidCorrectionDateException
* @throws InvalidEnumValueException
*/
public function testInvalidCorrectionDateException(): void
{
$this->expectException(InvalidCorrectionDateException::class);
new CorrectionInfo(CorrectionTypes::SELF, Helpers::randomStr(), Helpers::randomStr());
new CorrectionInfo(CorrectionType::SELF, Helpers::randomStr(), Helpers::randomStr());
}
/**
@@ -95,13 +97,12 @@ class CorrectionInfoTest extends BasicTestCase
*
* @covers \AtolOnline\Entities\CorrectionInfo
* @covers \AtolOnline\Entities\CorrectionInfo::setNumber
* @covers \AtolOnline\Enums\CorrectionTypes::isValid
* @covers \AtolOnline\Exceptions\EmptyCorrectionNumberException
* @return void
*/
public function testEmptyCorrectionNumberException(): void
{
$this->expectException(EmptyCorrectionNumberException::class);
new CorrectionInfo(CorrectionTypes::SELF, '01.01.2021', "\n\r\t\0");
new CorrectionInfo(CorrectionType::SELF, '01.01.2021', "\n\r\t\0");
}
}

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -10,7 +11,7 @@
namespace AtolOnline\Tests\Entities;
use AtolOnline\{
Constants\Constraints,
Constraints,
Helpers,
Tests\BasicTestCase};
use AtolOnline\Exceptions\{
@@ -71,7 +72,7 @@ class CorrectionTest extends BasicTestCase
{
$correction = $this->newCorrection()->setCashier(Helpers::randomStr());
$this->assertArrayHasKey('cashier', $correction->jsonSerialize());
$this->assertEquals($correction->getCashier(), $correction->jsonSerialize()['cashier']);
$this->assertSame($correction->getCashier(), $correction->jsonSerialize()['cashier']);
}
/**

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -10,38 +11,40 @@
namespace AtolOnline\Tests\Entities;
use AtolOnline\{
Constants\Constraints,
Entities\AgentInfo,
Entities\Item,
Entities\MoneyTransferOperator,
Entities\PayingAgent,
Entities\ReceivePaymentsOperator,
Entities\Supplier,
Entities\Vat,
Enums\AgentTypes,
Enums\PaymentMethods,
Enums\PaymentObjects,
Enums\VatTypes,
Exceptions\EmptyItemNameException,
Exceptions\InvalidDeclarationNumberException,
Exceptions\InvalidEnumValueException,
Exceptions\InvalidInnLengthException,
Exceptions\InvalidOKSMCodeException,
Exceptions\InvalidPhoneException,
Exceptions\NegativeItemExciseException,
Exceptions\NegativeItemPriceException,
Exceptions\NegativeItemQuantityException,
Exceptions\TooHighItemPriceException,
Exceptions\TooHighItemQuantityException,
Exceptions\TooHighItemSumException,
Exceptions\TooLongItemCodeException,
Exceptions\TooLongItemNameException,
Exceptions\TooLongMeasurementUnitException,
Exceptions\TooLongPayingAgentOperationException,
Exceptions\TooLongUserdataException,
Exceptions\TooManyException,
Constraints,
Helpers,
Tests\BasicTestCase};
use AtolOnline\Entities\{
AgentInfo,
Item,
MoneyTransferOperator,
PayingAgent,
ReceivePaymentsOperator,
Supplier,
Vat,};
use AtolOnline\Enums\{
AgentType,
PaymentMethod,
PaymentObject,
VatType,};
use AtolOnline\Exceptions\{
EmptyItemNameException,
InvalidDeclarationNumberException,
InvalidInnLengthException,
InvalidOKSMCodeException,
InvalidPhoneException,
NegativeItemExciseException,
NegativeItemPriceException,
NegativeItemQuantityException,
TooHighItemPriceException,
TooHighItemQuantityException,
TooHighItemSumException,
TooLongItemCodeException,
TooLongItemNameException,
TooLongMeasurementUnitException,
TooLongPayingAgentOperationException,
TooLongUserdataException,
TooManyException,};
use Exception;
/**
@@ -258,7 +261,6 @@ class ItemTest extends BasicTestCase
* @covers \AtolOnline\Entities\Item::getPaymentObject
* @covers \AtolOnline\Entities\Item::jsonSerialize
* @throws EmptyItemNameException
* @throws InvalidEnumValueException
* @throws TooManyException
* @throws NegativeItemPriceException
* @throws TooHighItemPriceException
@@ -269,13 +271,13 @@ class ItemTest extends BasicTestCase
public function testValidEnums(): void
{
$item = new Item('test item', 2, 3);
$this->assertEquals(
PaymentMethods::ADVANCE,
$item->setPaymentMethod(PaymentMethods::ADVANCE)->getPaymentMethod()
$this->assertSame(
PaymentMethod::ADVANCE,
$item->setPaymentMethod(PaymentMethod::ADVANCE)->getPaymentMethod()
);
$this->assertEquals(
PaymentObjects::COMMODITY,
$item->setPaymentObject(PaymentObjects::COMMODITY)->getPaymentObject()
$this->assertSame(
PaymentObject::COMMODITY,
$item->setPaymentObject(PaymentObject::COMMODITY)->getPaymentObject()
);
$this->assertIsAtolable($item, [
'name' => 'test item',
@@ -287,80 +289,6 @@ class ItemTest extends BasicTestCase
]);
}
/**
* Тестирует установку невалидного способа оплаты
*
* @covers \AtolOnline\Entities\Item::setPaymentMethod
* @covers \AtolOnline\Exceptions\InvalidEnumValueException
* @throws EmptyItemNameException
* @throws InvalidEnumValueException
* @throws TooManyException
* @throws NegativeItemPriceException
* @throws TooHighItemPriceException
* @throws NegativeItemQuantityException
* @throws TooLongItemNameException
*/
public function testInvalidPaymentMethod(): void
{
$this->expectException(InvalidEnumValueException::class);
$this->expectExceptionMessage('Некорректное значение AtolOnline\Enums\PaymentMethods::wrong_value');
(new Item('test item', 2, 3))->setPaymentMethod('wrong_value');
}
/**
* Тестирует установку невалидного предмета расчёта
*
* @covers \AtolOnline\Entities\Item::setPaymentObject
* @covers \AtolOnline\Exceptions\InvalidEnumValueException
* @throws EmptyItemNameException
* @throws InvalidEnumValueException
* @throws TooManyException
* @throws NegativeItemPriceException
* @throws TooHighItemPriceException
* @throws NegativeItemQuantityException
* @throws TooLongItemNameException
*/
public function testInvalidPaymentObject(): void
{
$this->expectException(InvalidEnumValueException::class);
$this->expectExceptionMessage('Некорректное значение AtolOnline\Enums\PaymentObjects::wrong_value');
(new Item('test item', 2, 3))->setPaymentObject('wrong_value');
}
/**
* Тестирует установку ставки НДС по строковой константе типа ставки
*
* @covers \AtolOnline\Entities\Item::setVat
* @covers \AtolOnline\Entities\Item::getVat
* @covers \AtolOnline\Entities\Item::jsonSerialize
* @throws EmptyItemNameException
* @throws InvalidEnumValueException
* @throws NegativeItemPriceException
* @throws NegativeItemQuantityException
* @throws TooHighItemPriceException
* @throws TooHighItemSumException
* @throws TooLongItemNameException
* @throws TooManyException
* @throws Exception
*/
public function testValidVatByString(): void
{
$item = (new Item('test item', 2, 3))->setVat(VatTypes::VAT20);
$this->assertIsSameClass(Vat::class, $item->getVat());
$this->assertEquals(VatTypes::VAT20, $item->getVat()->getType());
$this->assertEquals($item->getSum(), $item->getVat()->getSum());
$this->assertIsAtolable($item, [
'name' => 'test item',
'price' => 2,
'quantity' => 3,
'sum' => 6,
'vat' => [
'type' => 'vat20',
'sum' => 1.2,
],
]);
}
/**
* Тестирует установку ставки НДС объектом
*
@@ -368,7 +296,6 @@ class ItemTest extends BasicTestCase
* @covers \AtolOnline\Entities\Item::getVat
* @covers \AtolOnline\Entities\Item::jsonSerialize
* @throws EmptyItemNameException
* @throws InvalidEnumValueException
* @throws NegativeItemPriceException
* @throws NegativeItemQuantityException
* @throws TooHighItemPriceException
@@ -379,11 +306,11 @@ class ItemTest extends BasicTestCase
*/
public function testValidVatByObject(): void
{
$vat = new Vat(VatTypes::VAT20, 4000);
$vat = new Vat(VatType::VAT20, 4000);
$item = (new Item('test item', 2, 3))->setVat($vat);
$this->assertIsSameClass(Vat::class, $item->getVat());
$this->assertEquals(VatTypes::VAT20, $item->getVat()->getType());
$this->assertEquals($item->getSum(), $item->getVat()->getSum());
$this->assertSame(VatType::VAT20, $item->getVat()->getType());
$this->assertSame($item->getSum(), $item->getVat()->getSum());
$this->assertIsAtolable($item, [
'name' => 'test item',
'price' => 2,
@@ -396,28 +323,6 @@ class ItemTest extends BasicTestCase
]);
}
/**
* Тестирует обнуление ставки НДС
*
* @param mixed $vat
* @dataProvider providerNullableStrings
* @covers \AtolOnline\Entities\Item::setVat
* @covers \AtolOnline\Entities\Item::getVat
* @covers \AtolOnline\Entities\Item::jsonSerialize
* @throws EmptyItemNameException
* @throws NegativeItemPriceException
* @throws NegativeItemQuantityException
* @throws TooHighItemPriceException
* @throws TooLongItemNameException
* @throws TooManyException
* @throws InvalidEnumValueException
*/
public function testNullableVatByString(mixed $vat): void
{
$item = (new Item('test item', 2, 3))->setVat($vat);
$this->assertNull($item->getVat());
}
/**
* Тестирует установку атрибутов агента
*
@@ -425,7 +330,6 @@ class ItemTest extends BasicTestCase
* @covers \AtolOnline\Entities\Item::getAgentInfo
* @covers \AtolOnline\Entities\Item::jsonSerialize
* @throws EmptyItemNameException
* @throws InvalidEnumValueException
* @throws InvalidInnLengthException
* @throws InvalidPhoneException
* @throws NegativeItemPriceException
@@ -438,13 +342,13 @@ class ItemTest extends BasicTestCase
public function testAgentInfo(): void
{
$agent_info = new AgentInfo(
AgentTypes::ANOTHER,
AgentType::ANOTHER,
new PayingAgent('test', ['+79518888888']),
new ReceivePaymentsOperator(['+79519999999']),
new MoneyTransferOperator('MTO Name', '9876543210', 'London', ['+79517777777']),
);
$item = (new Item('test item', 2, 3))->setAgentInfo($agent_info);
$this->assertEquals($agent_info, $item->getAgentInfo());
$this->assertSame($agent_info, $item->getAgentInfo());
}
/**
@@ -471,7 +375,7 @@ class ItemTest extends BasicTestCase
['+122997365456'],
);
$item = (new Item('test item', 2, 3))->setSupplier($supplier);
$this->assertEquals($supplier, $item->getSupplier());
$this->assertSame($supplier, $item->getSupplier());
$this->assertIsAtolable($item, [
'name' => 'test item',
'price' => 2,
@@ -744,11 +648,11 @@ class ItemTest extends BasicTestCase
$encoded = trim(preg_replace('/([\dA-Fa-f]{2})/', '$1 ', bin2hex($code)));
$item = (new Item('test item', 2, 3))->setCode($code);
$this->assertEquals($code, $item->getCode());
$this->assertEquals($encoded, $item->getCodeHex());
$this->assertSame($code, $item->getCode());
$this->assertSame($encoded, $item->getCodeHex());
$decoded = hex2bin(str_replace(' ', '', $item->getCodeHex()));
$this->assertEquals($decoded, $item->getCode());
$this->assertSame($decoded, $item->getCode());
$this->assertIsAtolable($item, [
'name' => 'test item',

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -7,7 +8,7 @@
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
*/
declare(strict_types = 1);
declare(strict_types=1);
namespace AtolOnline\Tests\Entities;
@@ -85,9 +86,11 @@ class KktEntityTest extends BasicTestCase
public function testNotEnoughMonitorDataException(): void
{
$this->expectException(NotEnoughMonitorDataException::class);
new Kkt((object)[
'fiscalizationDate' => '2021-11-20T10:21:00+00:00',
]);
new Kkt(
(object)[
'fiscalizationDate' => '2021-11-20T10:21:00+00:00',
]
);
}
/**
@@ -104,7 +107,7 @@ class KktEntityTest extends BasicTestCase
// string
$this->assertNotNull($kkt->serialNumber);
$this->assertIsString($kkt->serialNumber);
$this->assertEquals($this->sample_data['serialNumber'], $kkt->serialNumber);
$this->assertSame($this->sample_data['serialNumber'], $kkt->serialNumber);
// int
$this->assertNotNull($kkt->signedDocuments);

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -29,7 +30,7 @@ class MoneyTransferOperatorTest extends BasicTestCase
*/
public function testConstructorWithoutArgs(): void
{
$this->assertEquals('[]', (string)(new MoneyTransferOperator()));
$this->assertSame('[]', (string)(new MoneyTransferOperator()));
}
/**
@@ -52,20 +53,26 @@ class MoneyTransferOperatorTest extends BasicTestCase
public function testConstructorWithArgs(): void
{
$this->assertIsAtolable(new MoneyTransferOperator('some name'), ['name' => 'some name']);
$this->assertIsAtolable(new MoneyTransferOperator(inn: '+fasd3\qe3fs_=nac99013928czc'), ['inn' => '3399013928']);
$this->assertIsAtolable(
new MoneyTransferOperator(inn: '+fasd3\qe3fs_=nac99013928czc'),
['inn' => '3399013928']
);
$this->assertIsAtolable(new MoneyTransferOperator(address: 'London'), ['address' => 'London']);
$this->assertIsAtolable(new MoneyTransferOperator(phones: ['+122997365456']), ['phones' => ['+122997365456']]);
$this->assertIsAtolable(new MoneyTransferOperator(
'some name',
'+fasd3\qe3fs_=nac99013928czc',
'London',
['+122997365456'],
), [
'name' => 'some name',
'inn' => '3399013928',
'address' => 'London',
'phones' => ['+122997365456'],
]);
$this->assertIsAtolable(
new MoneyTransferOperator(
'some name',
'+fasd3\qe3fs_=nac99013928czc',
'London',
['+122997365456'],
),
[
'name' => 'some name',
'inn' => '3399013928',
'address' => 'London',
'phones' => ['+122997365456'],
]
);
}
/**
@@ -145,8 +152,8 @@ class MoneyTransferOperatorTest extends BasicTestCase
*/
public function testValidInn(): void
{
$this->assertEquals('1234567890', (new MoneyTransferOperator())->setInn('1234567890')->getInn());
$this->assertEquals('123456789012', (new MoneyTransferOperator())->setInn('123456789012')->getInn());
$this->assertSame('1234567890', (new MoneyTransferOperator())->setInn('1234567890')->getInn());
$this->assertSame('123456789012', (new MoneyTransferOperator())->setInn('123456789012')->getInn());
}
/**

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -30,7 +31,7 @@ class PayingAgentTest extends BasicTestCase
*/
public function testConstructorWithoutArgs(): void
{
$this->assertEquals('[]', (string)(new PayingAgent()));
$this->assertSame('[]', (string)(new PayingAgent()));
}
/**
@@ -49,13 +50,16 @@ class PayingAgentTest extends BasicTestCase
public function testConstructorWithArgs(): void
{
$operation = Helpers::randomStr();
$this->assertIsAtolable(new PayingAgent(
$operation,
['+122997365456'],
), [
'operation' => $operation,
'phones' => ['+122997365456'],
]);
$this->assertIsAtolable(
new PayingAgent(
$operation,
['+122997365456'],
),
[
'operation' => $operation,
'phones' => ['+122997365456'],
]
);
$this->assertIsAtolable(
new PayingAgent($operation),
['operation' => $operation]

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -10,12 +11,11 @@
namespace AtolOnline\Tests\Entities;
use AtolOnline\{
Constants\Constraints,
Constraints,
Entities\Payment,
Enums\PaymentTypes,
Enums\PaymentType,
Tests\BasicTestCase};
use AtolOnline\Exceptions\{
InvalidEnumValueException,
NegativePaymentSumException,
TooHighPaymentSumException,};
use Exception;
@@ -35,7 +35,6 @@ class PaymentTest extends BasicTestCase
* @covers \AtolOnline\Entities\Payment::getSum
* @covers \AtolOnline\Entities\Payment::jsonSerialize
* @return void
* @throws InvalidEnumValueException
* @throws NegativePaymentSumException
* @throws TooHighPaymentSumException
* @throws Exception
@@ -43,33 +42,14 @@ class PaymentTest extends BasicTestCase
public function testConstructor(): void
{
$this->assertIsAtolable(
new Payment(PaymentTypes::ELECTRON, 123.456789),
new Payment(PaymentType::ELECTRON, 123.456789),
[
'type' => PaymentTypes::ELECTRON,
'type' => PaymentType::ELECTRON,
'sum' => 123.46,
]
);
}
/**
* Тестирует исключение при некорректном типе
*
* @covers \AtolOnline\Entities\Payment
* @covers \AtolOnline\Entities\Payment::setType
* @covers \AtolOnline\Enums\PaymentTypes::isValid
* @covers \AtolOnline\Exceptions\InvalidEnumValueException
* @return void
* @throws InvalidEnumValueException
* @throws NegativePaymentSumException
* @throws TooHighPaymentSumException
*/
public function testInvalidEnumValueException(): void
{
$this->expectException(InvalidEnumValueException::class);
$this->expectExceptionMessage('Некорректное значение AtolOnline\Enums\PaymentTypes::123');
new Payment(123, 123.456789);
}
/**
* Тестирует исключение при слишком большой сумме
*
@@ -77,13 +57,12 @@ class PaymentTest extends BasicTestCase
* @covers \AtolOnline\Entities\Payment::setSum
* @covers \AtolOnline\Exceptions\TooHighPaymentSumException
* @return void
* @throws InvalidEnumValueException
* @throws NegativePaymentSumException
*/
public function testTooHighPaymentSumException(): void
{
$this->expectException(TooHighPaymentSumException::class);
new Payment(PaymentTypes::ELECTRON, Constraints::MAX_COUNT_PAYMENT_SUM + 1);
new Payment(PaymentType::ELECTRON, Constraints::MAX_COUNT_PAYMENT_SUM + 1);
}
/**
@@ -93,13 +72,12 @@ class PaymentTest extends BasicTestCase
* @covers \AtolOnline\Entities\Payment::setSum
* @covers \AtolOnline\Exceptions\NegativePaymentSumException
* @return void
* @throws InvalidEnumValueException
* @throws NegativePaymentSumException
* @throws TooHighPaymentSumException
*/
public function testNegativePaymentSumException(): void
{
$this->expectException(NegativePaymentSumException::class);
new Payment(PaymentTypes::ELECTRON, -1);
new Payment(PaymentType::ELECTRON, -1);
}
}

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -10,7 +11,7 @@
namespace AtolOnline\Tests\Entities;
use AtolOnline\{
Constants\Constraints,
Constraints,
Helpers,
Tests\BasicTestCase};
use AtolOnline\Collections\{
@@ -30,8 +31,8 @@ use AtolOnline\Entities\{
Supplier,
Vat,};
use AtolOnline\Enums\{
AgentTypes,
SnoTypes,};
AgentType,
SnoType,};
use AtolOnline\Exceptions\{
EmptyItemNameException,
EmptyItemsException,
@@ -120,14 +121,14 @@ class ReceiptTest extends BasicTestCase
public function testAgentInfo(): void
{
$agent_info = new AgentInfo(
AgentTypes::ANOTHER,
AgentType::ANOTHER,
new PayingAgent('test', ['+79518888888']),
new ReceivePaymentsOperator(['+79519999999']),
new MoneyTransferOperator('MTO Name', '9876543210', 'London', ['+79517777777']),
);
$receipt = $this->newReceipt()->setAgentInfo($agent_info);
$this->assertArrayHasKey('agent_info', $receipt->jsonSerialize());
$this->assertEquals($receipt->getAgentInfo()->jsonSerialize(), $receipt->jsonSerialize()['agent_info']);
$this->assertSame($receipt->getAgentInfo()->jsonSerialize(), $receipt->jsonSerialize()['agent_info']);
$this->assertArrayNotHasKey('agent_info', $receipt->setAgentInfo(null)->jsonSerialize());
}
@@ -159,7 +160,7 @@ class ReceiptTest extends BasicTestCase
$supplier = new Supplier('some name', '+fasd3\qe3fs_=nac99013928czc', ['+122997365456']);
$receipt = $this->newReceipt()->setSupplier($supplier);
$this->assertArrayHasKey('supplier_info', $receipt->jsonSerialize());
$this->assertEquals($receipt->getSupplier()->jsonSerialize(), $receipt->jsonSerialize()['supplier_info']);
$this->assertSame($receipt->getSupplier()->jsonSerialize(), $receipt->jsonSerialize()['supplier_info']);
$this->assertArrayNotHasKey('supplier_info', $receipt->setSupplier(null)->jsonSerialize());
}
@@ -181,8 +182,8 @@ class ReceiptTest extends BasicTestCase
{
$this->expectException(EmptyItemsException::class);
new Receipt(
new Client('John Doe', 'john@example.com', '+1/22/99*73s dsdas654 5s6', '+fasd3\qe3fs_=nac99013928czc'),
new Company('company@example.com', SnoTypes::OSN, '1234567890', 'https://example.com'),
new Client('John Doe', '+1/22/99*73s dsdas654 5s6', 'john@example.com', '+fasd3\qe3fs_=nac99013928czc'),
new Company('1234567890', SnoType::OSN, 'https://example.com', 'company@example.com'),
new Items([]),
new Payments($this->generatePaymentObjects())
);
@@ -211,8 +212,8 @@ class ReceiptTest extends BasicTestCase
'Коллекция AtolOnline\Collections\Items должна содержать объекты AtolOnline\Entities\Item'
);
new Receipt(
new Client('John Doe', 'john@example.com', '+1/22/99*73s dsdas654 5s6', '+fasd3\qe3fs_=nac99013928czc'),
new Company('company@example.com', SnoTypes::OSN, '1234567890', 'https://example.com'),
new Client('John Doe', '+1/22/99*73s dsdas654 5s6', 'john@example.com', '+fasd3\qe3fs_=nac99013928czc'),
new Company('1234567890', SnoType::OSN, 'https://example.com', 'company@example.com'),
new Items(['qwerty']),
new Payments($this->generatePaymentObjects())
);
@@ -240,8 +241,8 @@ class ReceiptTest extends BasicTestCase
{
$this->expectException(EmptyPaymentsException::class);
new Receipt(
new Client('John Doe', 'john@example.com', '+1/22/99*73s dsdas654 5s6', '+fasd3\qe3fs_=nac99013928czc'),
new Company('company@example.com', SnoTypes::OSN, '1234567890', 'https://example.com'),
new Client('John Doe', '+1/22/99*73s dsdas654 5s6', 'john@example.com', '+fasd3\qe3fs_=nac99013928czc'),
new Company('1234567890', SnoType::OSN, 'https://example.com', 'company@example.com'),
new Items([new Item('test item', 2, 3)]),
new Payments([])
);
@@ -273,8 +274,8 @@ class ReceiptTest extends BasicTestCase
'Коллекция AtolOnline\Collections\Payments должна содержать объекты AtolOnline\Entities\Payment'
);
(string)new Receipt(
new Client('John Doe', 'john@example.com', '+1/22/99*73s dsdas654 5s6', '+fasd3\qe3fs_=nac99013928czc'),
new Company('company@example.com', SnoTypes::OSN, '1234567890', 'https://example.com'),
new Client('John Doe', '+1/22/99*73s dsdas654 5s6', 'john@example.com', '+fasd3\qe3fs_=nac99013928czc'),
new Company('1234567890', SnoType::OSN, 'https://example.com', 'company@example.com'),
new Items([new Item('test item', 2, 3)]),
new Payments(['qwerty'])
);
@@ -365,11 +366,11 @@ class ReceiptTest extends BasicTestCase
{
$receipt = $this->newReceipt();
$items_total = $receipt->getItems()->pluck('sum')->sum();
$this->assertEquals($items_total, $receipt->getTotal());
$this->assertSame($items_total, $receipt->getTotal());
/** @var Vat $vat */
$receipt->setVats(new Vats($this->generateVatObjects(2)))->getVats()
->each(fn($vat) => $this->assertEquals($items_total, $vat->getSum()));
->each(fn ($vat) => $this->assertSame($items_total, $vat->getSum()));
}
/**
@@ -398,7 +399,7 @@ class ReceiptTest extends BasicTestCase
{
$receipt = $this->newReceipt()->setCashier(Helpers::randomStr());
$this->assertArrayHasKey('cashier', $receipt->jsonSerialize());
$this->assertEquals($receipt->getCashier(), $receipt->jsonSerialize()['cashier']);
$this->assertSame($receipt->getCashier(), $receipt->jsonSerialize()['cashier']);
}
/**
@@ -480,7 +481,7 @@ class ReceiptTest extends BasicTestCase
{
$receipt = $this->newReceipt()->setAddCheckProps(Helpers::randomStr());
$this->assertArrayHasKey('additional_check_props', $receipt->jsonSerialize());
$this->assertEquals($receipt->getAddCheckProps(), $receipt->jsonSerialize()['additional_check_props']);
$this->assertSame($receipt->getAddCheckProps(), $receipt->jsonSerialize()['additional_check_props']);
}
/**
@@ -562,7 +563,7 @@ class ReceiptTest extends BasicTestCase
$aup = new AdditionalUserProps('name', 'value');
$receipt = $this->newReceipt()->setAddUserProps($aup);
$this->assertArrayHasKey('additional_user_props', $receipt->jsonSerialize());
$this->assertEquals(
$this->assertSame(
$receipt->getAddUserProps()->jsonSerialize(),
$receipt->jsonSerialize()['additional_user_props']
);

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -28,7 +29,7 @@ class ReceivePaymentsOperatorTest extends BasicTestCase
*/
public function testConstructorWithoutArgs(): void
{
$this->assertEquals('[]', (string)(new ReceivePaymentsOperator()));
$this->assertSame('[]', (string)(new ReceivePaymentsOperator()));
}
/**

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -29,7 +30,7 @@ class SupplierTest extends BasicTestCase
*/
public function testConstructorWithoutArgs(): void
{
$this->assertEquals('[]', (string)(new Supplier()));
$this->assertSame('[]', (string)(new Supplier()));
}
/**
@@ -52,15 +53,18 @@ class SupplierTest extends BasicTestCase
$this->assertIsAtolable(new Supplier('some name'), ['name' => 'some name']);
$this->assertIsAtolable(new Supplier(inn: '+fasd3\qe3fs_=nac99013928czc'), ['inn' => '3399013928']);
$this->assertIsAtolable(new Supplier(phones: ['+122997365456']), ['phones' => ['+122997365456']]);
$this->assertIsAtolable(new Supplier(
'some name',
'+fasd3\qe3fs_=nac99013928czc',
['+122997365456'],
), [
'name' => 'some name',
'inn' => '3399013928',
'phones' => ['+122997365456'],
]);
$this->assertIsAtolable(
new Supplier(
'some name',
'+fasd3\qe3fs_=nac99013928czc',
['+122997365456'],
),
[
'name' => 'some name',
'inn' => '3399013928',
'phones' => ['+122997365456'],
]
);
}
/**
@@ -140,8 +144,8 @@ class SupplierTest extends BasicTestCase
*/
public function testValidInn(): void
{
$this->assertEquals('1234567890', (new Supplier())->setInn('1234567890')->getInn());
$this->assertEquals('123456789012', (new Supplier())->setInn('123456789012')->getInn());
$this->assertSame('1234567890', (new Supplier())->setInn('1234567890')->getInn());
$this->assertSame('123456789012', (new Supplier())->setInn('123456789012')->getInn());
}
/**

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
*
@@ -11,8 +12,7 @@ namespace AtolOnline\Tests\Entities;
use AtolOnline\{
Entities\Vat,
Enums\VatTypes,
Exceptions\InvalidEnumValueException,
Enums\VatType,
Tests\BasicTestCase};
use Exception;
@@ -29,14 +29,14 @@ class VatTest extends BasicTestCase
public function providerVatsSet(): array
{
return [
[VatTypes::NONE, 0],
[VatTypes::VAT0, 0],
[VatTypes::VAT10, 10],
[VatTypes::VAT18, 18],
[VatTypes::VAT20, 20],
[VatTypes::VAT110, 9.09],
[VatTypes::VAT118, 15.25],
[VatTypes::VAT120, 16.67],
[VatType::NONE, 0],
[VatType::VAT0, 0],
[VatType::VAT10, 10],
[VatType::VAT18, 18],
[VatType::VAT20, 20],
[VatType::VAT110, 9.09],
[VatType::VAT118, 15.25],
[VatType::VAT120, 16.67],
];
}
@@ -48,20 +48,21 @@ class VatTest extends BasicTestCase
public function providerVatsAdd(): array
{
return [
[VatTypes::VAT10, 12, 10],
[VatTypes::VAT18, 21.6, 18],
[VatTypes::VAT20, 24, 20],
[VatTypes::VAT110, 10.91, 9.09],
[VatTypes::VAT118, 18.31, 15.25],
[VatTypes::VAT120, 20, 16.67],
[VatType::VAT10, 12, 10],
[VatType::VAT18, 21.6, 18],
[VatType::VAT20, 24, 20],
[VatType::VAT110, 10.91, 9.09],
[VatType::VAT118, 18.31, 15.25],
[VatType::VAT120, 20, 16.67],
];
}
/**
* Тестирует конструктор без передачи значений и приведение к json
*
* @param string $type Тип НДС
* @param VatType $type Тип НДС
* @param float $sum Исходная сумма
* @throws Exception
* @dataProvider providerVatsSet
* @covers \AtolOnline\Entities\Vat
* @covers \AtolOnline\Entities\Vat::setType
@@ -70,36 +71,33 @@ class VatTest extends BasicTestCase
* @covers \AtolOnline\Entities\Vat::getSum
* @covers \AtolOnline\Entities\Vat::getCalculated
* @covers \AtolOnline\Entities\Vat::jsonSerialize
* @throws InvalidEnumValueException
* @throws Exception
*/
public function testConstructor(string $type, float $sum): void
public function testConstructor(VatType $type, float $sum): void
{
$vat = new Vat($type, $sum);
$this->assertIsAtolable($vat, [
'type' => $vat->getType(),
'sum' => $vat->getCalculated(),
]);
$this->assertEquals($type, $vat->getType());
$this->assertEquals($sum, $vat->getSum());
$this->assertSame($type, $vat->getType());
$this->assertSame($sum, $vat->getSum());
}
/**
* Тестирует расчёт суммы НДС от суммы 100+20р и 100-20р
*
* @dataProvider providerVatsAdd
* @param string $type Тип НДС
* @param VatType $type Тип НДС
* @param float $after_plus Результат после +20р
* @param float $after_minus Результат после -20р
* @covers \AtolOnline\Entities\Vat::addSum
* @covers \AtolOnline\Entities\Vat::getCalculated
* @throws InvalidEnumValueException
*/
public function testVatAdd(string $type, float $after_plus, float $after_minus)
public function testVatAdd(VatType $type, float $after_plus, float $after_minus)
{
$vat = (new Vat($type, 100))->addSum(20); // 120р
$this->assertEquals($after_plus, $vat->getCalculated());
$this->assertSame($after_plus, $vat->getCalculated());
$vat->addSum(-20); // 100р
$this->assertEquals($after_minus, $vat->getCalculated());
$this->assertSame($after_minus, $vat->getCalculated());
}
}