2021-11-18 04:24:30 +00:00
|
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
* 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,
|
2021-11-20 15:38:19 +00:00
|
|
|
|
Enums\SnoTypes,
|
2021-11-18 04:24:30 +00:00
|
|
|
|
Exceptions\InvalidEmailException,
|
2021-11-22 06:51:10 +00:00
|
|
|
|
Exceptions\InvalidEnumValueException,
|
2021-11-18 04:24:30 +00:00
|
|
|
|
Exceptions\InvalidInnLengthException,
|
|
|
|
|
Exceptions\InvalidPaymentAddressException,
|
|
|
|
|
Exceptions\TooLongEmailException,
|
|
|
|
|
Exceptions\TooLongPaymentAddressException,
|
2021-11-23 17:30:54 +00:00
|
|
|
|
Helpers,
|
|
|
|
|
Tests\BasicTestCase
|
|
|
|
|
};
|
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
|
|
|
|
|
*/
|
|
|
|
|
public function testConstructor()
|
|
|
|
|
{
|
|
|
|
|
$this->assertAtolable(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,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение о слишком длинном email
|
|
|
|
|
*
|
|
|
|
|
* @covers \AtolOnline\Entities\Company
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::setEmail
|
|
|
|
|
* @covers \AtolOnline\Exceptions\TooLongEmailException
|
|
|
|
|
*/
|
|
|
|
|
public function testEmailTooLongException()
|
|
|
|
|
{
|
|
|
|
|
$this->expectException(TooLongEmailException::class);
|
|
|
|
|
new Company(Helpers::randomStr(65), SnoTypes::OSN, '1234567890', 'https://example.com');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение о невалидном email
|
|
|
|
|
*
|
|
|
|
|
* @covers \AtolOnline\Entities\Company
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::setEmail
|
|
|
|
|
* @covers \AtolOnline\Exceptions\InvalidEmailException
|
|
|
|
|
*/
|
|
|
|
|
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
|
2021-11-22 06:51:10 +00:00
|
|
|
|
* @covers \AtolOnline\Exceptions\InvalidEnumValueException
|
2021-11-18 04:24:30 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testInvalidSnoException()
|
|
|
|
|
{
|
2021-11-22 06:51:10 +00:00
|
|
|
|
$this->expectException(InvalidEnumValueException::class);
|
2021-11-18 04:24:30 +00:00
|
|
|
|
new Company('company@example.com', 'test', '1234567890', 'https://example.com');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение о слишком длинном платёжном адресе
|
|
|
|
|
*
|
|
|
|
|
* @covers \AtolOnline\Entities\Company
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::setInn
|
|
|
|
|
* @covers \AtolOnline\Exceptions\InvalidInnLengthException
|
|
|
|
|
*/
|
|
|
|
|
public function testInvalidInnLengthException()
|
|
|
|
|
{
|
|
|
|
|
$this->expectException(InvalidInnLengthException::class);
|
|
|
|
|
new Company('company@example.com', SnoTypes::OSN, Helpers::randomStr(13), 'https://example.com');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение о слишком длинном платёжном адресе
|
|
|
|
|
*
|
|
|
|
|
* @covers \AtolOnline\Entities\Company
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::setPaymentAddress
|
|
|
|
|
* @covers \AtolOnline\Exceptions\TooLongPaymentAddressException
|
|
|
|
|
*/
|
|
|
|
|
public function testTooLongPaymentAddressException()
|
|
|
|
|
{
|
|
|
|
|
$this->expectException(TooLongPaymentAddressException::class);
|
|
|
|
|
new Company('company@example.com', SnoTypes::OSN, '1234567890', Helpers::randomStr(257));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение о невалидном платёжном адресе
|
|
|
|
|
*
|
|
|
|
|
* @covers \AtolOnline\Entities\Company
|
|
|
|
|
* @covers \AtolOnline\Entities\Company::setPaymentAddress
|
|
|
|
|
* @covers \AtolOnline\Exceptions\InvalidPaymentAddressException
|
|
|
|
|
*/
|
|
|
|
|
public function testInvalidPaymentAddressException()
|
|
|
|
|
{
|
|
|
|
|
$this->expectException(InvalidPaymentAddressException::class);
|
|
|
|
|
new Company('company@example.com', SnoTypes::OSN, '1234567890', '');
|
|
|
|
|
}
|
2021-11-23 17:30:54 +00:00
|
|
|
|
}
|