Небольшой рефакторинг по тестам
- `BasicTestCase::assertAtolable() => assertIsAtolable()` - генерация тестовых объектов `Vat`, `Payment` и `Item` вынесены в `BasicTestCase`
This commit is contained in:
@@ -38,7 +38,7 @@ class AdditionalUserPropsTest extends BasicTestCase
|
||||
*/
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertAtolable(
|
||||
$this->assertIsAtolable(
|
||||
new AdditionalUserProps('name', 'value'),
|
||||
[
|
||||
'name' => 'name',
|
||||
|
||||
@@ -36,7 +36,7 @@ class AgentInfoTest extends BasicTestCase
|
||||
*/
|
||||
public function testConstructorWithoutArgs(): void
|
||||
{
|
||||
$this->assertAtolable(new AgentInfo(), []);
|
||||
$this->assertIsAtolable(new AgentInfo(), []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,20 +63,20 @@ class AgentInfoTest extends BasicTestCase
|
||||
*/
|
||||
public function testConstructorWithArgs(): void
|
||||
{
|
||||
$this->assertAtolable(new AgentInfo(null), []);
|
||||
$this->assertAtolable(new AgentInfo(AgentTypes::ANOTHER), ['type' => AgentTypes::ANOTHER]);
|
||||
$this->assertAtolable(new AgentInfo(pagent: new PayingAgent()), []);
|
||||
$this->assertAtolable(new AgentInfo(mt_operator: new MoneyTransferOperator()), []);
|
||||
$this->assertAtolable(new AgentInfo(rp_operator: new ReceivePaymentsOperator()), []);
|
||||
$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->assertAtolable(new AgentInfo(
|
||||
$this->assertIsAtolable(new AgentInfo(
|
||||
AgentTypes::ANOTHER,
|
||||
new PayingAgent(),
|
||||
new ReceivePaymentsOperator(),
|
||||
new MoneyTransferOperator(),
|
||||
), ['type' => AgentTypes::ANOTHER]);
|
||||
|
||||
$this->assertAtolable(new AgentInfo(
|
||||
$this->assertIsAtolable(new AgentInfo(
|
||||
AgentTypes::ANOTHER,
|
||||
new PayingAgent('test', ['+79518888888']),
|
||||
new ReceivePaymentsOperator(['+79519999999']),
|
||||
|
||||
@@ -34,7 +34,7 @@ class ClientTest extends BasicTestCase
|
||||
*/
|
||||
public function testConstructorWithoutArgs(): void
|
||||
{
|
||||
$this->assertAtolable(new Client(), []);
|
||||
$this->assertIsAtolable(new Client(), []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,11 +54,11 @@ class ClientTest extends BasicTestCase
|
||||
*/
|
||||
public function testConstructorWithArgs(): void
|
||||
{
|
||||
$this->assertAtolable(new Client('John Doe'), ['name' => 'John Doe']);
|
||||
$this->assertAtolable(new Client(email: 'john@example.com'), ['email' => 'john@example.com']);
|
||||
$this->assertAtolable(new Client(phone: '+1/22/99*73s dsdas654 5s6'), ['phone' => '+122997365456']);
|
||||
$this->assertAtolable(new Client(inn: '+fasd3\qe3fs_=nac99013928czc'), ['inn' => '3399013928']);
|
||||
$this->assertAtolable(new Client(
|
||||
$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(inn: '+fasd3\qe3fs_=nac99013928czc'), ['inn' => '3399013928']);
|
||||
$this->assertIsAtolable(new Client(
|
||||
'John Doe',
|
||||
'john@example.com',
|
||||
'+1/22/99*73s dsdas654 5s6', // +122997365456
|
||||
|
||||
@@ -44,7 +44,7 @@ class CompanyTest extends BasicTestCase
|
||||
*/
|
||||
public function testConstructor()
|
||||
{
|
||||
$this->assertAtolable(new Company(
|
||||
$this->assertIsAtolable(new Company(
|
||||
$email = 'company@example.com',
|
||||
$sno = SnoTypes::OSN,
|
||||
$inn = '1234567890',
|
||||
|
||||
@@ -43,7 +43,7 @@ class CorrectionInfoTest extends BasicTestCase
|
||||
*/
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertAtolable(
|
||||
$this->assertIsAtolable(
|
||||
new CorrectionInfo(CorrectionTypes::SELF, '01.01.2021', $number = Helpers::randomStr()),
|
||||
[
|
||||
'type' => CorrectionTypes::SELF,
|
||||
|
||||
@@ -71,7 +71,7 @@ class ItemTest extends BasicTestCase
|
||||
*/
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertAtolable(
|
||||
$this->assertIsAtolable(
|
||||
new Item('test item', 2, 3),
|
||||
[
|
||||
'name' => 'test item',
|
||||
@@ -277,7 +277,7 @@ class ItemTest extends BasicTestCase
|
||||
PaymentObjects::COMMODITY,
|
||||
$item->setPaymentObject(PaymentObjects::COMMODITY)->getPaymentObject()
|
||||
);
|
||||
$this->assertAtolable($item, [
|
||||
$this->assertIsAtolable($item, [
|
||||
'name' => 'test item',
|
||||
'price' => 2,
|
||||
'quantity' => 3,
|
||||
@@ -349,7 +349,7 @@ class ItemTest extends BasicTestCase
|
||||
$this->assertIsSameClass(Vat::class, $item->getVat());
|
||||
$this->assertEquals(VatTypes::VAT20, $item->getVat()->getType());
|
||||
$this->assertEquals($item->getSum(), $item->getVat()->getSum());
|
||||
$this->assertAtolable($item, [
|
||||
$this->assertIsAtolable($item, [
|
||||
'name' => 'test item',
|
||||
'price' => 2,
|
||||
'quantity' => 3,
|
||||
@@ -384,7 +384,7 @@ class ItemTest extends BasicTestCase
|
||||
$this->assertIsSameClass(Vat::class, $item->getVat());
|
||||
$this->assertEquals(VatTypes::VAT20, $item->getVat()->getType());
|
||||
$this->assertEquals($item->getSum(), $item->getVat()->getSum());
|
||||
$this->assertAtolable($item, [
|
||||
$this->assertIsAtolable($item, [
|
||||
'name' => 'test item',
|
||||
'price' => 2,
|
||||
'quantity' => 3,
|
||||
@@ -472,7 +472,7 @@ class ItemTest extends BasicTestCase
|
||||
);
|
||||
$item = (new Item('test item', 2, 3))->setSupplier($supplier);
|
||||
$this->assertEquals($supplier, $item->getSupplier());
|
||||
$this->assertAtolable($item, [
|
||||
$this->assertIsAtolable($item, [
|
||||
'name' => 'test item',
|
||||
'price' => 2,
|
||||
'quantity' => 3,
|
||||
@@ -502,7 +502,7 @@ class ItemTest extends BasicTestCase
|
||||
*/
|
||||
public function testValidUserdata(): void
|
||||
{
|
||||
$this->assertAtolable(
|
||||
$this->assertIsAtolable(
|
||||
(new Item('test item', 2, 3))
|
||||
->setUserData($user_data = Helpers::randomStr(Constraints::MAX_LENGTH_USER_DATA)),
|
||||
[
|
||||
@@ -572,7 +572,7 @@ class ItemTest extends BasicTestCase
|
||||
*/
|
||||
public function testCountryCode(): void
|
||||
{
|
||||
$this->assertAtolable(
|
||||
$this->assertIsAtolable(
|
||||
(new Item('test item', 2, 3))->setCountryCode('800'),
|
||||
[
|
||||
'name' => 'test item',
|
||||
@@ -620,7 +620,7 @@ class ItemTest extends BasicTestCase
|
||||
*/
|
||||
public function testValidDeclarationNumber(): void
|
||||
{
|
||||
$this->assertAtolable(
|
||||
$this->assertIsAtolable(
|
||||
(new Item('test item', 2, 3))
|
||||
->setDeclarationNumber($code = Helpers::randomStr()),
|
||||
[
|
||||
@@ -691,7 +691,7 @@ class ItemTest extends BasicTestCase
|
||||
*/
|
||||
public function testExcise(): void
|
||||
{
|
||||
$this->assertAtolable(
|
||||
$this->assertIsAtolable(
|
||||
(new Item('test item', 2, 3))->setExcise(1),
|
||||
[
|
||||
'name' => 'test item',
|
||||
@@ -750,7 +750,7 @@ class ItemTest extends BasicTestCase
|
||||
$decoded = hex2bin(str_replace(' ', '', $item->getCodeHex()));
|
||||
$this->assertEquals($decoded, $item->getCode());
|
||||
|
||||
$this->assertAtolable($item, [
|
||||
$this->assertIsAtolable($item, [
|
||||
'name' => 'test item',
|
||||
'price' => 2,
|
||||
'quantity' => 3,
|
||||
|
||||
@@ -57,7 +57,7 @@ class KktEntityTest extends BasicTestCase
|
||||
{
|
||||
$kkt = new Kkt((object)$this->sample_data);
|
||||
$this->assertIsSameClass(Kkt::class, $kkt);
|
||||
$this->assertAtolable($kkt);
|
||||
$this->assertIsAtolable($kkt);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,11 +51,11 @@ class MoneyTransferOperatorTest extends BasicTestCase
|
||||
*/
|
||||
public function testConstructorWithArgs(): void
|
||||
{
|
||||
$this->assertAtolable(new MoneyTransferOperator('some name'), ['name' => 'some name']);
|
||||
$this->assertAtolable(new MoneyTransferOperator(inn: '+fasd3\qe3fs_=nac99013928czc'), ['inn' => '3399013928']);
|
||||
$this->assertAtolable(new MoneyTransferOperator(address: 'London'), ['address' => 'London']);
|
||||
$this->assertAtolable(new MoneyTransferOperator(phones: ['+122997365456']), ['phones' => ['+122997365456']]);
|
||||
$this->assertAtolable(new MoneyTransferOperator(
|
||||
$this->assertIsAtolable(new MoneyTransferOperator('some name'), ['name' => 'some name']);
|
||||
$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',
|
||||
|
||||
@@ -49,18 +49,18 @@ class PayingAgentTest extends BasicTestCase
|
||||
public function testConstructorWithArgs(): void
|
||||
{
|
||||
$operation = Helpers::randomStr();
|
||||
$this->assertAtolable(new PayingAgent(
|
||||
$this->assertIsAtolable(new PayingAgent(
|
||||
$operation,
|
||||
['+122997365456'],
|
||||
), [
|
||||
'operation' => $operation,
|
||||
'phones' => ['+122997365456'],
|
||||
]);
|
||||
$this->assertAtolable(
|
||||
$this->assertIsAtolable(
|
||||
new PayingAgent($operation),
|
||||
['operation' => $operation]
|
||||
);
|
||||
$this->assertAtolable(
|
||||
$this->assertIsAtolable(
|
||||
new PayingAgent(phones: ['+122997365456']),
|
||||
['phones' => ['+122997365456']]
|
||||
);
|
||||
|
||||
@@ -42,7 +42,7 @@ class PaymentTest extends BasicTestCase
|
||||
*/
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->assertAtolable(
|
||||
$this->assertIsAtolable(
|
||||
new Payment(PaymentTypes::ELECTRON, 123.456789),
|
||||
[
|
||||
'type' => PaymentTypes::ELECTRON,
|
||||
|
||||
@@ -43,7 +43,7 @@ class ReceivePaymentsOperatorTest extends BasicTestCase
|
||||
*/
|
||||
public function testConstructorWithArgs(): void
|
||||
{
|
||||
$this->assertAtolable(new ReceivePaymentsOperator(['+122997365456']), ['phones' => ['+122997365456']]);
|
||||
$this->assertIsAtolable(new ReceivePaymentsOperator(['+122997365456']), ['phones' => ['+122997365456']]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,10 +49,10 @@ class SupplierTest extends BasicTestCase
|
||||
*/
|
||||
public function testConstructorWithArgs(): void
|
||||
{
|
||||
$this->assertAtolable(new Supplier('some name'), ['name' => 'some name']);
|
||||
$this->assertAtolable(new Supplier(inn: '+fasd3\qe3fs_=nac99013928czc'), ['inn' => '3399013928']);
|
||||
$this->assertAtolable(new Supplier(phones: ['+122997365456']), ['phones' => ['+122997365456']]);
|
||||
$this->assertAtolable(new Supplier(
|
||||
$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'],
|
||||
|
||||
@@ -76,7 +76,7 @@ class VatTest extends BasicTestCase
|
||||
public function testConstructor(string $type, float $sum): void
|
||||
{
|
||||
$vat = new Vat($type, $sum);
|
||||
$this->assertAtolable($vat, [
|
||||
$this->assertIsAtolable($vat, [
|
||||
'type' => $vat->getType(),
|
||||
'sum' => $vat->getCalculated(),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user