2020-01-11 06:30:25 +00:00
|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Copyright (c) Антон Аксенов (aka Anthony Axenov)
|
|
|
|
|
*
|
|
|
|
|
* This code is licensed under MIT.
|
|
|
|
|
* Этот код распространяется по лицензии MIT.
|
|
|
|
|
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
use AtolOnline\{Constants\SnoTypes,
|
|
|
|
|
Entities\Company,
|
|
|
|
|
Exceptions\AtolEmailTooLongException,
|
|
|
|
|
Exceptions\AtolEmailValidateException,
|
|
|
|
|
Exceptions\AtolInnWrongLengthException,
|
|
|
|
|
Exceptions\AtolPaymentAddressTooLongException
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class CompanyTest
|
|
|
|
|
*/
|
|
|
|
|
class CompanyTest extends BasicTestCase
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует установку параметров через конструктор
|
|
|
|
|
*/
|
|
|
|
|
public function testConstructor()
|
|
|
|
|
{
|
|
|
|
|
$company = new Company(
|
|
|
|
|
SnoTypes::OSN,
|
|
|
|
|
'5544332219',
|
|
|
|
|
'https://v4.online.atol.ru',
|
|
|
|
|
'company@example.com'
|
|
|
|
|
);
|
|
|
|
|
$this->checkAtolEntity($company);
|
|
|
|
|
$this->assertEquals(SnoTypes::OSN, $company->getSno());
|
|
|
|
|
$this->assertEquals('5544332219', $company->getInn());
|
|
|
|
|
$this->assertEquals('https://v4.online.atol.ru', $company->getPaymentAddress());
|
|
|
|
|
$this->assertEquals('company@example.com', $company->getEmail());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение о некорректной длине ИНН
|
|
|
|
|
*
|
2020-05-29 14:24:15 +00:00
|
|
|
|
* @throws \AtolOnline\Exceptions\AtolInnWrongLengthException
|
2020-01-11 06:30:25 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testAtolInnWrongLengthException()
|
|
|
|
|
{
|
|
|
|
|
$company = new Company();
|
|
|
|
|
$this->expectException(AtolInnWrongLengthException::class);
|
|
|
|
|
$company->setInn('321');
|
|
|
|
|
$company->setInn('1234567890123');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение о слишком длинном платёжном адресе
|
|
|
|
|
*
|
2020-05-29 14:24:15 +00:00
|
|
|
|
* @throws \AtolOnline\Exceptions\AtolPaymentAddressTooLongException
|
2020-01-11 06:30:25 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testAtolPaymentAddressTooLongException()
|
|
|
|
|
{
|
|
|
|
|
$company = new Company();
|
|
|
|
|
$this->expectException(AtolPaymentAddressTooLongException::class);
|
2020-05-29 14:24:15 +00:00
|
|
|
|
$company->setPaymentAddress(self::randomString(257));
|
2020-01-11 06:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение о слишком длинной почте
|
|
|
|
|
*
|
2020-05-29 14:24:15 +00:00
|
|
|
|
* @throws \AtolOnline\Exceptions\AtolEmailTooLongException
|
|
|
|
|
* @throws \AtolOnline\Exceptions\AtolEmailValidateException
|
2020-01-11 06:30:25 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testAtolEmailTooLongException()
|
|
|
|
|
{
|
|
|
|
|
$company = new Company();
|
|
|
|
|
$this->expectException(AtolEmailTooLongException::class);
|
2020-05-29 14:24:15 +00:00
|
|
|
|
$company->setEmail(self::randomString(65));
|
2020-01-11 06:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Тестирует исключение о некорректной почте
|
|
|
|
|
*
|
2020-05-29 14:24:15 +00:00
|
|
|
|
* @throws \AtolOnline\Exceptions\AtolEmailTooLongException
|
|
|
|
|
* @throws \AtolOnline\Exceptions\AtolEmailValidateException
|
2020-01-11 06:30:25 +00:00
|
|
|
|
*/
|
|
|
|
|
public function testAtolEmailValidateException()
|
|
|
|
|
{
|
|
|
|
|
$company = new Company();
|
|
|
|
|
$this->expectException(AtolEmailValidateException::class);
|
2020-05-29 14:24:15 +00:00
|
|
|
|
$company->setEmail(self::randomString(15));
|
2020-01-11 06:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|