From 4cf6e81d5fff0094c2b6b0a269d8b3729d754aad Mon Sep 17 00:00:00 2001 From: AnthonyAxenov Date: Fri, 29 May 2020 22:24:15 +0800 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BF=D0=B0=D0=BD=D0=B8=D0=B8=20=D0=B8=20=D0=BA?= =?UTF-8?q?=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/BasicTestCase.php | 17 ++++++++++++++++- tests/Feature/ItemTest.php | 16 ---------------- tests/Unit/ClientTest.php | 36 ++++-------------------------------- tests/Unit/CompanyTest.php | 37 +++++++++---------------------------- 4 files changed, 29 insertions(+), 77 deletions(-) diff --git a/tests/BasicTestCase.php b/tests/BasicTestCase.php index 4d5e984..829da25 100644 --- a/tests/BasicTestCase.php +++ b/tests/BasicTestCase.php @@ -42,7 +42,22 @@ class BasicTestCase extends TestCase */ public function tearDown(): void { - //parent::tearDown(); } + + /** + * Возвращает случайную строку указанной длины + * + * @param int $length + * @return string + */ + protected static function randomString($length = 8) + { + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $string = ''; + for ($i = 0; $i < $length; $i++) { + $string .= $characters[mt_rand(0, strlen($characters) - 1)]; + } + return $string; + } } \ No newline at end of file diff --git a/tests/Feature/ItemTest.php b/tests/Feature/ItemTest.php index 420018a..0971910 100644 --- a/tests/Feature/ItemTest.php +++ b/tests/Feature/ItemTest.php @@ -22,22 +22,6 @@ use AtolOnline\{Constants\PaymentMethods, */ class ItemTest extends BasicTestCase { - /** - * Возвращает случайную строку указанной длины - * - * @param int $length - * @return string - */ - private static function randomString($length = 8) - { - $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $string = ''; - for ($i = 0; $i < $length; $i++) { - $string .= $characters[mt_rand(0, strlen($characters) - 1)]; - } - return $string; - } - /** * Тестирует установку параметров через конструктор * diff --git a/tests/Unit/ClientTest.php b/tests/Unit/ClientTest.php index 93dcedf..0df1a53 100644 --- a/tests/Unit/ClientTest.php +++ b/tests/Unit/ClientTest.php @@ -22,12 +22,6 @@ class ClientTest extends BasicTestCase { /** * Тестирует установку параметров - * - * @throws \AtolOnline\Exceptions\AtolEmailTooLongException - * @throws \AtolOnline\Exceptions\AtolEmailValidateException - * @throws \AtolOnline\Exceptions\AtolNameTooLongException - * @throws \AtolOnline\Exceptions\AtolPhoneTooLongException - * @throws \AtolOnline\Exceptions\AtolInnWrongLengthException */ public function testConstructor() { @@ -48,30 +42,18 @@ class ClientTest extends BasicTestCase * Тестирует исключение о слишком длинном имени * * @throws \AtolOnline\Exceptions\AtolNameTooLongException - * @throws \AtolOnline\Exceptions\AtolEmailTooLongException - * @throws \AtolOnline\Exceptions\AtolEmailValidateException - * @throws \AtolOnline\Exceptions\AtolPhoneTooLongException - * @throws \AtolOnline\Exceptions\AtolInnWrongLengthException */ public function testAtolNameTooLongException() { $customer = new Client(); $this->expectException(AtolNameTooLongException::class); - $customer->setName('John Doe John Doe John Doe John Doe John Doe '. - 'John Doe John Doe John Doe John Doe John Doe John Doe John Doe John '. - 'Doe John Doe John Doe John Doe John DoeJohn Doe John Doe John Doe '. - 'John Doe John Doe John Doe John Doe John Doe John Doe John Doe John '. - 'Doe John Doe John Doe John Doe John Doe John Doe John Doe'); + $customer->setName(self::randomString(257)); } /** * Тестирует исключение о слишком длинном телефоне * * @throws \AtolOnline\Exceptions\AtolPhoneTooLongException - * @throws \AtolOnline\Exceptions\AtolNameTooLongException - * @throws \AtolOnline\Exceptions\AtolEmailTooLongException - * @throws \AtolOnline\Exceptions\AtolEmailValidateException - * @throws \AtolOnline\Exceptions\AtolInnWrongLengthException */ public function testAtolPhoneTooLongException() { @@ -84,42 +66,32 @@ class ClientTest extends BasicTestCase * Тестирует исключение о слишком длинной почте * * @throws \AtolOnline\Exceptions\AtolEmailTooLongException - * @throws \AtolOnline\Exceptions\AtolPhoneTooLongException - * @throws \AtolOnline\Exceptions\AtolNameTooLongException * @throws \AtolOnline\Exceptions\AtolEmailValidateException - * @throws \AtolOnline\Exceptions\AtolInnWrongLengthException */ public function testAtolEmailTooLongException() { $customer = new Client(); $this->expectException(AtolEmailTooLongException::class); - $customer->setEmail('johnjohnjohnjohnjohnjohndoedoedoedoe@exampleexampleexampleexample.com'); + $customer->setEmail(self::randomString(65)); } /** * Тестирует исключение о некорректной почте * - * @throws \AtolOnline\Exceptions\AtolEmailValidateException * @throws \AtolOnline\Exceptions\AtolEmailTooLongException - * @throws \AtolOnline\Exceptions\AtolPhoneTooLongException - * @throws \AtolOnline\Exceptions\AtolNameTooLongException - * @throws \AtolOnline\Exceptions\AtolInnWrongLengthException + * @throws \AtolOnline\Exceptions\AtolEmailValidateException */ public function testAtolEmailValidateException() { $customer = new Client(); $this->expectException(AtolEmailValidateException::class); - $customer->setEmail('John Doe'); + $customer->setEmail(self::randomString(15)); } /** * Тестирует исключение о некорректной длине ИНН * * @throws \AtolOnline\Exceptions\AtolInnWrongLengthException - * @throws \AtolOnline\Exceptions\AtolEmailTooLongException - * @throws \AtolOnline\Exceptions\AtolEmailValidateException - * @throws \AtolOnline\Exceptions\AtolNameTooLongException - * @throws \AtolOnline\Exceptions\AtolPhoneTooLongException */ public function testAtolInnWrongLengthException() { diff --git a/tests/Unit/CompanyTest.php b/tests/Unit/CompanyTest.php index b59d373..4211303 100644 --- a/tests/Unit/CompanyTest.php +++ b/tests/Unit/CompanyTest.php @@ -22,11 +22,6 @@ class CompanyTest extends BasicTestCase { /** * Тестирует установку параметров через конструктор - * - * @throws AtolOnline\Exceptions\AtolEmailTooLongException - * @throws AtolOnline\Exceptions\AtolEmailValidateException - * @throws AtolOnline\Exceptions\AtolInnWrongLengthException - * @throws AtolOnline\Exceptions\AtolPaymentAddressTooLongException */ public function testConstructor() { @@ -46,10 +41,7 @@ class CompanyTest extends BasicTestCase /** * Тестирует исключение о некорректной длине ИНН * - * @throws AtolOnline\Exceptions\AtolInnWrongLengthException - * @throws AtolOnline\Exceptions\AtolEmailTooLongException - * @throws AtolOnline\Exceptions\AtolEmailValidateException - * @throws AtolOnline\Exceptions\AtolPaymentAddressTooLongException + * @throws \AtolOnline\Exceptions\AtolInnWrongLengthException */ public function testAtolInnWrongLengthException() { @@ -62,49 +54,38 @@ class CompanyTest extends BasicTestCase /** * Тестирует исключение о слишком длинном платёжном адресе * - * @throws AtolOnline\Exceptions\AtolPaymentAddressTooLongException - * @throws AtolOnline\Exceptions\AtolEmailTooLongException - * @throws AtolOnline\Exceptions\AtolEmailValidateException - * @throws AtolOnline\Exceptions\AtolInnWrongLengthException + * @throws \AtolOnline\Exceptions\AtolPaymentAddressTooLongException */ public function testAtolPaymentAddressTooLongException() { $company = new Company(); $this->expectException(AtolPaymentAddressTooLongException::class); - $company->setPaymentAddress('John Doe John Doe John Doe John Doe '. - 'John Doe John Doe John Doe John Doe John Doe John Doe John Doe John Doe John '. - 'Doe John Doe John Doe John Doe John DoeJohn Doe John Doe John Doe John Doe '. - 'John Doe John Doe John Doe John Doe John Doe John Doe John Doe John Doe John '. - 'Doe John Doe John Doe John Doe John Doe'); + $company->setPaymentAddress(self::randomString(257)); } /** * Тестирует исключение о слишком длинной почте * - * @throws AtolOnline\Exceptions\AtolEmailTooLongException - * @throws AtolOnline\Exceptions\AtolEmailValidateException - * @throws AtolOnline\Exceptions\AtolInnWrongLengthException - * @throws AtolOnline\Exceptions\AtolPaymentAddressTooLongException + * @throws \AtolOnline\Exceptions\AtolEmailTooLongException + * @throws \AtolOnline\Exceptions\AtolEmailValidateException */ public function testAtolEmailTooLongException() { $company = new Company(); $this->expectException(AtolEmailTooLongException::class); - $company->setEmail('johnjohnjohnjohnjohnjohndoedoedoedoe@exampleexampleexampleexample.com'); + $company->setEmail(self::randomString(65)); } /** * Тестирует исключение о некорректной почте * - * @throws AtolOnline\Exceptions\AtolEmailValidateException - * @throws AtolOnline\Exceptions\AtolEmailTooLongException - * @throws AtolOnline\Exceptions\AtolInnWrongLengthException - * @throws AtolOnline\Exceptions\AtolPaymentAddressTooLongException + * @throws \AtolOnline\Exceptions\AtolEmailTooLongException + * @throws \AtolOnline\Exceptions\AtolEmailValidateException */ public function testAtolEmailValidateException() { $company = new Company(); $this->expectException(AtolEmailValidateException::class); - $company->setEmail('John Doe'); + $company->setEmail(self::randomString(15)); } } \ No newline at end of file