From 8b79b2be51bf3486c1f15ac15b8998ddc4d7e362 Mon Sep 17 00:00:00 2001 From: AnthonyAxenov Date: Wed, 24 Nov 2021 18:55:53 +0800 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=BE=D1=84=D0=B8?= =?UTF-8?q?=D0=BA=D1=81=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `Ffd105Tags::CLIENT_CONTACTS` => `CLIENT_PHONE_EMAIL` + мелочи по `Client`, `ClientTest` и `PayingAgentTest` --- src/Entities/Client.php | 24 ++++++------------- src/Exceptions/EmptyEmailException.php | 2 +- src/Exceptions/InvalidEmailException.php | 2 +- src/Exceptions/InvalidPhoneException.php | 2 +- .../TooLongClientContactException.php | 2 +- src/Exceptions/TooLongEmailException.php | 2 +- .../AtolOnline/Tests/Entities/ClientTest.php | 9 +------ .../Tests/Entities/PayingAgentTest.php | 7 +++--- 8 files changed, 17 insertions(+), 33 deletions(-) diff --git a/src/Entities/Client.php b/src/Entities/Client.php index ce5f41b..3d8376e 100644 --- a/src/Entities/Client.php +++ b/src/Entities/Client.php @@ -17,8 +17,7 @@ use AtolOnline\{ Exceptions\InvalidInnLengthException, Exceptions\TooLongClientContactException, Exceptions\TooLongClientNameException, - Exceptions\TooLongEmailException -}; + Exceptions\TooLongEmailException}; /** * Класс Client, описывающий сущность покупателя @@ -28,22 +27,22 @@ use AtolOnline\{ class Client extends Entity { /** - * @var string|null Наименование. Тег ФФД - 1227. + * @var string|null Наименование (1227) */ protected ?string $name = null; /** - * @var string|null Email. Тег ФФД - 1008. + * @var string|null Email (1008) */ protected ?string $email = null; /** - * @var string|null Телефон покупателя. Тег ФФД - 1008. + * @var string|null Телефон (1008) */ protected ?string $phone = null; /** - * @var string|null ИНН. Тег ФФД - 1228. + * @var string|null ИНН (1228) */ protected ?string $inn = null; @@ -52,7 +51,7 @@ class Client extends Entity * * @param string|null $name Наименование (1227) * @param string|null $phone Email (1008) - * @param string|null $email Телефон покупателя (1008) + * @param string|null $email Телефон (1008) * @param string|null $inn ИНН (1228) * @throws TooLongClientNameException * @throws TooLongClientContactException @@ -65,8 +64,7 @@ class Client extends Entity ?string $email = null, ?string $phone = null, ?string $inn = null - ) - { + ) { !is_null($name) && $this->setName($name); !is_null($email) && $this->setEmail($email); !is_null($phone) && $this->setPhone($phone); @@ -76,8 +74,6 @@ class Client extends Entity /** * Возвращает наименование покупателя * - * Тег ФФД - 1227 - * * @return string|null */ public function getName(): ?string @@ -88,8 +84,6 @@ class Client extends Entity /** * Устанавливает наименование покупателя * - * Тег ФФД - 1227 - * * @todo улучшить валидацию по Constraints::PATTERN_PHONE * @param string|null $name * @return $this @@ -142,8 +136,6 @@ class Client extends Entity /** * Возвращает установленный телефон * - * Тег ФФД - 1008 - * * @return string|null */ public function getPhone(): ?string @@ -154,8 +146,6 @@ class Client extends Entity /** * Устанавливает телефон * - * Тег ФФД - 1008 - * * @param string|null $phone Номер телефона * @return $this * @throws TooLongClientContactException diff --git a/src/Exceptions/EmptyEmailException.php b/src/Exceptions/EmptyEmailException.php index 1993027..ebe842e 100644 --- a/src/Exceptions/EmptyEmailException.php +++ b/src/Exceptions/EmptyEmailException.php @@ -22,7 +22,7 @@ class EmptyEmailException extends AtolException { protected $message = 'Email не может быть пустым'; protected array $ffd_tags = [ - Ffd105Tags::CLIENT_CONTACT, + Ffd105Tags::CLIENT_PHONE_EMAIL, Ffd105Tags::COMPANY_EMAIL, ]; } diff --git a/src/Exceptions/InvalidEmailException.php b/src/Exceptions/InvalidEmailException.php index 9b07ca9..dcc6617 100644 --- a/src/Exceptions/InvalidEmailException.php +++ b/src/Exceptions/InvalidEmailException.php @@ -21,7 +21,7 @@ use AtolOnline\Constants\Ffd105Tags; class InvalidEmailException extends AtolException { protected array $ffd_tags = [ - Ffd105Tags::CLIENT_CONTACT, + Ffd105Tags::CLIENT_PHONE_EMAIL, Ffd105Tags::COMPANY_EMAIL, ]; diff --git a/src/Exceptions/InvalidPhoneException.php b/src/Exceptions/InvalidPhoneException.php index 27552d5..6b5d597 100644 --- a/src/Exceptions/InvalidPhoneException.php +++ b/src/Exceptions/InvalidPhoneException.php @@ -19,7 +19,7 @@ use AtolOnline\Constants\Ffd105Tags; class InvalidPhoneException extends AtolException { protected array $ffd_tags = [ - Ffd105Tags::CLIENT_CONTACT, + Ffd105Tags::CLIENT_PHONE_EMAIL, Ffd105Tags::PAGENT_PHONE, Ffd105Tags::RPO_PHONES, Ffd105Tags::MTO_PHONES, diff --git a/src/Exceptions/TooLongClientContactException.php b/src/Exceptions/TooLongClientContactException.php index b98e0d0..c79bf1d 100644 --- a/src/Exceptions/TooLongClientContactException.php +++ b/src/Exceptions/TooLongClientContactException.php @@ -21,5 +21,5 @@ class TooLongClientContactException extends TooLongException { protected $message = 'Cлишком длинный телефон или email покупателя'; protected float $max = Constraints::MAX_LENGTH_CLIENT_CONTACT; - protected array $ffd_tags = [Ffd105Tags::CLIENT_CONTACT]; + protected array $ffd_tags = [Ffd105Tags::CLIENT_PHONE_EMAIL]; } diff --git a/src/Exceptions/TooLongEmailException.php b/src/Exceptions/TooLongEmailException.php index 4d0df4f..224bcb1 100644 --- a/src/Exceptions/TooLongEmailException.php +++ b/src/Exceptions/TooLongEmailException.php @@ -22,7 +22,7 @@ class TooLongEmailException extends TooLongException protected $message = 'Слишком длинный email'; protected float $max = Constraints::MAX_LENGTH_EMAIL; protected array $ffd_tags = [ - Ffd105Tags::CLIENT_CONTACT, + Ffd105Tags::CLIENT_PHONE_EMAIL, Ffd105Tags::COMPANY_EMAIL, ]; } diff --git a/tests/AtolOnline/Tests/Entities/ClientTest.php b/tests/AtolOnline/Tests/Entities/ClientTest.php index 52f05c9..1207c41 100644 --- a/tests/AtolOnline/Tests/Entities/ClientTest.php +++ b/tests/AtolOnline/Tests/Entities/ClientTest.php @@ -17,8 +17,7 @@ use AtolOnline\{ Exceptions\TooLongClientNameException, Exceptions\TooLongEmailException, Helpers, - Tests\BasicTestCase -}; + Tests\BasicTestCase}; /** * Набор тестов для проверки работы класса покупателя @@ -111,8 +110,6 @@ class ClientTest extends BasicTestCase (new Client())->setName(Helpers::randomStr(400)); } - //------------------------------------------------------------------------------------------------------------------ - /** * Тестирует установку телефонов, которые приводятся к null * @@ -158,8 +155,6 @@ class ClientTest extends BasicTestCase (new Client())->setPhone('99999999999999999999999999999999999999999999999999999999999999999999999999'); } - //------------------------------------------------------------------------------------------------------------------ - /** * Тестирует установку валидных email-ов * @@ -208,8 +203,6 @@ class ClientTest extends BasicTestCase (new Client())->setEmail($email); } - //------------------------------------------------------------------------------------------------------------------ - /** * Тестирует исключение о корректной длине ИНН * diff --git a/tests/AtolOnline/Tests/Entities/PayingAgentTest.php b/tests/AtolOnline/Tests/Entities/PayingAgentTest.php index d835ae0..0967ff0 100644 --- a/tests/AtolOnline/Tests/Entities/PayingAgentTest.php +++ b/tests/AtolOnline/Tests/Entities/PayingAgentTest.php @@ -67,16 +67,17 @@ class PayingAgentTest extends BasicTestCase /** * Тестирует установку операций, которые приводятся к null * - * @param mixed $name + * @param mixed $operation * @dataProvider providerNullableStrings * @covers \AtolOnline\Entities\PayingAgent * @covers \AtolOnline\Entities\PayingAgent::setOperation * @covers \AtolOnline\Entities\PayingAgent::getOperation * @throws TooLongPayingAgentOperationException + * @throws InvalidPhoneException */ - public function testNullableOperations(mixed $name): void + public function testNullableOperations(mixed $operation): void { - $this->assertNull((new PayingAgent())->setOperation($name)->getOperation()); + $this->assertNull((new PayingAgent($operation))->getOperation()); } /**