2021-11-18 04:24:30 +00:00
|
|
|
|
<?php
|
2022-12-14 16:19:55 +00:00
|
|
|
|
|
2021-11-18 04:24:30 +00:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
|
|
|
|
|
*
|
|
|
|
|
* This code is licensed under MIT.
|
|
|
|
|
* Этот код распространяется по лицензии MIT.
|
|
|
|
|
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
|
|
|
|
|
*/
|
|
|
|
|
|
2021-11-23 17:30:54 +00:00
|
|
|
|
namespace AtolOnline\Tests\Entities;
|
2021-11-18 04:24:30 +00:00
|
|
|
|
|
|
|
|
|
use AtolOnline\{
|
|
|
|
|
Entities\Company,
|
2022-12-14 16:19:55 +00:00
|
|
|
|
Enums\SnoType,
|
2021-11-18 04:24:30 +00:00
|
|
|
|
Exceptions\InvalidEmailException,
|
|
|
|
|
Exceptions\InvalidInnLengthException,
|
|
|
|
|
Exceptions\InvalidPaymentAddressException,
|
|
|
|
|
Exceptions\TooLongEmailException,
|
|
|
|
|
Exceptions\TooLongPaymentAddressException,
|
2021-11-23 17:30:54 +00:00
|
|
|
|
Helpers,
|
2021-12-01 12:11:08 +00:00
|
|
|
|
Tests\BasicTestCase};
|
2021-12-06 08:14:19 +00:00
|
|
|
|
use Exception;
|
2021-11-18 04:24:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-12-01 12:11:08 +00:00
|
|
|
|
* Набор тестов для проверки работы класса продавца
|
2021-11-18 04:24:30 +00:00
|
|
|
|
*/
|
|
|
|
|
class CompanyTest extends BasicTestCase
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует конструктор с сеттерами и приведение к json с геттерами
|
|
|
|
|
*
|
|
|
|
|
* @covers \AtolOnline\Entities\Company
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::jsonSerialize
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::setEmail
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::setSno
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::setInn
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::setPaymentAddress
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::getEmail
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::getSno
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::getInn
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::getPaymentAddress
|
2021-12-06 08:14:19 +00:00
|
|
|
|
* @throws Exception
|
2021-11-18 04:24:30 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testConstructor()
|
|
|
|
|
{
|
2022-12-14 16:19:55 +00:00
|
|
|
|
$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,
|
|
|
|
|
]
|
|
|
|
|
);
|
2021-11-18 04:24:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение о слишком длинном email
|
|
|
|
|
*
|
|
|
|
|
* @covers \AtolOnline\Entities\Company
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::setEmail
|
|
|
|
|
* @covers \AtolOnline\Exceptions\TooLongEmailException
|
2021-12-06 08:14:19 +00:00
|
|
|
|
* @throws InvalidEmailException
|
|
|
|
|
* @throws InvalidInnLengthException
|
|
|
|
|
* @throws InvalidPaymentAddressException
|
|
|
|
|
* @throws TooLongEmailException
|
|
|
|
|
* @throws TooLongPaymentAddressException
|
2021-11-18 04:24:30 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testEmailTooLongException()
|
|
|
|
|
{
|
|
|
|
|
$this->expectException(TooLongEmailException::class);
|
2022-12-14 16:19:55 +00:00
|
|
|
|
new Company('1234567890', SnoType::OSN, 'https://example.com', Helpers::randomStr(65));
|
2021-11-18 04:24:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение о невалидном email
|
|
|
|
|
*
|
|
|
|
|
* @covers \AtolOnline\Entities\Company
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::setEmail
|
|
|
|
|
* @covers \AtolOnline\Exceptions\InvalidEmailException
|
|
|
|
|
*/
|
|
|
|
|
public function testInvalidEmailException()
|
|
|
|
|
{
|
|
|
|
|
$this->expectException(InvalidEmailException::class);
|
2022-12-14 16:19:55 +00:00
|
|
|
|
new Company('1234567890', SnoType::OSN, 'https://example.com', 'company@examas%^*.com');
|
2021-11-18 04:24:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение о слишком длинном платёжном адресе
|
|
|
|
|
*
|
|
|
|
|
* @covers \AtolOnline\Entities\Company
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::setInn
|
|
|
|
|
* @covers \AtolOnline\Exceptions\InvalidInnLengthException
|
2021-12-06 08:14:19 +00:00
|
|
|
|
* @throws InvalidEmailException
|
|
|
|
|
* @throws InvalidInnLengthException
|
|
|
|
|
* @throws InvalidPaymentAddressException
|
|
|
|
|
* @throws TooLongEmailException
|
|
|
|
|
* @throws TooLongPaymentAddressException
|
2021-11-18 04:24:30 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testInvalidInnLengthException()
|
|
|
|
|
{
|
|
|
|
|
$this->expectException(InvalidInnLengthException::class);
|
2022-12-14 16:19:55 +00:00
|
|
|
|
new Company(Helpers::randomStr(13), SnoType::OSN, 'https://example.com', 'company@example.com');
|
2021-11-18 04:24:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение о слишком длинном платёжном адресе
|
|
|
|
|
*
|
|
|
|
|
* @covers \AtolOnline\Entities\Company
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::setPaymentAddress
|
|
|
|
|
* @covers \AtolOnline\Exceptions\TooLongPaymentAddressException
|
2021-12-06 08:14:19 +00:00
|
|
|
|
* @throws InvalidEmailException
|
|
|
|
|
* @throws InvalidInnLengthException
|
|
|
|
|
* @throws InvalidPaymentAddressException
|
|
|
|
|
* @throws TooLongEmailException
|
|
|
|
|
* @throws TooLongPaymentAddressException
|
2021-11-18 04:24:30 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testTooLongPaymentAddressException()
|
|
|
|
|
{
|
|
|
|
|
$this->expectException(TooLongPaymentAddressException::class);
|
2022-12-14 16:19:55 +00:00
|
|
|
|
new Company('1234567890', SnoType::OSN, Helpers::randomStr(257), 'company@example.com');
|
2021-11-18 04:24:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение о невалидном платёжном адресе
|
|
|
|
|
*
|
|
|
|
|
* @covers \AtolOnline\Entities\Company
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::setPaymentAddress
|
|
|
|
|
* @covers \AtolOnline\Exceptions\InvalidPaymentAddressException
|
|
|
|
|
*/
|
|
|
|
|
public function testInvalidPaymentAddressException()
|
|
|
|
|
{
|
|
|
|
|
$this->expectException(InvalidPaymentAddressException::class);
|
2022-12-14 16:19:55 +00:00
|
|
|
|
new Company('1234567890', SnoType::OSN, '', 'company@example.com');
|
2021-11-18 04:24:30 +00:00
|
|
|
|
}
|
2021-11-23 17:30:54 +00:00
|
|
|
|
}
|