From 3d4435b2e9152e1050c84d6720e8caa21cd5c687 Mon Sep 17 00:00:00 2001 From: Thiago Paes Date: Sun, 2 Dec 2018 00:28:04 -0200 Subject: [PATCH] refactory(validators): Remove external validation and using internal types --- README.md | 10 +- composer.json | 2 +- composer.lock | 130 ++---- phpunit.xml.dist | 8 +- samples/cart.php | 4 +- samples/recebido.php | 4 +- samples/remessa.php | 14 +- src/Common/Base/Address.php | 215 ---------- src/Common/Base/Authorization.php | 40 -- src/Common/Base/Bank.php | 118 ------ src/Common/Base/BankAccount.php | 174 -------- src/Common/Base/Billet.php | 134 ------- src/Common/Base/Cart.php | 32 -- src/Common/Base/Charge.php | 124 ------ src/Common/Base/Client.php | 51 --- src/Common/Base/ConsumerUnity.php | 124 ------ src/Common/Base/Customer.php | 136 ------- src/Common/Base/Dealership.php | 71 ---- src/Common/Base/Document.php | 95 ----- src/Common/Base/Email.php | 89 ----- src/Common/Base/Holder.php | 45 --- src/Common/Base/Occurrence.php | 137 ------- src/Common/Base/Parcel.php | 118 ------ src/Common/Base/Parcels.php | 31 -- src/Common/Base/Person.php | 299 -------------- src/Common/Base/Phone.php | 86 ---- src/Common/Base/Purchaser.php | 79 ---- src/Common/Base/Seller.php | 43 -- src/Common/Base/Sequence.php | 56 --- src/Common/Type/Alphanumeric.php | 13 - src/Common/Type/Number.php | 13 - src/Common/Util/Number.php | 39 -- src/Factory.php | 42 +- src/Received/File.php | 4 +- src/Received/Partial/Detail.php | 28 +- src/Received/Partial/Footer.php | 6 +- src/Received/Partial/Header.php | 16 +- src/Shipment/File.php | 22 +- src/Shipment/Partial/Detail.php | 24 +- src/Shipment/Partial/Footer.php | 10 +- src/Shipment/Partial/Header.php | 14 +- .../ChangeProtectedAttribute.php | 2 +- tests/Common/Base/AddressTest.php | 325 --------------- tests/Common/Base/AuthorizationTest.php | 53 --- tests/Common/Base/BankAccountTest.php | 235 ----------- tests/Common/Base/BankTest.php | 148 ------- tests/Common/Base/BilletTest.php | 191 --------- tests/Common/Base/CartTest.php | 83 ---- tests/Common/Base/ChargeTest.php | 97 ----- tests/Common/Base/ClientTest.php | 78 ---- tests/Common/Base/ConsumerUnityTest.php | 161 -------- tests/Common/Base/CustomerTest.php | 231 ----------- tests/Common/Base/DealershipTest.php | 90 ----- tests/Common/Base/DocumentTest.php | 128 ------ tests/Common/Base/EmailTest.php | 135 ------- tests/Common/Base/HolderTest.php | 92 ----- tests/Common/Base/OccurrenceTest.php | 186 --------- tests/Common/Base/ParcelTest.php | 189 --------- tests/Common/Base/ParcelsTest.php | 55 --- tests/Common/Base/PersonTest.php | 374 ------------------ tests/Common/Base/PhoneTest.php | 138 ------- tests/Common/Base/PurchaserTest.php | 115 ------ tests/Common/Base/SellerTest.php | 74 ---- tests/Common/Base/SequenceTest.php | 67 ---- tests/Common/Util/NumberTest.php | 77 ---- tests/Mock.php | 42 +- tests/Received/FileTest.php | 4 +- tests/Received/Partial/DetailTest.php | 18 +- tests/Received/Partial/FooterTest.php | 4 +- tests/Received/Partial/HeaderTest.php | 6 +- tests/Shipment/FileTest.php | 6 +- tests/Shipment/Partial/DetailTest.php | 24 +- tests/Shipment/Partial/FooterTest.php | 4 +- tests/Shipment/Partial/HeaderTest.php | 6 +- 74 files changed, 189 insertions(+), 5949 deletions(-) delete mode 100644 src/Common/Base/Address.php delete mode 100644 src/Common/Base/Authorization.php delete mode 100644 src/Common/Base/Bank.php delete mode 100644 src/Common/Base/BankAccount.php delete mode 100644 src/Common/Base/Billet.php delete mode 100644 src/Common/Base/Cart.php delete mode 100644 src/Common/Base/Charge.php delete mode 100644 src/Common/Base/Client.php delete mode 100644 src/Common/Base/ConsumerUnity.php delete mode 100644 src/Common/Base/Customer.php delete mode 100644 src/Common/Base/Dealership.php delete mode 100644 src/Common/Base/Document.php delete mode 100644 src/Common/Base/Email.php delete mode 100644 src/Common/Base/Holder.php delete mode 100644 src/Common/Base/Occurrence.php delete mode 100644 src/Common/Base/Parcel.php delete mode 100644 src/Common/Base/Parcels.php delete mode 100644 src/Common/Base/Person.php delete mode 100644 src/Common/Base/Phone.php delete mode 100644 src/Common/Base/Purchaser.php delete mode 100644 src/Common/Base/Seller.php delete mode 100644 src/Common/Base/Sequence.php delete mode 100644 src/Common/Type/Alphanumeric.php delete mode 100644 src/Common/Type/Number.php delete mode 100644 src/Common/Util/Number.php rename {src/Common/Util => tests}/ChangeProtectedAttribute.php (93%) delete mode 100644 tests/Common/Base/AddressTest.php delete mode 100644 tests/Common/Base/AuthorizationTest.php delete mode 100644 tests/Common/Base/BankAccountTest.php delete mode 100644 tests/Common/Base/BankTest.php delete mode 100644 tests/Common/Base/BilletTest.php delete mode 100644 tests/Common/Base/CartTest.php delete mode 100644 tests/Common/Base/ChargeTest.php delete mode 100644 tests/Common/Base/ClientTest.php delete mode 100644 tests/Common/Base/ConsumerUnityTest.php delete mode 100644 tests/Common/Base/CustomerTest.php delete mode 100644 tests/Common/Base/DealershipTest.php delete mode 100644 tests/Common/Base/DocumentTest.php delete mode 100644 tests/Common/Base/EmailTest.php delete mode 100644 tests/Common/Base/HolderTest.php delete mode 100644 tests/Common/Base/OccurrenceTest.php delete mode 100644 tests/Common/Base/ParcelTest.php delete mode 100644 tests/Common/Base/ParcelsTest.php delete mode 100644 tests/Common/Base/PersonTest.php delete mode 100644 tests/Common/Base/PhoneTest.php delete mode 100644 tests/Common/Base/PurchaserTest.php delete mode 100644 tests/Common/Base/SellerTest.php delete mode 100644 tests/Common/Base/SequenceTest.php delete mode 100644 tests/Common/Util/NumberTest.php diff --git a/README.md b/README.md index ed318c2..31c486a 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,7 @@ Descrição dos exemplos - samples/remessa.php - Geração de arquivo de remessa - samples/recebido.php - Leitura do arquivo de retorno -## Contribuindo +## Licença -### Instalação -Após baixar o [Composer](http://www.getcomposer.org), basta rodar o *install* - -``` -composer.phar install --prefer-dist -``` +GNU GENERAL PUBLIC LICENSE +Version 3, 29 June 2007 diff --git a/composer.json b/composer.json index d11bbb4..6783507 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ ], "require": { "php": "^7.1", - "respect/validation": "^1.1.12" + "mrprompt/shipmentcommon": "^2.0.2" }, "require-dev": { "phpunit/phpunit": "^6.1.3", diff --git a/composer.lock b/composer.lock index f137c13..473a21b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,129 +4,63 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1306b5a1534d99368adcd4b9cbbdf792", + "content-hash": "a4f1f52730d85bad9aed406c1f78c37b", "packages": [ { - "name": "respect/validation", - "version": "1.1.29", + "name": "mrprompt/shipmentcommon", + "version": "2.0.2", "source": { "type": "git", - "url": "https://github.com/Respect/Validation.git", - "reference": "f8c90fa36859ca41c766efcf0c476d58913a7767" + "url": "https://github.com/mrprompt/ShipmentCommon.git", + "reference": "701580f1a1d9cb50bee6423a14412f73ad260733" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Respect/Validation/zipball/f8c90fa36859ca41c766efcf0c476d58913a7767", - "reference": "f8c90fa36859ca41c766efcf0c476d58913a7767", + "url": "https://api.github.com/repos/mrprompt/ShipmentCommon/zipball/701580f1a1d9cb50bee6423a14412f73ad260733", + "reference": "701580f1a1d9cb50bee6423a14412f73ad260733", "shasum": "" }, "require": { - "php": ">=5.4", - "symfony/polyfill-mbstring": "^1.2" + "php": "^7.1" }, "require-dev": { - "egulias/email-validator": "~1.2 || ~2.1", - "mikey179/vfsstream": "^1.5", - "phpunit/phpunit": "~4.0", - "symfony/validator": "~2.6.9", - "zendframework/zend-validator": "~2.3" - }, - "suggest": { - "egulias/email-validator": "Strict (RFC compliant) email validation", - "ext-bcmath": "Arbitrary Precision Mathematics", - "ext-mbstring": "Multibyte String Functions", - "friendsofphp/php-cs-fixer": "Fix PSR2 and other coding style issues", - "symfony/validator": "Use Symfony validator through Respect\\Validation", - "zendframework/zend-validator": "Use Zend Framework validator through Respect\\Validation" + "mockery/mockery": "dev-master@dev", + "phpunit/phpunit": "^6.1.3" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, "autoload": { "psr-4": { - "Respect\\Validation\\": "library/" + "MrPrompt\\ShipmentCommon\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "GPL-3.0-or-later" ], "authors": [ { - "name": "Respect/Validation Contributors", - "homepage": "https://github.com/Respect/Validation/graphs/contributors" - } - ], - "description": "The most awesome validation engine ever created for PHP", - "homepage": "http://respect.github.io/Validation/", - "keywords": [ - "respect", - "validation", - "validator" - ], - "time": "2018-11-04T21:58:45+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.10.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "c79c051f5b3a46be09205c73b80b346e4153e494" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494", - "reference": "c79c051f5b3a46be09205c73b80b346e4153e494", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.9-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" + "name": "Thiago Paes", + "email": "mrprompt@gmail.com", + "role": "Developer" + }, + { + "name": "Johnathan Cardoso", + "email": "git@spamhunter.johnathan.com.br", + "role": "Collaborator" }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" + "name": "Walter Discher Cechinel", + "email": "mistrim@gmail.com", + "role": "Collaborator" }, { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Luís Otávio Cobucci Oblonczyk", + "email": "lcobucci@gmail.com", + "role": "Collaborator" } ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "time": "2018-09-21T13:07:52+00:00" + "description": "Common classes used in remittance libraries.", + "time": "2018-12-02T01:23:06+00:00" } ], "packages-dev": [ @@ -284,12 +218,12 @@ "source": { "type": "git", "url": "https://github.com/mockery/mockery.git", - "reference": "a0299757e37696d3e18a61b0369d5d4fe09fc946" + "reference": "e269741a9e96f7a6257054ff963fc2b6316cf21a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/a0299757e37696d3e18a61b0369d5d4fe09fc946", - "reference": "a0299757e37696d3e18a61b0369d5d4fe09fc946", + "url": "https://api.github.com/repos/mockery/mockery/zipball/e269741a9e96f7a6257054ff963fc2b6316cf21a", + "reference": "e269741a9e96f7a6257054ff963fc2b6316cf21a", "shasum": "" }, "require": { @@ -341,7 +275,7 @@ "test double", "testing" ], - "time": "2018-10-12T09:41:15+00:00" + "time": "2018-11-22T06:31:11+00:00" }, { "name": "myclabs/deep-copy", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ef69893..543e4f1 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,8 +2,7 @@ + backupStaticAttributes="false" verbose="true"> @@ -16,17 +15,12 @@ ./tests/Received - - - ./tests/Common - ./vendor ./samples - ./src/Common/Base/Type diff --git a/samples/cart.php b/samples/cart.php index 89c5784..a30168c 100644 --- a/samples/cart.php +++ b/samples/cart.php @@ -4,8 +4,8 @@ * * @author Thiago Paes */ -use MrPrompt\Celesc\Common\Base\Charge; -use MrPrompt\Celesc\Common\Base\Occurrence; +use MrPrompt\ShipmentCommon\Base\Charge; +use MrPrompt\ShipmentCommon\Base\Occurrence; /* @var $vencimento \DateTime */ $vencimento = (new DateTime())->add(new DateInterval('P30D')); diff --git a/samples/recebido.php b/samples/recebido.php index 59294f7..7ca3dd3 100644 --- a/samples/recebido.php +++ b/samples/recebido.php @@ -7,7 +7,7 @@ * @author Thiago Paes */ use MrPrompt\Celesc\Received\File; -use MrPrompt\Celesc\Common\Base\Sequence; +use MrPrompt\ShipmentCommon\Base\Sequence; require __DIR__ . '/bootstrap.php'; @@ -15,7 +15,7 @@ $lista = require __DIR__ . '/cart.php'; try { - /* @var $importer \MrPrompt\Celesc\Common\Base\Sequence */ + /* @var $importer \MrPrompt\ShipmentCommon\Base\Sequence */ $sequence = new Sequence('063'); /* @var $importer \MrPrompt\Celesc\Received\File */ diff --git a/samples/remessa.php b/samples/remessa.php index 61f8e30..5c35230 100644 --- a/samples/remessa.php +++ b/samples/remessa.php @@ -7,17 +7,17 @@ * @author Thiago Paes */ use MrPrompt\Celesc\Factory; -use MrPrompt\Celesc\Common\Base\Cart; -use MrPrompt\Celesc\Common\Base\Sequence; +use MrPrompt\ShipmentCommon\Base\Cart; +use MrPrompt\ShipmentCommon\Base\Sequence; use MrPrompt\Celesc\Shipment\File; -use MrPrompt\Celesc\Common\Base\Dealership; +use MrPrompt\ShipmentCommon\Base\Dealership; require __DIR__ . '/bootstrap.php'; /* @var $today \DateTime */ $today = DateTime::createFromFormat('dmY', '01082016'); -/* @var $cart \MrPrompt\Celesc\Common\Base\Cart */ +/* @var $cart \MrPrompt\ShipmentCommon\Base\Cart */ $cart = new Cart(); /* @var $lista array */ @@ -42,13 +42,13 @@ } try { - /* @var $sequence \MrPrompt\Celesc\Common\Base\Sequence */ + /* @var $sequence \MrPrompt\ShipmentCommon\Base\Sequence */ $sequence = new Sequence('0104'); - /* @var $customer \MrPrompt\Celesc\Common\Base\Customer */ + /* @var $customer \MrPrompt\ShipmentCommon\Base\Customer */ $customer = Factory::createCustomerFromArray(array_shift($lista)['vendedor']); - /* @var $dealership \MrPrompt\Celesc\Common\Base\Dealership */ + /* @var $dealership \MrPrompt\ShipmentCommon\Base\Dealership */ $dealership = new Dealership(); $dealership->setCode('0001'); diff --git a/src/Common/Base/Address.php b/src/Common/Base/Address.php deleted file mode 100644 index 8f5d6d7..0000000 --- a/src/Common/Base/Address.php +++ /dev/null @@ -1,215 +0,0 @@ - - */ -class Address -{ - /** - * City - * - * @var string - */ - private $city; - - /** - * State - * - * @var string - */ - private $state; - - /** - * Postal Code - CEP - * - * @var mixed - */ - private $postalCode; - - /** - * - * @var string - */ - private $address; - - /** - * - * @var int - */ - private $number; - - /** - * - * @var string - */ - private $district; - - /** - * - * @var string - */ - private $complement; - - /** - * @return the $city - */ - public function getCity() - { - return $this->city; - } - - /** - * @param string $city - */ - public function setCity($city) - { - try { - Validator::create()->length(null, 200)->assert($city); - - $this->city = $city; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid city name: %s', $city)); - } - } - - /** - * @return the $state - */ - public function getState() - { - return $this->state; - } - - /** - * @param string $state - */ - public function setState($state) - { - try { - Validator::create()->length(null, 2)->assert($state); - - $this->state = $state; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid state value: %s', $state)); - } - } - - /** - * @return the $postalCode - */ - public function getPostalCode() - { - return $this->postalCode; - } - - /** - * @param string $postalCode - */ - public function setPostalCode($postalCode) - { - try { - Validator::stringType()->notEmpty()->length(8, 8)->assert($postalCode); - - $this->postalCode = $postalCode; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid postal code: "%s"', $postalCode)); - } - } - - /** - * @return the $address - */ - public function getAddress() - { - return $this->address; - } - - /** - * @param string $address - */ - public function setAddress($address) - { - try { - Validator::create()->length(null, 140)->assert($address); - - $this->address = $address; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid address: "%s"', $address)); - } - } - - /** - * @return the $number - */ - public function getNumber() - { - return $this->number; - } - - /** - * @param number $number - */ - public function setNumber($number) - { - try { - $number = trim($number); - - Validator::create()->numeric()->assert($number); - - $this->number = $number; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid address number %s', $number)); - } - - } - - /** - * @return the $district - */ - public function getDistrict() - { - return $this->district; - } - - /** - * @param string $district - */ - public function setDistrict($district) - { - try { - Validator::create()->length(null, 200)->assert($district); - - $this->district = $district; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('District %s is invalid', $district)); - } - } - - /** - * @return the $complement - */ - public function getComplement() - { - return $this->complement; - } - - /** - * @param string $complement - */ - public function setComplement($complement) - { - try { - Validator::create()->length(null, 150)->assert($complement); - - $this->complement = $complement; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Complement %s is invalid', $complement)); - } - } -} diff --git a/src/Common/Base/Authorization.php b/src/Common/Base/Authorization.php deleted file mode 100644 index 932c5df..0000000 --- a/src/Common/Base/Authorization.php +++ /dev/null @@ -1,40 +0,0 @@ - - */ -class Authorization -{ - /** - * @var int - */ - private $number; - - /** - * @return int - */ - public function getNumber() - { - return $this->number; - } - - /** - * @param int $number - */ - public function setNumber($number) - { - try { - Validator::create()->notEmpty()->assert($number); - - $this->number = $number; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid authorization number: %s', $number)); - } - } -} diff --git a/src/Common/Base/Bank.php b/src/Common/Base/Bank.php deleted file mode 100644 index 897c9f1..0000000 --- a/src/Common/Base/Bank.php +++ /dev/null @@ -1,118 +0,0 @@ - - */ -class Bank -{ - const BANCO_DO_BRASIL = 30; - const HSBC = 36; - const SANTANDER = 54; - const CAIXA_ECONOMICA_FEDERAL = 55; - const SICRED = 79; - - /** - * @var array - */ - private $codes = [ - self::BANCO_DO_BRASIL, - self::HSBC, - self::SANTANDER, - self::CAIXA_ECONOMICA_FEDERAL, - self::SICRED - ]; - - /** - * - * @var number - */ - private $agency; - - /** - * - * @var number - */ - private $digit; - - /** - * - * @var number - */ - private $code; - - /** - * @return the $agency - */ - public function getAgency() - { - return $this->agency; - } - - /** - * Set the agency - * - * @param number $agency - */ - public function setAgency($agency) - { - try { - Validator::create()->numeric()->assert($agency); - - $this->agency = $agency; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid agency %s', $agency)); - } - } - - /** - * @return the $agencyDigit - */ - public function getDigit() - { - return $this->digit; - } - - /** - * Set the digt - * - * @param number $digit - */ - public function setDigit($digit) - { - try { - Validator::create()->numeric()->assert($digit); - - $this->digit = $digit; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid digit %s', $digit)); - } - } - - /** - * @return number - */ - public function getCode() - { - return $this->code; - } - - /** - * @param number $code - */ - public function setCode($code) - { - try { - Validator::create()->numeric()->in($this->codes)->assert($code); - - $this->code = $code; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid bank code %s', $code)); - } - } -} diff --git a/src/Common/Base/BankAccount.php b/src/Common/Base/BankAccount.php deleted file mode 100644 index 1c1a04d..0000000 --- a/src/Common/Base/BankAccount.php +++ /dev/null @@ -1,174 +0,0 @@ - - */ -class BankAccount -{ - /** - * @var string - */ - private $account; - - /** - * @var string - */ - private $accountDigit; - - /** - * @var string - */ - private $accountOperation; - - /** - * @var boolean - */ - private $security = false; - - /** - * @var BankInterface - */ - private $bank; - - /** - * @var Person - */ - private $holder; - - /** - * @param Bank $bank - * @param Holder $holder - */ - public function __construct(Bank $bank, Holder $holder) - { - $this->bank = $bank; - $this->holder = $holder; - $this->security = false; - } - - /** - * @return int - */ - public function getNumber() - { - return $this->account; - } - - /** - * @param int $account - */ - public function setNumber($account) - { - try { - Validator::create()->numeric()->assert($account); - - $this->account = $account; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid account number: %s', $account)); - } - } - - /** - * @return int - */ - public function getDigit() - { - return $this->accountDigit; - } - - /** - * @param int $accountDigit - */ - public function setDigit($accountDigit) - { - try { - Validator::create()->numeric()->assert($accountDigit); - - $this->accountDigit = $accountDigit; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid account digit: %s', $accountDigit)); - } - } - - /** - * @return int - */ - public function getOperation() - { - return $this->accountOperation; - } - - /** - * @param string $accountOperation - */ - public function setOperation($accountOperation) - { - try { - Validator::create()->numeric()->assert($accountOperation); - - $this->accountOperation = $accountOperation; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid operation: %s', $accountOperation)); - } - } - - /** - * @return boolean - */ - public function getSecurity() - { - return $this->security; - } - - /** - * @param boolean $security - */ - public function setSecurity($security = false) - { - try { - Validator::create()->boolType()->assert($security); - - $this->security = $security; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Security life must be true or false', $security)); - } - } - - /** - * @return Bank - */ - public function getBank() - { - return $this->bank; - } - - /** - * @param Bank $bank - */ - public function setBank(Bank $bank) - { - $this->bank = $bank; - } - - /** - * @return Person - */ - public function getHolder() - { - return $this->holder; - } - - /** - * @param Holder $holder - */ - public function setHolder(Holder $holder) - { - $this->holder = $holder; - } -} diff --git a/src/Common/Base/Billet.php b/src/Common/Base/Billet.php deleted file mode 100644 index 2e21d45..0000000 --- a/src/Common/Base/Billet.php +++ /dev/null @@ -1,134 +0,0 @@ - - */ -class Billet -{ - /** - * @var ArrayObject - */ - private $details; - - /** - * @var float - */ - private $rate; - - /** - * @var BankAccount - */ - private $bankAccount; - - /** - * @var Seller - */ - private $assignor; - - /** - * @var string - */ - private $number; - - /** - * Constructor - */ - public function __construct() - { - $this->details = new ArrayObject(); - } - - /** - * @return ArrayObject - */ - public function getDetails() - { - return $this->details; - } - - /** - * @param ArrayObject $details - */ - public function setDetails(ArrayObject $details) - { - $this->details = $details; - } - - /** - * @param Detail $detail - */ - public function addDetail(Detail $detail) - { - $this->details->append($detail); - } - - /** - * @return float - */ - public function getRate() - { - return $this->rate; - } - - /** - * @param float $rate - */ - public function setRate($rate) - { - $this->rate = $rate; - } - - /** - * @return BankAccount - */ - public function getBankAccount() - { - return $this->bankAccount; - } - - /** - * @param BankAccount $bankAccount - */ - public function setBankAccount(BankAccount $bankAccount) - { - $this->bankAccount = $bankAccount; - } - - /** - * @return Seller - */ - public function getAssignor() - { - return $this->assignor; - } - - /** - * @param Seller $assignor - */ - public function setAssignor(Seller $assignor) - { - $this->assignor = $assignor; - } - - /** - * @return string - */ - public function getNumber() - { - return $this->number; - } - - /** - * @param string $number - */ - public function setNumber($number) - { - $this->number = $number; - } -} diff --git a/src/Common/Base/Cart.php b/src/Common/Base/Cart.php deleted file mode 100644 index 1cdd660..0000000 --- a/src/Common/Base/Cart.php +++ /dev/null @@ -1,32 +0,0 @@ - - */ -class Cart extends ArrayObject -{ - /** - * @param mixed $item - */ - public function addItem($item) - { - $this->append($item); - } - - /** - * @param mixed $item - */ - public function removeItem($item) - { - if (!$this->offsetExists($item)) { - throw new \InvalidArgumentException(sprintf('Item "%s" not exists', $item)); - } - - $this->offsetUnset($item); - } -} \ No newline at end of file diff --git a/src/Common/Base/Charge.php b/src/Common/Base/Charge.php deleted file mode 100644 index ab11fef..0000000 --- a/src/Common/Base/Charge.php +++ /dev/null @@ -1,124 +0,0 @@ - - */ -class Charge -{ - /** - * Billet - * - * @const string - */ - const BILLET = 'B'; - - /** - * Credit card - * - * @const string - */ - const CREDIT_CARD = 'C'; - - /** - * Debit on bank account - * - * @const string - */ - const DEBIT = 'D'; - - /** - * Energy account - * - * @const string - */ - const ENERGY = 'E'; - - /** - * Batch File - * - * @const string - */ - const BATCH_FILE = 'F'; - - /** - * Payment Slip - * - * @const string - */ - const PAYMENT_SLIP = 'P'; - - /** - * Charging type - * - * Types: - * - B = Boleto Bancário - * - E = Energia - * - C = Cartão de Crédito - * - D = Débito Automático - * - D = Arquivo de Remessa - * - P = Bloqueto - * - * @var string - */ - private $charging = self::CREDIT_CARD; - - /** - * Occurrence - * - * @var string - */ - private $occurrence = Occurrence::INSERT; - - /** - * @return the $charging - */ - public function getCharging() - { - return $this->charging; - } - - /** - * @param string $charging - */ - public function setCharging($charging) - { - try { - $validTypes = [ - self::BILLET, - self::CREDIT_CARD, - self::DEBIT, - self::ENERGY, - self::BATCH_FILE, - self::PAYMENT_SLIP - ]; - - Validator::create()->notEmpty()->alpha()->in($validTypes)->assert($charging); - - $this->charging = $charging; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid charge type: %s', $charging)); - } - } - - /** - * @return Occurrence - */ - public function getOccurrence() - { - return $this->occurrence; - } - - /** - * @param Occurrence $occurrence - */ - public function setOccurrence(Occurrence $occurrence) - { - $this->occurrence = $occurrence; - } -} diff --git a/src/Common/Base/Client.php b/src/Common/Base/Client.php deleted file mode 100644 index 4e66024..0000000 --- a/src/Common/Base/Client.php +++ /dev/null @@ -1,51 +0,0 @@ - - */ -class Client -{ - /** - * @var int - */ - private $code; - - /** - * @param int $code - */ - public function __construct($code = null) - { - $this->code = $code; - } - - /** - * @return int - */ - public function getCode() - { - return $this->code; - } - - /** - * @param int $code - * @return void - * @throws InvalidArgumentException - */ - public function setCode($code) - { - try { - Validator::numeric()->assert($code); - - $this->code = $code; - } catch (AllOfException $ex) { - throw new InvalidArgumentException(sprintf('Code must be a numeric value, %s is invalid', $code)); - } - } -} diff --git a/src/Common/Base/ConsumerUnity.php b/src/Common/Base/ConsumerUnity.php deleted file mode 100644 index 298286e..0000000 --- a/src/Common/Base/ConsumerUnity.php +++ /dev/null @@ -1,124 +0,0 @@ - - */ -class ConsumerUnity -{ - /** - * @var int - */ - private $number; - - /** - * @var int - */ - private $code; - - /** - * @var DateTime - */ - private $read; - - /** - * @var DateTime - */ - private $maturity; - - /** - * Constructor - */ - public function __construct() - { - $this->read = new DateTime(); - $this->maturity = new DateTime(); - } - - /** - * Get the number - * - * @return int - */ - public function getNumber() - { - return $this->number; - } - - /** - * Set the consumer number - * - * @param int $number - * @return void - */ - public function setNumber($number) - { - try { - Validator::create()->notEmpty()->assert($number); - - $this->number = $number; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Number of consumer unity %s is invalid', $number)); - } - } - - /** - * @return mixed - */ - public function getRead() - { - return $this->read; - } - - /** - * @param DateTime $read - */ - public function setRead(DateTime $read) - { - $this->read = $read; - } - - /** - * @return DateTime - */ - public function getMaturity() - { - return $this->maturity; - } - - /** - * @param DateTime $maturity - */ - public function setMaturity(DateTime $maturity) - { - $this->maturity = $maturity; - } - - /** - * @return number - */ - public function getCode() - { - return $this->code; - } - - /** - * @param number $code - */ - public function setCode($code) - { - try { - Validator::create()->notEmpty()->assert($code); - - $this->code = $code; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid consumer unity value %s', $code)); - } - } -} diff --git a/src/Common/Base/Customer.php b/src/Common/Base/Customer.php deleted file mode 100644 index 25d8c12..0000000 --- a/src/Common/Base/Customer.php +++ /dev/null @@ -1,136 +0,0 @@ - - */ -class Customer extends Person -{ - /** - * @var int - */ - private $code; - - /** - * @var int - */ - private $identityNumber; - - /** - * @var bool - */ - private $helpfulMaturity; - - /** - * @var int - */ - private $workingDays; - - /** - * @return int - */ - public function getCode() - { - return $this->code; - } - - /** - * @param int $code - * @return void - */ - public function setCode($code) - { - try { - Validator - ::create() - ->notEmpty() - ->assert($code); - - $this->code = $code; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid customer code: %s', $code)); - } - } - - /** - * @return int - */ - public function getIdentityNumber() - { - return $this->identityNumber; - } - - /** - * @param int $identityNumber - */ - public function setIdentityNumber($identityNumber) - { - try { - $number = floor($identityNumber); - - Validator - ::create() - ->notEmpty() - ->assert($number); - - $this->identityNumber = $number; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid identity number: %s', $identityNumber)); - } - } - - /** - * @return mixed - */ - public function getHelpfulMaturity() - { - return $this->helpfulMaturity; - } - - /** - * @param boolean $helpfulMaturity - */ - public function setHelpfulMaturity($helpfulMaturity = true) - { - try { - Validator - ::create() - ->boolType() - ->assert($helpfulMaturity); - - $this->helpfulMaturity = $helpfulMaturity; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid helpful maturity state: %s', $helpfulMaturity)); - } - } - - /** - * @return int - */ - public function getWorkingDays() - { - return $this->workingDays; - } - - /** - * @param int $workingDays - */ - public function setWorkingDays($workingDays) - { - try { - Validator - ::create() - ->notEmpty() - ->intType() - ->assert($workingDays); - - $this->workingDays = $workingDays; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid working days: %s', $workingDays)); - } - } -} diff --git a/src/Common/Base/Dealership.php b/src/Common/Base/Dealership.php deleted file mode 100644 index dfed6cc..0000000 --- a/src/Common/Base/Dealership.php +++ /dev/null @@ -1,71 +0,0 @@ - - */ -class Dealership -{ - /** - * @var string - */ - private $code; - - /** - * @var string - */ - private $name; - - /** - * Return the dealeship code - * - * @return string - */ - public function getCode() - { - return $this->code; - } - - /** - * Dealership code - * - * @param string $code - */ - public function setCode($code) - { - try { - Validator::create()->notEmpty()->assert($code); - - $this->code = $code; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid dealership code: %s', $code)); - } - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param string $name - */ - public function setName($name) - { - try { - Validator::create()->notEmpty()->assert($name); - - $this->name = $name; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid dealership name: %s', $name)); - } - } -} diff --git a/src/Common/Base/Document.php b/src/Common/Base/Document.php deleted file mode 100644 index 46a4de6..0000000 --- a/src/Common/Base/Document.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ -class Document -{ - /** - * CPF - for individual - * - * @const int - */ - const CPF = 1; - - /** - * CNPJ - for Legal Entity - * - */ - const CNPJ = 2; - - /** - * @var string - */ - private $type = self::CPF; - - /** - * @var int - */ - private $number; - - /** - * @param int $type - */ - public function __construct($type = self::CPF) - { - $this->setType($type); - } - - /** - * @return string - */ - public function getType() - { - return $this->type; - } - - /** - * @param string $type - */ - public function setType($type) - { - try { - Validator - ::intType() - ->notEmpty() - ->in([self::CPF, self::CNPJ]) - ->assert($type); - - $this->type = $type; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid document type: %s', $type)); - } - } - - /** - * @return mixed - */ - public function getNumber() - { - return $this->number; - } - - /** - * @param mixed $number - */ - public function setNumber($number) - { - try { - Validator - ::stringType() - ->length(11, 18) - ->assert($number); - - $this->number = $number; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Document #%s is invalid', $number)); - } - } -} diff --git a/src/Common/Base/Email.php b/src/Common/Base/Email.php deleted file mode 100644 index 1417fd0..0000000 --- a/src/Common/Base/Email.php +++ /dev/null @@ -1,89 +0,0 @@ - - */ -class Email -{ - /** - * @var string - */ - private $address; - - /** - * @var boolean - */ - private $primary; - - /** - * @param string $address - * @param bool $primary - */ - public function __construct($address, $primary = true) - { - $this->setAddress($address); - $this->setPrimary($primary); - } - - /** - * @return string - */ - public function getAddress() - { - return $this->address; - } - - /** - * @param string $address - */ - public function setAddress($address) - { - try { - Validator::notEmpty()->email()->assert($address); - - $this->address = $address; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException( - sprintf('E-mails address "%s" is invalid', $address) - ); - } - } - - /** - * @return boolean - */ - public function isPrimary() - { - return $this->primary; - } - - /** - * @return boolean - */ - public function getPrimary() - { - return $this->primary; - } - - /** - * @param boolean $primary - */ - public function setPrimary($primary) - { - try { - - Validator::notEmpty()->boolType()->assert($primary); - - $this->primary = $primary; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException( - sprintf('The primary only accept boolean value, %s is invalid', $primary) - ); - } - } -} \ No newline at end of file diff --git a/src/Common/Base/Holder.php b/src/Common/Base/Holder.php deleted file mode 100644 index 8f153d2..0000000 --- a/src/Common/Base/Holder.php +++ /dev/null @@ -1,45 +0,0 @@ - - */ -class Holder extends Person -{ - /** - * @var int - */ - private $code; - - /** - * @return int - */ - public function getCode() - { - return $this->code; - } - - /** - * @param int $code - * @return void - */ - public function setCode($code) - { - try { - Validator - ::create() - ->notEmpty() - ->intType() - ->assert($code); - - $this->code = $code; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Holder code %s is invalid', $code)); - } - } -} diff --git a/src/Common/Base/Occurrence.php b/src/Common/Base/Occurrence.php deleted file mode 100644 index c662105..0000000 --- a/src/Common/Base/Occurrence.php +++ /dev/null @@ -1,137 +0,0 @@ - - */ -class Occurrence -{ - /** - * Insert ocurrence - * - * @const string - */ - const INSERT = 'I'; - - /** - * Cancel occurrence - * - * @const string - */ - const CANCEL = 'C'; - - /** - * Update occurrence - * - * @const string - */ - const UPDATE = 'A'; - - /** - * Occurrence type - * - * @var string - */ - private $type = self::INSERT; - - /** - * Occurrence Return Code - * - * @var int - */ - private $return; - - /** - * Occurrence Description - * - * @var string - */ - private $description; - - /** - * @var DateTime - */ - private $date; - - /** - * @return string - */ - public function getType() - { - return $this->type; - } - - /** - * @param string $type - */ - public function setType($type) - { - try { - Validator::in([self::INSERT, self::CANCEL, self::UPDATE])->assert($type); - - $this->type = $type; - } catch (AllOfException $e) { - throw new \InvalidArgumentException(sprintf('Invalid occurrence type: %S', $type)); - } - } - - /** - * @return int - */ - public function getReturn() - { - return $this->return; - } - - /** - * @param int $return - */ - public function setReturn($return = 0) - { - $this->return = $return; - } - - /** - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * @param string $description - */ - public function setDescription($description = '') - { - try { - Validator::stringType()->assert($description); - - $this->description = $description; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid description: %s', $description)); - } - } - - /** - * @return DateTime - */ - public function getDate() - { - return $this->date; - } - - /** - * @param DateTime $date - */ - public function setDate(DateTime $date) - { - $this->date = $date; - } -} diff --git a/src/Common/Base/Parcel.php b/src/Common/Base/Parcel.php deleted file mode 100644 index 4a1a239..0000000 --- a/src/Common/Base/Parcel.php +++ /dev/null @@ -1,118 +0,0 @@ - - */ -class Parcel -{ - /** - * - * @var DateTime - */ - private $maturity; - - /** - * - * @var float - */ - private $price; - - /** - * @var int - */ - private $key; - - /** - * @var int - */ - private $quantity; - - /** - * @return the $maturity - */ - public function getMaturity() - { - return $this->maturity; - } - - /** - * @param \DateTime $maturity - */ - public function setMaturity(DateTime $maturity) - { - $this->maturity = $maturity; - } - - /** - * @return the $price - */ - public function getPrice() - { - return $this->price; - } - - /** - * @param float $price - */ - public function setPrice($price) - { - try { - Validator::create()->notEmpty()->numeric()->assert($price); - - $this->price = $price; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid parcel price: %s', $price)); - } - } - - /** - * @return int - */ - public function getKey() - { - return $this->key; - } - - /** - * @param int $key - */ - public function setKey($key = 0) - { - try { - Validator::numeric()->assert($key); - - $this->key = (int) $key; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid parcel key: %s', $key)); - } - } - - /** - * @return int - */ - public function getQuantity() - { - return $this->quantity; - } - - /** - * @param int $quantity - */ - public function setQuantity($quantity) - { - try { - Validator::create()->notEmpty()->numeric()->assert($quantity); - - $this->quantity = $quantity; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid parcel quantity: %s', $quantity)); - } - } -} diff --git a/src/Common/Base/Parcels.php b/src/Common/Base/Parcels.php deleted file mode 100644 index 582cc4c..0000000 --- a/src/Common/Base/Parcels.php +++ /dev/null @@ -1,31 +0,0 @@ - - */ -class Parcels extends SplFixedArray -{ - /** - * Constructor - * - * @param int $quantity - */ - public function __construct($quantity = 1) - { - parent::__construct($quantity); - } - - /** - * @param Parcel $parcel - */ - public function addParcel(Parcel $parcel) - { - $this->offsetSet($this->key(), $parcel); - $this->next(); - } -} diff --git a/src/Common/Base/Person.php b/src/Common/Base/Person.php deleted file mode 100644 index b00dfc5..0000000 --- a/src/Common/Base/Person.php +++ /dev/null @@ -1,299 +0,0 @@ - - */ -class Person -{ - /** - * @var string - */ - private $name; - - /** - * @var Document - */ - private $document; - - /** - * @var string - */ - private $email; - - /** - * @var Phone - */ - private $cellPhone; - - /** - * @var Phone - */ - private $homePhone; - - /** - * @var Phone - */ - private $homePhoneSecondary; - - /** - * - * @var string - */ - private $fatherName; - - /** - * - * @var string - */ - private $motherName; - - /** - * Person type - * - * F = Física - * J = Jurídica - * - * @var string - */ - private $person = 'F'; - - /** - * Salaried situation - * - * A = active - * I = inactive - */ - private $salaried = 'A'; - - /** - * Birth - * - * @var DateTime - */ - private $birth; - - /** - * Address - * - * @var Address - */ - private $address; - - /** - * Constructor - * - */ - public function __construct() - { - $this->person = 'F'; - $this->salaried = 'A'; - $this->birth = new DateTime(); - $this->document = new Document(); - $this->address = new Address(); - } - - /** - * @return Document - */ - public function getDocument() - { - return $this->document; - } - - /** - * @param Document $document - */ - public function setDocument(Document $document) - { - $this->document = $document; - } - - /** - * @return Phone - */ - public function getHomePhone() - { - return $this->homePhone; - } - - /** - * @param Phone $homePhone - */ - public function setHomePhone(Phone $homePhone) - { - $this->homePhone = $homePhone; - } - - /** - * @return Phone - */ - public function getHomePhoneSecondary() - { - return $this->homePhoneSecondary; - } - - /** - * @param Phone $homePhone - */ - public function setHomePhoneSecondary(Phone $homePhone) - { - $this->homePhoneSecondary = $homePhone; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param string $name - */ - public function setName($name) - { - $this->name = $name; - } - - /** - * @return Email - */ - public function getEmail() - { - return $this->email; - } - - /** - * @param Email $email - */ - public function setEmail(Email $email) - { - $this->email = $email; - } - - /** - * @return Phone - */ - public function getCellPhone() - { - return $this->cellPhone; - } - - /** - * @param Phone $cellPhone - */ - public function setCellPhone($cellPhone) - { - $this->cellPhone = $cellPhone; - } - - /** - * @return the $fatherName - */ - public function getFatherName() - { - return $this->fatherName; - } - - /** - * @param string $fatherName - */ - public function setFatherName($fatherName) - { - $this->fatherName = $fatherName; - } - - /** - * @return the $motherName - */ - public function getMotherName() - { - return $this->motherName; - } - - /** - * @param string $motherName - */ - public function setMotherName($motherName) - { - $this->motherName = $motherName; - } - - /** - * @return the $person - */ - public function getPerson() - { - return $this->person; - } - - /** - * @param string $person - * @throws \InvalidArgumentException - */ - public function setPerson($person) - { - try { - Validator::create()->stringType()->in(['F', 'J'])->assert($person); - - $this->person = $person; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid person type: "%s"', $person), 500, $ex); - } - } - - /** - * @return mixed - */ - public function getSalaried() - { - return $this->salaried; - } - - /** - * @param mixed $salaried - */ - public function setSalaried($salaried) - { - $this->salaried = $salaried; - } - - /** - * @return DateTime - */ - public function getBirth() - { - return $this->birth; - } - - /** - * @param DateTime $birth - */ - public function setBirth(DateTime $birth) - { - $this->birth = $birth; - } - - /** - * @return Address - */ - public function getAddress() - { - return $this->address; - } - - /** - * @param Address $address - */ - public function setAddress(Address $address) - { - $this->address = $address; - } -} diff --git a/src/Common/Base/Phone.php b/src/Common/Base/Phone.php deleted file mode 100644 index 75893fa..0000000 --- a/src/Common/Base/Phone.php +++ /dev/null @@ -1,86 +0,0 @@ - - */ -class Phone -{ - /** - * @const int - */ - const CELLPHONE = 1; - - /** - * @const int - */ - const TELEPHONE = 2; - - /** - * @var int - */ - private $number; - - /** - * @var int - */ - private $type; - - /** - * Constructor - * - * @param int $type - */ - public function __construct($type = self::TELEPHONE) - { - $this->setType($type); - } - - /** - * @return int - */ - public function getNumber() - { - return $this->number; - } - - /** - * @param int $number - */ - public function setNumber($number) - { - try { - Validator::stringType()->notEmpty()->length(8, 20)->assert($number); - - $this->number = $number; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid phone number: %s', $number)); - } - } - - /** - * @return int - */ - public function getType() - { - return $this->type; - } - - /** - * @param int $type - */ - public function setType($type) - { - try { - Validator::intType()->in([self::CELLPHONE, self::TELEPHONE])->assert($type); - - $this->type = $type; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid phone type: %s', $type)); - } - } -} diff --git a/src/Common/Base/Purchaser.php b/src/Common/Base/Purchaser.php deleted file mode 100644 index e12dd4d..0000000 --- a/src/Common/Base/Purchaser.php +++ /dev/null @@ -1,79 +0,0 @@ - - */ -class Purchaser extends Person -{ - /** - * Fantasy name - * - * @var string - */ - private $purchaserFantasyName; - - /** - * Social Reason - * - * @var string - */ - private $purchaserSocialReason; - - /** - * State Registration - * - * @var string - */ - private $purchaserStateRegistration; - - /** - * @return string - */ - public function getPurchaserStateRegistration() - { - return $this->purchaserStateRegistration; - } - - /** - * @param string $purchaserStateRegistration - */ - public function setPurchaserStateRegistration($purchaserStateRegistration) - { - $this->purchaserStateRegistration = $purchaserStateRegistration; - } - - /** - * @return the $purchaserFantasyName - */ - public function getPurchaserFantasyName() - { - return $this->purchaserFantasyName; - } - - /** - * @param mixed $purchaserFantasyName - */ - public function setPurchaserFantasyName($purchaserFantasyName) - { - $this->purchaserFantasyName = $purchaserFantasyName; - } - - /** - * @return the $purchaserSocialReason - */ - public function getPurchaserSocialReason() - { - return $this->purchaserSocialReason; - } - - /** - * @param mixed $purchaserSocialReason - */ - public function setPurchaserSocialReason($purchaserSocialReason) - { - $this->purchaserSocialReason = $purchaserSocialReason; - } -} diff --git a/src/Common/Base/Seller.php b/src/Common/Base/Seller.php deleted file mode 100644 index b1bb270..0000000 --- a/src/Common/Base/Seller.php +++ /dev/null @@ -1,43 +0,0 @@ - - */ -class Seller extends Person -{ - /** - * @var int - */ - private $code; - - /** - * @return int - */ - public function getCode() - { - return $this->code; - } - - /** - * @param int $code - * @return void - * @throws InvalidArgumentException - */ - public function setCode($code) - { - try { - Validator::notEmpty()->assert($code); - - $this->code = $code; - } catch (AllOfException $ex) { - throw new InvalidArgumentException(sprintf('Invalid seller code %s', $code)); - } - } -} diff --git a/src/Common/Base/Sequence.php b/src/Common/Base/Sequence.php deleted file mode 100644 index d1d7b4e..0000000 --- a/src/Common/Base/Sequence.php +++ /dev/null @@ -1,56 +0,0 @@ - - */ -class Sequence -{ - /** - * @var int - */ - private $value; - - /** - * Sequence constructor. - * @param string $value - */ - public function __construct($value = "0001") - { - $this->value = $value; - } - - /** - * Return the value from sequence - * - * @return string - */ - public function getValue() - { - return $this->value; - } - - /** - * Set the value from sequence - * - * @param string $value - * @return void - * @throws InvalidArgumentException - */ - public function setValue($value) - { - try { - Validator::create()->notEmpty()->assert($value); - - $this->value = $value; - } catch (AllOfException $ex) { - throw new InvalidArgumentException('Sequence value can not be empty'); - } - } -} diff --git a/src/Common/Type/Alphanumeric.php b/src/Common/Type/Alphanumeric.php deleted file mode 100644 index 1da7f4d..0000000 --- a/src/Common/Type/Alphanumeric.php +++ /dev/null @@ -1,13 +0,0 @@ - - */ -abstract class Alphanumeric -{ - const ALIGN = STR_PAD_RIGHT; - const FILL = ' '; -} \ No newline at end of file diff --git a/src/Common/Type/Number.php b/src/Common/Type/Number.php deleted file mode 100644 index 21251f7..0000000 --- a/src/Common/Type/Number.php +++ /dev/null @@ -1,13 +0,0 @@ - - */ -abstract class Number -{ - const ALIGN = STR_PAD_LEFT; - const FILL = 0; -} \ No newline at end of file diff --git a/src/Common/Util/Number.php b/src/Common/Util/Number.php deleted file mode 100644 index 871584d..0000000 --- a/src/Common/Util/Number.php +++ /dev/null @@ -1,39 +0,0 @@ - - */ -abstract class Number -{ - const FILL_LEFT = 0; - const FILL_RIGHT = 1; - - /** - * @param $value - * @param $length - * @param int $fillSide - * @return string - * @throws \InvalidArgumentException - */ - public static function zeroFill($value = '', $length = 0, $fillSide = self::FILL_LEFT) - { - $valueLength = strlen($value); - - if ($valueLength == $length) { - return $value; - } - - if ($valueLength > $length) { - throw new \InvalidArgumentException(sprintf( - 'The given value (%s) is invalid', - $value - )); - } - - return str_pad($value, $length, 0, $fillSide); - } -} diff --git a/src/Factory.php b/src/Factory.php index 29b4344..7593de5 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -2,25 +2,25 @@ namespace MrPrompt\Celesc; use DateTime; -use MrPrompt\Celesc\Common\Base\Address; -use MrPrompt\Celesc\Common\Base\Authorization; -use MrPrompt\Celesc\Common\Base\Bank; -use MrPrompt\Celesc\Common\Base\BankAccount; -use MrPrompt\Celesc\Common\Base\Billet; -use MrPrompt\Celesc\Common\Base\Charge; -use MrPrompt\Celesc\Common\Base\ConsumerUnity; -use MrPrompt\Celesc\Common\Base\Customer; -use MrPrompt\Celesc\Common\Base\Document; -use MrPrompt\Celesc\Common\Base\Email; -use MrPrompt\Celesc\Common\Base\Holder; -use MrPrompt\Celesc\Common\Base\Occurrence; -use MrPrompt\Celesc\Common\Base\Parcel; -use MrPrompt\Celesc\Common\Base\Parcels; -use MrPrompt\Celesc\Common\Base\Person; -use MrPrompt\Celesc\Common\Base\Phone; -use MrPrompt\Celesc\Common\Base\Purchaser; -use MrPrompt\Celesc\Common\Base\Seller; -use MrPrompt\Celesc\Common\Base\Sequence; +use MrPrompt\ShipmentCommon\Base\Address; +use MrPrompt\ShipmentCommon\Base\Authorization; +use MrPrompt\ShipmentCommon\Base\Bank; +use MrPrompt\ShipmentCommon\Base\BankAccount; +use MrPrompt\ShipmentCommon\Base\Billet; +use MrPrompt\ShipmentCommon\Base\Charge; +use MrPrompt\ShipmentCommon\Base\ConsumerUnity; +use MrPrompt\ShipmentCommon\Base\Customer; +use MrPrompt\ShipmentCommon\Base\Document; +use MrPrompt\ShipmentCommon\Base\Email; +use MrPrompt\ShipmentCommon\Base\Holder; +use MrPrompt\ShipmentCommon\Base\Occurrence; +use MrPrompt\ShipmentCommon\Base\Parcel; +use MrPrompt\ShipmentCommon\Base\Parcels; +use MrPrompt\ShipmentCommon\Base\Person; +use MrPrompt\ShipmentCommon\Base\Phone; +use MrPrompt\ShipmentCommon\Base\Purchaser; +use MrPrompt\ShipmentCommon\Base\Seller; +use MrPrompt\ShipmentCommon\Base\Sequence; use MrPrompt\Celesc\Shipment\Partial\Detail; /** @@ -50,7 +50,7 @@ public static function createDocumentFromArray(array $campos = []) public static function createCustomerFromArray(array $campos = []) { $customer = new Customer(); - $customer->setCode($campos['codigo']); + $customer->setCode((int) $campos['codigo']); $customer->setIdentityNumber($campos['documento']); $customer->setName($campos['nome']); @@ -278,7 +278,7 @@ public static function createSellerFromArray(array $campos = []) if (array_key_exists('vendedor', $campos)) { $seller = new Seller(); - $seller->setCode($campos['vendedor']['codigo']); + $seller->setCode((int) $campos['vendedor']['codigo']); $seller->setName($campos['vendedor']['nome']); $seller->setDocument(static::createDocumentFromArray($campos['vendedor'])); $seller->setAddress(static::createAddressFromArray($campos['vendedor']['endereco'])); diff --git a/src/Received/File.php b/src/Received/File.php index 67a3e63..86864ec 100644 --- a/src/Received/File.php +++ b/src/Received/File.php @@ -1,8 +1,8 @@ */ -class Detail +class Detail extends \stdClass { /** * Type of register @@ -67,7 +67,7 @@ class Detail public function __construct($row) { $this->consumerUnity = new ConsumerUnity(); - $this->consumerUnity->setNumber(substr($row, 1, 13)); + $this->consumerUnity->setNumber((int) substr($row, 1, 13)); $this->parcel = new Parcel(); $this->parcel->setPrice(substr($row, 14, 9)); @@ -75,20 +75,20 @@ public function __construct($row) $this->parcel->setMaturity(DateTime::createFromFormat('dmY', substr($row, 23, 8))); $this->occurrence = new Occurrence(); - $this->occurrence->setReturn(substr($row, 31, 2)); + $this->occurrence->setReturn((int) substr($row, 31, 2)); $this->authorization = new Authorization(); - $this->authorization->setNumber(substr($row, 41, 60)); + $this->authorization->setNumber((int) substr($row, 41, 60)); $this->dealership = new Dealership(); $document = new Document(); - $document->setNumber(substr($row, 109, 11)); + $document->setNumber((int) substr($row, 109, 11)); $this->purchaser = new Purchaser(); $this->purchaser->setDocument($document); - $this->sequence = new Sequence(substr($row, 144, 6)); + $this->sequence = new Sequence((int) substr($row, 144, 6)); } /** diff --git a/src/Received/Partial/Footer.php b/src/Received/Partial/Footer.php index 0dd3c63..44c0239 100644 --- a/src/Received/Partial/Footer.php +++ b/src/Received/Partial/Footer.php @@ -1,8 +1,8 @@ parcel->setPrice(substr($row, 1, 11)); $this->parcel->setQuantity(1); - $this->sequence = new Sequence((substr($row, 144, 6))); + $this->sequence = new Sequence((int) (substr($row, 144, 6))); } /** diff --git a/src/Received/Partial/Header.php b/src/Received/Partial/Header.php index 62b84b6..f29d142 100644 --- a/src/Received/Partial/Header.php +++ b/src/Received/Partial/Header.php @@ -2,10 +2,10 @@ namespace MrPrompt\Celesc\Received\Partial; use DateTime; -use MrPrompt\Celesc\Common\Base\Dealership; -use MrPrompt\Celesc\Common\Base\Occurrence; -use MrPrompt\Celesc\Common\Base\Customer; -use MrPrompt\Celesc\Common\Base\Sequence; +use MrPrompt\ShipmentCommon\Base\Dealership; +use MrPrompt\ShipmentCommon\Base\Occurrence; +use MrPrompt\ShipmentCommon\Base\Customer; +use MrPrompt\ShipmentCommon\Base\Sequence; /** * File header @@ -77,18 +77,18 @@ class Header public function __construct($row) { $this->customer = new Customer(); - $this->customer->setCode(substr($row, 1, 56)); + $this->customer->setCode((int) substr($row, 1, 56)); $this->customer->setName(substr($row, 83, 60)); $this->dealership = new Dealership(); - $this->dealership->setCode(substr($row, 57, 2)); + $this->dealership->setCode((int) substr($row, 57, 2)); $this->created = DateTime::createFromFormat('dmY', substr($row, 61, 8)); $this->occurrence = new Occurrence(); - $this->occurrence->setReturn(substr($row, 81, 2)); + $this->occurrence->setReturn((int) substr($row, 81, 2)); - $this->sequence = new Sequence(substr($row, 144, 6)); + $this->sequence = new Sequence((int) substr($row, 144, 6)); } /** diff --git a/src/Shipment/File.php b/src/Shipment/File.php index c0935ff..8cc5bb6 100644 --- a/src/Shipment/File.php +++ b/src/Shipment/File.php @@ -1,16 +1,16 @@ customer = $customer; $this->dealership = $dealership; diff --git a/src/Shipment/Partial/Detail.php b/src/Shipment/Partial/Detail.php index 1a96c74..2923df0 100644 --- a/src/Shipment/Partial/Detail.php +++ b/src/Shipment/Partial/Detail.php @@ -1,21 +1,21 @@ */ -class Detail +class Detail extends \stdClass { /** * Type of register @@ -213,10 +213,10 @@ public function render() $result = str_pad(self::TYPE, 1, Alphanumeric::FILL, Alphanumeric::ALIGN); // Consumer Unity from client - $result .= str_pad($this->consumerUnity->getNumber(), 13, Number::FILL, Number::ALIGN); + $result .= str_pad($this->consumerUnity->getNumber(), 13, Numeric::FILL, Numeric::ALIGN); // Value - $result .= str_pad(preg_replace('/[^0-9]+/', '', $this->getPrice()->getPrice()), 9, Number::FILL, Number::ALIGN); + $result .= str_pad(preg_replace('/[^0-9]+/', '', $this->getPrice()->getPrice()), 9, Numeric::FILL, Numeric::ALIGN); // Maturity $result .= $this->getPrice()->getMaturity()->format(self::DATE_FORMAT); @@ -246,7 +246,7 @@ public function render() $result .= str_pad(' ', 11, Alphanumeric::FILL, Alphanumeric::ALIGN); // sequence number from line - $result .= str_pad($this->sequence->getValue(), 6, Number::FILL, Number::ALIGN); + $result .= str_pad($this->sequence->getValue(), 6, Numeric::FILL, Numeric::ALIGN); // resulting.... return $result; diff --git a/src/Shipment/Partial/Footer.php b/src/Shipment/Partial/Footer.php index a6ecbba..ddcceb5 100644 --- a/src/Shipment/Partial/Footer.php +++ b/src/Shipment/Partial/Footer.php @@ -1,9 +1,9 @@ sum), 11, Number::FILL, Number::ALIGN); + $result .= str_pad(str_replace('.', '', $this->sum), 11, Numeric::FILL, Numeric::ALIGN); // whitespace $result .= str_pad(' ', 132, Alphanumeric::FILL, Alphanumeric::ALIGN); // sequence line - $result .= str_pad($this->sequence->getValue(), 6, Number::FILL, Number::ALIGN); + $result .= str_pad($this->sequence->getValue(), 6, Numeric::FILL, Numeric::ALIGN); // resulting... return $result; diff --git a/src/Shipment/Partial/Header.php b/src/Shipment/Partial/Header.php index 574cd30..3f4432d 100644 --- a/src/Shipment/Partial/Header.php +++ b/src/Shipment/Partial/Header.php @@ -2,11 +2,11 @@ namespace MrPrompt\Celesc\Shipment\Partial; use DateTime; -use MrPrompt\Celesc\Common\Base\Dealership; -use MrPrompt\Celesc\Common\Base\Customer; -use MrPrompt\Celesc\Common\Base\Sequence; -use MrPrompt\Celesc\Common\Type\Number; -use MrPrompt\Celesc\Common\Type\Alphanumeric; +use MrPrompt\ShipmentCommon\Base\Dealership; +use MrPrompt\ShipmentCommon\Base\Customer; +use MrPrompt\ShipmentCommon\Base\Sequence; +use MrPrompt\ShipmentCommon\Type\Numeric; +use MrPrompt\ShipmentCommon\Type\Alphanumeric; /** * File header @@ -174,7 +174,7 @@ public function render() $line .= str_pad(self::CURRENCY, 6, Alphanumeric::FILL, Alphanumeric::ALIGN); // sequence file - $line .= str_pad($this->sequence->getValue(), 6, Number::FILL, Number::ALIGN); + $line .= str_pad($this->sequence->getValue(), 6, Numeric::FILL, Numeric::ALIGN); // Result code $line .= str_pad(' ', 2, Alphanumeric::FILL, Alphanumeric::ALIGN); @@ -189,7 +189,7 @@ public function render() $line .= self::CODE; // sequence line - $line .= str_pad(self::LINE, 6, Number::FILL, Number::ALIGN); + $line .= str_pad(self::LINE, 6, Numeric::FILL, Numeric::ALIGN); // resulting... return $line; diff --git a/src/Common/Util/ChangeProtectedAttribute.php b/tests/ChangeProtectedAttribute.php similarity index 93% rename from src/Common/Util/ChangeProtectedAttribute.php rename to tests/ChangeProtectedAttribute.php index 02daf89..d2a6403 100644 --- a/src/Common/Util/ChangeProtectedAttribute.php +++ b/tests/ChangeProtectedAttribute.php @@ -1,5 +1,5 @@ - */ -class AddressTest extends TestCase -{ - use ChangeProtectedAttribute; - - /** - * @var Address - */ - private $address; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->address = new Address(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->address = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::getCity() - */ - public function getCityReturnCityAttribute() - { - $this->modifyAttribute($this->address, 'city', 'foo'); - - $this->assertEquals('foo', $this->address->getCity()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setCity() - */ - public function setCityReturnNull() - { - $result = $this->address->setCity('foo'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setCity() - */ - public function setCityReturnNullWhenEmpty() - { - $result = $this->address->setCity(''); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setCity() - * @expectedException \InvalidArgumentException - */ - public function setCityThrowsExceptionWhenExceedMaxLength() - { - $city = str_pad('x', 201, 'x'); - $result = $this->address->setCity($city); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::getState() - */ - public function getStateReturnStateAttribute() - { - $state = 'SC'; - - $this->modifyAttribute($this->address, 'state', $state); - - $this->assertEquals($state, $this->address->getState()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setState() - */ - public function setStateReturnNull() - { - $this->assertNull($this->address->setState('SC')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setState() - */ - public function setStateReturnNullWhenEmpty() - { - $this->assertNull($this->address->setState('')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setState() - * @expectedException \InvalidArgumentException - */ - public function setStateThrowsExceptionWhenDiferentOfTwoChars() - { - $this->assertNull($this->address->setState('SCS')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::getPostalCode() - */ - public function getPostalCodeReturnPostalCodeAttribute() - { - $postalCode = '88090080'; - - $this->modifyAttribute($this->address, 'postalCode', $postalCode); - - $this->assertEquals($postalCode, $this->address->getPostalCode()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setPostalCode() - */ - public function setPostalCodeReturnNull() - { - $result = $this->address->setPostalCode('88080090'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setPostalCode() - * @expectedException \InvalidArgumentException - */ - public function setPostalCodeThrowsExceptionWhenExceedMaxLength() - { - $result = $this->address->setPostalCode('8808009012'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setPostalCode() - * @expectedException \InvalidArgumentException - */ - public function setPostalCodeThrowsExceptionWhenEmpty() - { - $result = $this->address->setPostalCode(''); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setPostalCode() - * @expectedException \InvalidArgumentException - */ - public function setPostalCodeThrowsExceptionWhenMinorOfMinLength() - { - $result = $this->address->setPostalCode('88090'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::getAddress() - */ - public function getAddressReturnAddressAttribute() - { - $address = 'fooo'; - - $this->modifyAttribute($this->address, 'address', $address); - - $this->assertEquals($address, $this->address->getAddress()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setAddress() - */ - public function setAddressReturnNull() - { - $this->assertNull($this->address->setAddress('foo')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setAddress() - */ - public function setAddressReturnNullWhemEmpty() - { - $this->assertNull($this->address->setAddress(' ')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setAddress() - * @expectedException \InvalidArgumentException - */ - public function setAddressThrowsExceptionWhenExceedMaxLength() - { - $this->assertNull($this->address->setAddress(str_pad('x', 160, 'x'))); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::getNumber() - */ - public function getNumberReturnNumberAttribute() - { - $number = 5; - - $this->modifyAttribute($this->address, 'number', $number); - - $this->assertEquals($number, $this->address->getNumber()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setNumber() - */ - public function setNumberReturnNull() - { - $this->assertNull($this->address->setNumber(1)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setNumber() - * @expectedException \InvalidArgumentException - */ - public function setNumberThrowsExceptionWhenNotNumber() - { - $this->assertNull($this->address->setNumber('A2')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::getDistrict() - */ - public function getDistrictReturnDistrictAttribute() - { - $district = 'allaa'; - - $this->modifyAttribute($this->address, 'district', $district); - - $this->assertEquals($district, $this->address->getDistrict()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setDistrict() - */ - public function setDistrictReturnNull() - { - $this->assertNull($this->address->setDistrict('lalala')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setDistrict() - * @expectedException \InvalidArgumentException - */ - public function setDistrictThrowsExceptionWhenExceedMaximumValue() - { - $this->assertNull($this->address->setDistrict(str_pad('x', 201, 'x'))); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::getComplement() - */ - public function getComplementReturnComplementAttribute() - { - $complement = 'lalala'; - - $this->modifyAttribute($this->address, 'complement', $complement); - - $this->assertEquals($complement, $this->address->getComplement()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setComplement() - */ - public function setComplementReturnNull() - { - $this->assertNull($this->address->setComplement('lalajd')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Address::setComplement() - * @expectedException \InvalidArgumentException - */ - public function setComplementThrowsExceptionWhenExceedMaximumValue() - { - $this->assertNull($this->address->setComplement(str_pad('x', 201, 'x'))); - } -} diff --git a/tests/Common/Base/AuthorizationTest.php b/tests/Common/Base/AuthorizationTest.php deleted file mode 100644 index 8cf2a80..0000000 --- a/tests/Common/Base/AuthorizationTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - */ -class AuthorizationTest extends TestCase -{ - use ChangeProtectedAttribute; - - /** - * @var Authorization - */ - private $authorization; - - /** - * Prepares the environment before running a test. - */ - public function setUp() - { - parent::setUp(); - - $this->authorization = new Authorization(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Authorization::getNumber - */ - public function getNumberMustBeReturnNumberAttribute() - { - $this->modifyAttribute($this->authorization, 'number', 1); - - $this->assertEquals(1, $this->authorization->getNumber()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Authorization::setNumber - */ - public function setNumberMustBeReturnNull() - { - $result = $this->authorization->setNumber('lajskfsla'); - - $this->assertNull($result); - } -} diff --git a/tests/Common/Base/BankAccountTest.php b/tests/Common/Base/BankAccountTest.php deleted file mode 100644 index 5cb8898..0000000 --- a/tests/Common/Base/BankAccountTest.php +++ /dev/null @@ -1,235 +0,0 @@ - - */ -class BankAccountTest extends TestCase -{ - use ChangeProtectedAttribute; - use CelescMock; - - /** - * @var BankAccount - */ - private $bank; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->bank = new BankAccount( - $this->bankMock(), - $this->holderMock() - ); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->bank = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::getNumber() - */ - public function getNumberReturnAccountAttribute() - { - $account = 332; - - $this->modifyAttribute($this->bank, 'account', $account); - - $this->assertEquals($account, $this->bank->getNumber()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::getDigit() - */ - public function getDigitReturnAccountDigitAttribute() - { - $digit = 03; - - $this->modifyAttribute($this->bank, 'accountDigit', $digit); - - $this->assertEquals($digit, $this->bank->getDigit()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::getOperation() - */ - public function getOperationReturnAccountOperationAttribute() - { - $operation = 013; - - $this->modifyAttribute($this->bank, 'accountOperation', $operation); - - $this->assertEquals($operation, $this->bank->getOperation()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::getBank() - */ - public function getBankReturnBankAttribute() - { - $bank = $this->bankMock(); - - $this->modifyAttribute($this->bank, 'bank', $bank); - - $this->assertEquals($bank, $this->bank->getBank()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::getSecurity() - */ - public function getSecurityReturnSecurityAttribute() - { - $security = 'N'; - - $this->modifyAttribute($this->bank, 'security', $security); - - $this->assertEquals($security, $this->bank->getSecurity()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::getHolder() - */ - public function getHolderReturnHolderAttribute() - { - $holder = $this->holderMock(); - - $this->modifyAttribute($this->bank, 'holder', $holder); - - $this->assertEquals($holder, $this->bank->getHolder()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::setNumber() - */ - public function setNumberReturnNull() - { - $this->assertNull($this->bank->setNumber(233)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::setNumber() - * @expectedException \InvalidArgumentException - */ - public function setNumberThrowsExceptionWhenReceiveNotNumberValue() - { - $this->assertNull($this->bank->setNumber('XDS')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::setDigit() - */ - public function setDigitReturnNull() - { - $this->assertNull($this->bank->setDigit(233)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::setDigit() - * @expectedException \InvalidArgumentException - */ - public function setDigitThrowsExceptionWhenReceiveNotNumberValue() - { - $this->assertNull($this->bank->setDigit('XDE')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::setOperation() - */ - public function setOperationReturnNull() - { - $this->assertNull($this->bank->setOperation(233)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::setOperation() - * @expectedException \InvalidArgumentException - */ - public function setOperationThrowsExceptionWhenReceiveNotNumberValue() - { - $this->assertNull($this->bank->setOperation('XDS')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::setSecurity() - */ - public function setSecurityReturnNull() - { - $this->assertNull($this->bank->setSecurity(true)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::setSecurity() - * @expectedException \InvalidArgumentException - */ - public function setSecurityThrowsExceptionWhenReceiveNotBooleanValue() - { - $this->assertNull($this->bank->setSecurity('S')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::setBank() - */ - public function setBankReturnNull() - { - $this->assertNull($this->bank->setBank($this->bankMock())); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Celesc\Common\Base\BankAccount::setHolder() - */ - public function setHolderReturnNull() - { - $this->assertNull($this->bank->setHolder($this->holderMock())); - } -} diff --git a/tests/Common/Base/BankTest.php b/tests/Common/Base/BankTest.php deleted file mode 100644 index bb0d662..0000000 --- a/tests/Common/Base/BankTest.php +++ /dev/null @@ -1,148 +0,0 @@ - - */ -class BankTest extends TestCase -{ - use ChangeProtectedAttribute; - - /** - * @var Bank - */ - private $bank; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->bank = new Bank(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->bank = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Bank::getAgency() - */ - public function getAgencyReturnAgencyAttribute() - { - $agency = 55; - - $this->modifyAttribute($this->bank, 'agency', $agency); - - $this->assertEquals($agency, $this->bank->getAgency()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Bank::setAgency() - */ - public function setAgencyReturnNull() - { - $this->assertNull($this->bank->setAgency(55)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Bank::setAgency() - * @expectedException \InvalidArgumentException - */ - public function setAgencyThrowsExceptionWhenNotNumericValue() - { - $this->assertNull($this->bank->setAgency('SS')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Bank::getDigit() - */ - public function getDigitReturnDigitAttribute() - { - $agency = 55; - - $this->modifyAttribute($this->bank, 'digit', $agency); - - $this->assertEquals($agency, $this->bank->getDigit()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Bank::setDigit() - */ - public function setDigitReturnNull() - { - $this->assertNull($this->bank->setDigit(45)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Bank::setDigit() - * @expectedException \InvalidArgumentException - */ - public function setDigitThrowsExceptionWhenNotNumericValue() - { - $this->assertNull($this->bank->setDigit('AS')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Bank::getCode() - */ - public function getCodeMustBeReturnCodeAttribute() - { - $this->modifyAttribute($this->bank, 'code', Bank::SICRED); - - $this->assertEquals(Bank::SICRED, $this->bank->getCode()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Bank::setCode() - */ - public function setCodeMustBeReturnNull() - { - $result = $this->bank->setCode(Bank::SICRED); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Bank::setCode() - * @expectedException \InvalidArgumentException - */ - public function setCodeMustBeThrowsExceptionWhenReceiveStringName() - { - $this->bank->setCode('Banco do Brasil'); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Bank::setCode() - * @expectedException \InvalidArgumentException - */ - public function setCodeMustBeThrowsExceptionWhenReceiveInvalidCode() - { - $this->bank->setCode(0); - } -} diff --git a/tests/Common/Base/BilletTest.php b/tests/Common/Base/BilletTest.php deleted file mode 100644 index a37390d..0000000 --- a/tests/Common/Base/BilletTest.php +++ /dev/null @@ -1,191 +0,0 @@ - - */ -class BilletTest extends TestCase -{ - use ChangeProtectedAttribute; - use Mock; - - /** - * @var Billet - */ - private $billet; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->billet = new Billet(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->billet = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Billet::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Billet::getDetails() - */ - public function getDetailsReturnDetailsAttribute() - { - $this->assertInstanceOf(\ArrayObject::class, $this->billet->getDetails()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Billet::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Billet::setDetails() - */ - public function setDetailsMustBeReturnNull() - { - $result = $this->billet->setDetails(new \ArrayObject()); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Billet::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Billet::addDetail() - */ - public function addDetailMustBeReturnNull() - { - $detail = new Detail( - $this->sellerMock(), - $this->purchaserMock(), - $this->parcelsMock(), - $this->authorizationMock(), - $this->consumerUnityMock(), - $this->sequenceMock() - ); - - $result = $this->billet->addDetail($detail); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Billet::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Billet::getRate() - */ - public function getRateReturnRatesAttribute() - { - $rate = 1; - - $this->modifyAttribute($this->billet, 'rate', $rate); - - $this->assertEquals($rate, $this->billet->getRate()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Billet::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Billet::setRate() - */ - public function setRateMustBeReturnNull() - { - $result = $this->billet->setRate(1); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Billet::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Billet::getBankAccount() - */ - public function getBankAccountReturnBankaccountsAttribute() - { - $bankaccount = $this->bankAccountMock(); - - $this->modifyAttribute($this->billet, 'bankAccount', $bankaccount); - - $this->assertEquals($bankaccount, $this->billet->getBankAccount()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Billet::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Billet::setBankAccount() - */ - public function setBankAccountMustBeReturnNull() - { - $result = $this->billet->setBankAccount($this->bankAccountMock()); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Billet::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Billet::getAssignor() - */ - public function getAssignorReturnAssignorsAttribute() - { - $assignor = $this->sellerMock(); - - $this->modifyAttribute($this->billet, 'assignor', $assignor); - - $this->assertEquals($assignor, $this->billet->getAssignor()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Billet::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Billet::setAssignor() - */ - public function setAssignorMustBeReturnNull() - { - $result = $this->billet->setAssignor($this->sellerMock()); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Billet::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Billet::getNumber() - */ - public function getNumberReturnNumbersAttribute() - { - $number = 1; - - $this->modifyAttribute($this->billet, 'number', 1); - - $this->assertEquals(1, $this->billet->getNumber()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Billet::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Billet::setNumber() - */ - public function setNumberMustBeReturnNull() - { - $result = $this->billet->setNumber(1); - - $this->assertNull($result); - } -} diff --git a/tests/Common/Base/CartTest.php b/tests/Common/Base/CartTest.php deleted file mode 100644 index c755591..0000000 --- a/tests/Common/Base/CartTest.php +++ /dev/null @@ -1,83 +0,0 @@ - - */ -class CartTest extends TestCase -{ - use ChangeProtectedAttribute; - - /** - * @var Cart - */ - private $cart; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $item = m::mock(Detail::class); - - $this->cart = new Cart([$item]); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->cart = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Cart::addItem() - */ - public function addItem() - { - $item = m::mock(Detail::class); - - $result = $this->cart->addItem($item); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Cart::removeItem() - */ - public function removeItem() - { - $item = 0; - $result = $this->cart->removeItem($item); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Cart::removeItem() - * @expectedException \InvalidArgumentException - */ - public function removeItemAbsentThrowsException() - { - $item = 1; - $result = $this->cart->removeItem($item); - - $this->assertNull($result); - } -} diff --git a/tests/Common/Base/ChargeTest.php b/tests/Common/Base/ChargeTest.php deleted file mode 100644 index cc0fdf1..0000000 --- a/tests/Common/Base/ChargeTest.php +++ /dev/null @@ -1,97 +0,0 @@ - - */ -class ChargeTest extends TestCase -{ - use ChangeProtectedAttribute; - use Mock; - - /** - * @var Charge - */ - private $charge; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->charge = new Charge(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->charge = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Charge::getCharging() - */ - public function getChargingReturnChargingAttribute() - { - $charging = Charge::ENERGY; - - $this->modifyAttribute($this->charge, 'charging', $charging); - - $this->assertEquals($charging, $this->charge->getCharging()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Charge::setCharging() - */ - public function setChargingReturnNull() - { - $this->assertNull($this->charge->setCharging(Charge::ENERGY)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Charge::setCharging() - * @expectedException \InvalidArgumentException - */ - public function setChargingThrowsExceptionWhenNotValidChargingType() - { - $this->assertNull($this->charge->setCharging('CC')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Charge::getOccurrence() - */ - public function getOccurrenceReturnOccurrenceAttribute() - { - $occurrence = 'I'; - - $this->modifyAttribute($this->charge, 'occurrence', $occurrence); - - $this->assertEquals($occurrence, $this->charge->getOccurrence()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Charge::setOccurrence() - */ - public function setOccurrenceReturnNull() - { - $this->assertNull($this->charge->setOccurrence($this->occurrenceMock())); - } -} diff --git a/tests/Common/Base/ClientTest.php b/tests/Common/Base/ClientTest.php deleted file mode 100644 index 1b3c882..0000000 --- a/tests/Common/Base/ClientTest.php +++ /dev/null @@ -1,78 +0,0 @@ - - */ -class ClientTest extends TestCase -{ - use ChangeProtectedAttribute; - - /** - * @var Client - */ - private $client; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->client = new Client(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->client = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Client::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Client::getCode() - */ - public function getCodeReturnCodeAttribute() - { - $this->modifyAttribute($this->client, 'code', 1); - - $this->assertEquals($this->client->getCode(), 1); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Client::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Client::setCode() - * @covers \MrPrompt\Celesc\Common\Base\Client::getCode() - */ - public function setCodeChangeCodeAttribute() - { - $this->client->setCode(1); - - $this->assertEquals($this->client->getCode(), 1); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Client::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Client::setCode() - * @expectedException InvalidArgumentException - */ - public function setCodeOnlyAcceptIntegerValue() - { - $this->client->setCode('A'); - } -} diff --git a/tests/Common/Base/ConsumerUnityTest.php b/tests/Common/Base/ConsumerUnityTest.php deleted file mode 100644 index f3fef6d..0000000 --- a/tests/Common/Base/ConsumerUnityTest.php +++ /dev/null @@ -1,161 +0,0 @@ - - */ -class ConsumerUnityTest extends TestCase -{ - use ChangeProtectedAttribute; - - /** - * @var ConsumerUnity - */ - private $unity; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->unity = new ConsumerUnity(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->unity = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\ConsumerUnity::__construct() - * @covers \MrPrompt\Celesc\Common\Base\ConsumerUnity::getNumber() - */ - public function getNumberReturnNumberAttribute() - { - $number = rand(); - - $this->modifyAttribute($this->unity, 'number', $number); - - $this->assertEquals($number, $this->unity->getNumber()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\ConsumerUnity::__construct() - * @covers \MrPrompt\Celesc\Common\Base\ConsumerUnity::setNumber() - */ - public function setNumberReturnNull() - { - $this->assertNull($this->unity->setNumber(rand())); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\ConsumerUnity::__construct() - * @covers \MrPrompt\Celesc\Common\Base\ConsumerUnity::setNumber() - * @expectedException \InvalidArgumentException - */ - public function setNumberThrowsExceptionWhenEmpty() - { - $this->assertNull($this->unity->setNumber('')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\ConsumerUnity::__construct() - * @covers \MrPrompt\Celesc\Common\Base\ConsumerUnity::getRead() - */ - public function getReadReturnReadAttribute() - { - $read = new \DateTime(); - - $this->modifyAttribute($this->unity, 'read', $read); - - $this->assertSame($read, $this->unity->getRead()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\ConsumerUnity::__construct() - * @covers \MrPrompt\Celesc\Common\Base\ConsumerUnity::setRead() - */ - public function setReadReturnNull() - { - $this->assertNull($this->unity->setRead(new \DateTime())); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\ConsumerUnity::__construct() - * @covers \MrPrompt\Celesc\Common\Base\ConsumerUnity::getMaturity() - */ - public function getMaturityReturnMaturityAttribute() - { - $read = new \DateTime(); - - $this->modifyAttribute($this->unity, 'maturity', $read); - - $this->assertSame($read, $this->unity->getMaturity()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\ConsumerUnity::__construct() - * @covers \MrPrompt\Celesc\Common\Base\ConsumerUnity::setMaturity() - */ - public function setMaturityReturnNull() - { - $this->assertNull($this->unity->setMaturity(new \DateTime())); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Consumerunity::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Consumerunity::getCode() - */ - public function getCodeReturnCodeAttribute() - { - $this->modifyAttribute($this->unity, 'code', 1); - - $this->assertEquals($this->unity->getCode(), 1); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Consumerunity::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Consumerunity::setCode() - * @covers \MrPrompt\Celesc\Common\Base\Consumerunity::getCode() - */ - public function setCodeChangeCodeAttribute() - { - $this->unity->setCode(1); - - $this->assertEquals($this->unity->getCode(), 1); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Consumerunity::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Consumerunity::setCode() - * @expectedException InvalidArgumentException - */ - public function setCodeCouldNotBeEmpty() - { - $this->unity->setCode(''); - } -} diff --git a/tests/Common/Base/CustomerTest.php b/tests/Common/Base/CustomerTest.php deleted file mode 100644 index 7fe4fe9..0000000 --- a/tests/Common/Base/CustomerTest.php +++ /dev/null @@ -1,231 +0,0 @@ - - */ -class CustomerTest extends TestCase -{ - use ChangeProtectedAttribute; - - /** - * @var Customer - */ - private $customer; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->customer = new Customer(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->customer = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::getCode() - */ - public function getCodeReturnCodeAttribute() - { - $this->modifyAttribute($this->customer, 'code', 1); - - $this->assertEquals($this->customer->getCode(), 1); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::setCode() - */ - public function setCodeMustBeReturnNullWhenReceiveIntegerValue() - { - $this->assertNull($this->customer->setCode(1)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::setCode() - */ - public function setCodeMustBeReturnNullWhenReceiveNotNumericValue() - { - $this->assertNull($this->customer->setCode('A')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::setCode() - * @expectedException \InvalidArgumentException - */ - public function setCodeOnlyThrowsExceptionWhenEmpty() - { - $this->customer->setCode(''); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::setCode() - */ - public function setCodeMustBeReturnNullWhenReceiveFloatValue() - { - $this->assertNull($this->customer->setCode(7.9837)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::getIdentityNumber() - */ - public function getIdentityNumberReturnIdentityNumberAttribute() - { - $this->modifyAttribute($this->customer, 'identityNumber', 1); - - $this->assertEquals($this->customer->getIdentityNumber(), 1); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::setIdentityNumber() - */ - public function setIdentityNumberReturnNullWhenReceiveNumericValue() - { - $this->assertNull($this->customer->setIdentityNumber(1)); - $this->assertNull($this->customer->setIdentityNumber(1.5)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::setIdentityNumber() - * @expectedException \InvalidArgumentException - */ - public function setIdentityNumberThrowsExceptionWhenNotNumericValue() - { - $this->customer->setIdentityNumber('A'); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::setIdentityNumber() - * @expectedException \InvalidArgumentException - */ - public function setIdentityNumberThrowsExceptionWhenEmpty() - { - $this->customer->setIdentityNumber(''); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::getWorkingDays() - */ - public function getWorkingDaysReturnWorkingDaysAttribute() - { - $this->modifyAttribute($this->customer, 'workingDays', 1); - - $this->assertEquals($this->customer->getWorkingDays(), 1); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::setWorkingDays() - */ - public function setWorkingDaysReturnNullWhenReceiveNumericValue() - { - $this->assertNull($this->customer->setWorkingDays(1)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::setWorkingDays() - * @expectedException \InvalidArgumentException - */ - public function setWorkingDaysThrowsExceptionWhenNotNumericValue() - { - $this->customer->setWorkingDays('A'); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::setWorkingDays() - * @expectedException \InvalidArgumentException - */ - public function setWorkingDaysThrowsExceptionWhenEmpty() - { - $this->customer->setWorkingDays(''); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::setWorkingDays() - * @expectedException \InvalidArgumentException - */ - public function setWorkingDaysThrowsExceptionWhenNotInteger() - { - $this->customer->setWorkingDays(5.43); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::getHelpfulMaturity() - */ - public function getHelpfulMaturityReturnHelpfulMaturityAttribute() - { - $this->modifyAttribute($this->customer, 'helpfulMaturity', true); - - $this->assertTrue($this->customer->getHelpfulMaturity()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::setHelpfulMaturity() - */ - public function setHelpfulMaturityReturnNullWhenReceiveBooleanValue() - { - $this->assertNull($this->customer->setHelpfulMaturity(true)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::setHelpfulMaturity() - * @expectedException \InvalidArgumentException - */ - public function setHelpfulMaturityThrowsExceptionWhenNotBooleanValue() - { - $this->customer->setHelpfulMaturity('A'); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::setHelpfulMaturity() - * @expectedException \InvalidArgumentException - */ - public function setHelpfulMaturityThrowsExceptionWhenReceiveEmpty() - { - $this->customer->setHelpfulMaturity(''); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Customer::setHelpfulMaturity() - * @expectedException \InvalidArgumentException - */ - public function setHelpfulMaturityThrowsExceptionWhenNumeric() - { - $this->customer->setHelpfulMaturity(5.43); - } -} diff --git a/tests/Common/Base/DealershipTest.php b/tests/Common/Base/DealershipTest.php deleted file mode 100644 index 6263ff4..0000000 --- a/tests/Common/Base/DealershipTest.php +++ /dev/null @@ -1,90 +0,0 @@ - - */ -class DealershipTest extends TestCase -{ - use ChangeProtectedAttribute; - - /** - * @var Dealership - */ - private $dealership; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->dealership = new Dealership(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Dealership::getCode() - */ - public function getCodeReturnCodeAttribute() - { - $this->modifyAttribute($this->dealership, 'code', 1); - - $this->assertEquals(1, $this->dealership->getCode()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Dealership::setCode() - */ - public function setCodeMustBeReturnNull() - { - $this->assertNull($this->dealership->setCode('1')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Dealership::getName() - */ - public function getNameReturnNameAttribute() - { - $this->modifyAttribute($this->dealership, 'name', 1); - - $this->assertEquals(1, $this->dealership->getName()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Dealership::setName() - */ - public function setNameMustBeReturnNull() - { - $this->assertNull($this->dealership->setName('1')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Dealership::setName() - * @expectedException \InvalidArgumentException - */ - public function setNameThrowsExceptionWhenEmpty() - { - $this->assertNull($this->dealership->setName('')); - } -} diff --git a/tests/Common/Base/DocumentTest.php b/tests/Common/Base/DocumentTest.php deleted file mode 100644 index 183c1d4..0000000 --- a/tests/Common/Base/DocumentTest.php +++ /dev/null @@ -1,128 +0,0 @@ - - */ -class DocumentTest extends TestCase -{ - use ChangeProtectedAttribute; - - /** - * @var Document - */ - private $document; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->document = new Document(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - parent::tearDown(); - - $this->document = null; - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Document::__construct - * @covers \MrPrompt\Celesc\Common\Base\Document::getType - */ - public function getTypeMustBeReturnTypeAttribute() - { - $this->modifyAttribute($this->document, 'type', 2); - - $this->assertEquals(2, $this->document->getType()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Document::__construct - * @covers \MrPrompt\Celesc\Common\Base\Document::setType - */ - public function setTypeOnlyAcceptPreDefinedTypes() - { - $types = [Document::CNPJ, Document::CPF]; - $type = $types[ array_rand($types) ]; - - $result = $this->document->setType($type); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Document::__construct - * @covers \MrPrompt\Celesc\Common\Base\Document::setType - * @expectedException \InvalidArgumentException - */ - public function setTypeThrowsExceptionWhenInvalidtype() - { - $this->document->setType('PASSPORT'); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Document::__construct - * @covers \MrPrompt\Celesc\Common\Base\Document::setType - * @expectedException \InvalidArgumentException - */ - public function setTypeThrowsExceptionWhenEmptyValue() - { - $this->document->setType(''); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Document::__construct - * @covers \MrPrompt\Celesc\Common\Base\Document::getNumber - */ - public function getNumberMustBeReturnNumberAttribute() - { - $this->modifyAttribute($this->document, 'number', 2); - - $this->assertEquals(2, $this->document->getNumber()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Document::__construct - * @covers \MrPrompt\Celesc\Common\Base\Document::setNumber - */ - public function setNumberMustBeReturnNull() - { - $result = $this->document->setNumber('11122233344'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Document::__construct - * @covers \MrPrompt\Celesc\Common\Base\Document::setNumber - * @expectedException \InvalidArgumentException - */ - public function setNumberThrowsExceptionWhenExceedMaxLength() - { - $result = $this->document->setNumber(str_pad(0, 20, 0)); - - $this->assertNull($result); - } -} diff --git a/tests/Common/Base/EmailTest.php b/tests/Common/Base/EmailTest.php deleted file mode 100644 index 7ace841..0000000 --- a/tests/Common/Base/EmailTest.php +++ /dev/null @@ -1,135 +0,0 @@ - - */ -class EmailTest extends TestCase -{ - use ChangeProtectedAttribute; - use Mock; - - /** - * @var Email - */ - private $email; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->email = new Email('foo@foo.net'); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->email = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Email::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Email::getAddress() - */ - public function getAddressReturnAddressAttribute() - { - $address = 'foo@foo.net'; - - $this->modifyAttribute($this->email, 'address', $address); - - $this->assertEquals($address, $this->email->getAddress()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Email::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Email::setAddress() - */ - public function setAddressReturnNull() - { - $address = 'foo@foo.net'; - - $result = $this->email->setAddress($address); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Email::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Email::setAddress() - * @expectedException \InvalidArgumentException - */ - public function setAddressThrowsExceptionWhenAddressIsInvalid() - { - $address = '1234'; - - $result = $this->email->setAddress($address); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Email::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Email::getPrimary() - */ - public function getPrimaryReturnPrimaryAttribute() - { - $this->modifyAttribute($this->email, 'primary', true); - - $this->assertEquals(true, $this->email->getPrimary()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Email::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Email::isPrimary() - */ - public function isPrimaryReturnPrimaryAttribute() - { - $this->modifyAttribute($this->email, 'primary', true); - - $this->assertEquals(true, $this->email->isPrimary()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Email::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Email::setPrimary() - */ - public function setPrimaryReturnNull() - { - $result = $this->email->setPrimary(true); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Email::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Email::setPrimary() - * @expectedException \InvalidArgumentException - */ - public function setPrimaryThrowsExceptionPrimaryIsNotBoolean() - { - $result = $this->email->setPrimary('true'); - - $this->assertNull($result); - } -} diff --git a/tests/Common/Base/HolderTest.php b/tests/Common/Base/HolderTest.php deleted file mode 100644 index 83d36f9..0000000 --- a/tests/Common/Base/HolderTest.php +++ /dev/null @@ -1,92 +0,0 @@ - - */ -class HolderTest extends TestCase -{ - use ChangeProtectedAttribute; - - /** - * @var Holder - */ - private $holder; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->holder = new Holder(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->holder = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Holder::getCode() - */ - public function getCodeReturnCodeAttribute() - { - $this->modifyAttribute($this->holder, 'code', 1); - - $this->assertEquals($this->holder->getCode(), 1); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Holder::setCode() - */ - public function setCodeMustBeReturnNullWhenReceiveIntegerValue() - { - $this->assertNull($this->holder->setCode(1)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Holder::setCode() - * @expectedException \InvalidArgumentException - */ - public function setCodeThrowsExceptionWhenNotNumericValue() - { - $this->holder->setCode('A'); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Holder::setCode() - * @expectedException \InvalidArgumentException - */ - public function setCodeOnlyThrowsExceptionWhenEmpty() - { - $this->holder->setCode(''); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Holder::setCode() - * @expectedException \InvalidArgumentException - */ - public function setCodeOnlyThrowsExceptionWhenNotIntegerValue() - { - $this->holder->setCode(7.9837); - } -} diff --git a/tests/Common/Base/OccurrenceTest.php b/tests/Common/Base/OccurrenceTest.php deleted file mode 100644 index 8d04c78..0000000 --- a/tests/Common/Base/OccurrenceTest.php +++ /dev/null @@ -1,186 +0,0 @@ - - */ -class OccurrenceTest extends TestCase -{ - use ChangeProtectedAttribute; - - /** - * @var Occurrence - */ - private $occurrence; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->occurrence = new Occurrence(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - parent::tearDown(); - - $this->occurrence = null; - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Occurrence::getType() - */ - public function getTypeMustBeReturnTypeAttribute() - { - $types = [Occurrence::CANCEL, Occurrence::INSERT, Occurrence::UPDATE]; - $type = $types[ array_rand($types) ]; - - $this->modifyAttribute($this->occurrence, 'type', $type); - - $this->assertEquals($type, $this->occurrence->getType()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Occurrence::setType() - */ - public function setTypeOnlyAcceptPreDefinedTypes() - { - $types = [Occurrence::CANCEL, Occurrence::INSERT, Occurrence::UPDATE]; - $type = $types[ array_rand($types) ]; - - $result = $this->occurrence->setType($type); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Occurrence::setType() - * @expectedException \InvalidArgumentException - */ - public function setTypeThrowsExceptionWhenNotPredefinedTypes() - { - $type = 'X'; - - $this->occurrence->setType($type); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Occurrence::setType() - * @expectedException \InvalidArgumentException - */ - public function setTypeThrowsExceptionWhenEmpty() - { - $type = ' '; - - $this->occurrence->setType($type); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Occurrence::getReturn() - */ - public function getReturnMustBeReturnReturnAttribute() - { - $this->modifyAttribute($this->occurrence, 'return', 1); - - $this->assertEquals(1, $this->occurrence->getReturn()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Occurrence::setReturn() - */ - public function setReturnMustBeReturnNullWhenReceiveNumericValue() - { - $this->assertNull($this->occurrence->setReturn(1)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Occurrence::setReturn() - */ - public function setReturnMustBeReturnNullWhenNotReceiveAnyParameter() - { - $this->assertNull($this->occurrence->setReturn()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Occurrence::getDescription() - */ - public function getDescriptionMustBeReturnDescriptionAttribute() - { - $this->modifyAttribute($this->occurrence, 'description', 'foo'); - - $this->assertEquals('foo', $this->occurrence->getDescription()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Occurrence::setDescription() - */ - public function setDescriptionReturnNullWhenReceiveEmptyValue() - { - $this->assertNull($this->occurrence->setDescription('')); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Occurrence::setDescription() - */ - public function setDescriptionReturnNullWhenNotReceiveAnyParameter() - { - $this->assertNull($this->occurrence->setDescription()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Occurrence::setDescription() - * @expectedException \InvalidArgumentException - */ - public function setDescriptionThrowsExceptionWhenNotReceiveNotString() - { - $this->assertNull($this->occurrence->setDescription(33)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Occurrence::getDate() - */ - public function getDateMustBeReturnDateAttribute() - { - $date = new \DateTime(); - $this->modifyAttribute($this->occurrence, 'date', $date); - - $this->assertSame($date, $this->occurrence->getDate()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Occurrence::setDate() - */ - public function setDateMustBeReturnNull() - { - $date = new \DateTime(); - - $result = $this->occurrence->setDate($date); - - $this->assertNull($result); - } -} diff --git a/tests/Common/Base/ParcelTest.php b/tests/Common/Base/ParcelTest.php deleted file mode 100644 index 88c5e10..0000000 --- a/tests/Common/Base/ParcelTest.php +++ /dev/null @@ -1,189 +0,0 @@ - - */ -class ParcelTest extends TestCase -{ - use ChangeProtectedAttribute; - - /** - * @var Parcel - */ - private $parcel; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->parcel = new Parcel(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->parcel = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Parcel::getMaturity() - */ - public function getMaturity() - { - $maturity = new DateTime(); - - $this->modifyAttribute($this->parcel, 'maturity', $maturity); - - $this->assertSame($maturity, $this->parcel->getMaturity()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Parcel::setMaturity() - */ - public function setMaturity() - { - $result = $this->parcel->setMaturity(new DateTime()); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Parcel::getPrice() - */ - public function getPrice() - { - $price = 1.00; - - $this->modifyAttribute($this->parcel, 'price', $price); - - $this->assertEquals($price, $this->parcel->getPrice()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Parcel::setPrice() - */ - public function setPrice() - { - $result = $this->parcel->setPrice(1); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Parcel::setPrice() - * @expectedException \InvalidArgumentException - */ - public function setPriceThrowsExceptionWhenReceiveNotNumericValue() - { - $this->parcel->setPrice('SD'); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Parcel::setPrice() - * @expectedException \InvalidArgumentException - */ - public function setPriceThrowsExceptionWhenReceiveEmptyValue() - { - $this->parcel->setPrice(''); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Parcel::getKey() - */ - public function getKey() - { - $parcel = 1; - - $this->modifyAttribute($this->parcel, 'key', $parcel); - - $this->assertEquals($parcel, $this->parcel->getKey()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Parcel::setKey() - */ - public function setKey() - { - $result = $this->parcel->setKey(1); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Parcel::setKey() - * @expectedException \InvalidArgumentException - */ - public function setKeyThrowsExceptionWhenReceiveNotNumericValue() - { - $this->parcel->setKey('SD'); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Parcel::getQuantity() - */ - public function getQuantity() - { - $quantity = 1.00; - - $this->modifyAttribute($this->parcel, 'quantity', $quantity); - - $this->assertEquals($quantity, $this->parcel->getQuantity()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Parcel::setQuantity() - */ - public function setQuantity() - { - $result = $this->parcel->setQuantity(1); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Parcel::setQuantity() - * @expectedException \InvalidArgumentException - */ - public function setQuantityThrowsExceptionWhenReceiveNotNumericValue() - { - $this->parcel->setQuantity('SD'); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Parcel::setQuantity() - * @expectedException \InvalidArgumentException - */ - public function setQuantityThrowsExceptionWhenReceiveEmptyValue() - { - $this->parcel->setQuantity(''); - } -} diff --git a/tests/Common/Base/ParcelsTest.php b/tests/Common/Base/ParcelsTest.php deleted file mode 100644 index 8efbdec..0000000 --- a/tests/Common/Base/ParcelsTest.php +++ /dev/null @@ -1,55 +0,0 @@ - - */ -class ParcelsTest extends TestCase -{ - use ChangeProtectedAttribute; - use Mock; - - /** - * @var Parcels - */ - private $parcels; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->parcels = new Parcels(4); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->parcels = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Parcels::__construct - * @covers \MrPrompt\Celesc\Common\Base\Parcels::addParcel - */ - public function addParcelMustReturnNullWhenReceiveParcelObject() - { - $this->assertNull($this->parcels->addParcel($this->parcelMock())); - } -} diff --git a/tests/Common/Base/PersonTest.php b/tests/Common/Base/PersonTest.php deleted file mode 100644 index 0a164a6..0000000 --- a/tests/Common/Base/PersonTest.php +++ /dev/null @@ -1,374 +0,0 @@ - - */ -class PersonTest extends TestCase -{ - use ChangeProtectedAttribute; - use Mock; - - /** - * @var Person - */ - private $person; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->person = new Person(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->person = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::getDocument() - */ - public function getDocumentReturnDocumentAttribute() - { - $document = $this->documentMock(); - - $this->modifyAttribute($this->person, 'document', $document); - - $this->assertSame($document, $this->person->getDocument()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::setDocument() - */ - public function setDocumentReturnEmpty() - { - $document = $this->documentMock(); - - $this->assertNull($this->person->setDocument($document)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::getHomePhone() - */ - public function getHomePhoneReturnHomePhoneAttribute() - { - $telephone = $this->phoneMock(); - - $this->modifyAttribute($this->person, 'homePhone', $telephone); - - $this->assertSame($telephone, $this->person->getHomePhone()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::setHomePhone() - */ - public function setHomePhoneReturnEmpty() - { - $telephone = $this->phoneMock(); - - $result = $this->person->setHomePhone($telephone); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::getHomePhoneSecondary() - */ - public function getHomePhoneSecondaryReturnHomePhoneSecondaryAttribute() - { - $telephone = $this->phoneMock(); - - $this->modifyAttribute($this->person, 'homePhoneSecondary', $telephone); - - $this->assertSame($telephone, $this->person->getHomePhoneSecondary()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::setHomePhoneSecondary() - */ - public function setHomePhoneSecondaryReturnEmpty() - { - $telephone = $this->phoneMock(); - - $result = $this->person->setHomePhoneSecondary($telephone); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::getName() - */ - public function getNameReturnNameAttribute() - { - $this->modifyAttribute($this->person, 'name', 'foo'); - - $this->assertEquals('foo', $this->person->getName()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::setName() - */ - public function setNameReturnEmpty() - { - $result = $this->person->setName('foo'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::getEmail() - */ - public function getEmailReturnEmailAttribute() - { - $email = $this->emailMock(); - - $this->modifyAttribute($this->person, 'email', $email); - - $this->assertSame($email, $this->person->getEmail()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::setEmail() - */ - public function setEmailReturnEmpty() - { - $email = $this->emailMock(); - - $result = $this->person->setEmail($email); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::getCellPhone() - */ - public function getCellPhoneReturnCellPhoneAttribute() - { - $cel = $this->phoneMock(); - - $this->modifyAttribute($this->person, 'cellPhone', $cel); - - $this->assertEquals($cel, $this->person->getCellPhone()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::setCellPhone() - */ - public function setCellPhoneReturnEmpty() - { - $cel = $this->phoneMock(); - - $result = $this->person->setCellPhone($cel); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::getFatherName() - */ - public function getFatherNameReturnFatherNameAttribute() - { - $fatherName = 'bar'; - - $this->modifyAttribute($this->person, 'fatherName', $fatherName); - - $this->assertEquals($fatherName, $this->person->getFatherName()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::setFatherName() - */ - public function setFatherNameReturnEmpty() - { - $result = $this->person->setFatherName('bar'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::getMotherName() - */ - public function getMotherNameReturnMotherNameAttribute() - { - $motherName = 'bar'; - - $this->modifyAttribute($this->person, 'motherName', $motherName); - - $this->assertEquals($motherName, $this->person->getMotherName()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::setMotherName() - */ - public function setMotherNameReturnEmpty() - { - $result = $this->person->setMotherName('bar'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::getPerson() - */ - public function getPersonReturnPersonAttribute() - { - $person = 'F'; - - $this->modifyAttribute($this->person, 'person', $person); - - $this->assertEquals($person, $this->person->getPerson()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::setPerson() - */ - public function setPersonReturnEmpty() - { - $result = $this->person->setPerson('F'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::setPerson() - * @expectedException \InvalidArgumentException - */ - public function setPersonThrowsExceptionWhenEmpty() - { - $this->person->setPerson(''); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::getSalaried() - */ - public function getSalariedMustBeReturnSalariedAttribute() - { - $this->modifyAttribute($this->person, 'salaried', true); - - $this->assertEquals(true, $this->person->getSalaried()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::setSalaried() - */ - public function setSalariedMustBeReturnNull() - { - $salaried = true; - - $result = $this->person->setSalaried($salaried); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::getBirth() - */ - public function getBirthMustBeReturnBirthAttribute() - { - $birth = new \DateTime(); - $this->modifyAttribute($this->person, 'birth', $birth); - - $this->assertEquals($birth, $this->person->getBirth()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::setBirth() - */ - public function setBirthMustBeReturnNull() - { - $birth = new \DateTime(); - - $result = $this->person->setBirth($birth); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::getAddress() - */ - public function getAddressMustBeReturnAddressAttribute() - { - $address = new Address(); - $this->modifyAttribute($this->person, 'address', $address); - - $this->assertEquals($address, $this->person->getAddress()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Person::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Person::setAddress() - */ - public function setAddressMustBeReturnNull() - { - $address = new Address(); - - $result = $this->person->setAddress($address); - - $this->assertNull($result); - } -} diff --git a/tests/Common/Base/PhoneTest.php b/tests/Common/Base/PhoneTest.php deleted file mode 100644 index b399eab..0000000 --- a/tests/Common/Base/PhoneTest.php +++ /dev/null @@ -1,138 +0,0 @@ - - */ -class PhoneTest extends TestCase -{ - use ChangeProtectedAttribute; - use Mock; - - /** - * @var Phone - */ - private $phone; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->phone = new Phone(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->phone = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Phone::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Phone::getNumber() - */ - public function getNumberReturnNumberAttribute() - { - $this->modifyAttribute($this->phone, 'number', 1); - - $this->assertEquals(1, $this->phone->getNumber()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Phone::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Phone::setNumber() - */ - public function setNumberReturnNull() - { - $number = '12341234'; - - $result = $this->phone->setNumber($number); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Phone::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Phone::setNumber() - * @expectedException \InvalidArgumentException - */ - public function setNumberThrowsExceptionWhenNumberIsToShort() - { - $number = '1234'; - - $result = $this->phone->setNumber($number); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Phone::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Phone::setNumber() - * @expectedException \InvalidArgumentException - */ - public function setNumberThrowsExceptionWhenNumberIsToLong() - { - $number = '12343434234432423432233432'; - - $result = $this->phone->setNumber($number); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Phone::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Phone::getType() - */ - public function getTypeReturnTypeAttribute() - { - $this->modifyAttribute($this->phone, 'type', 1); - - $this->assertEquals(1, $this->phone->getType()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Phone::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Phone::setType() - */ - public function setTypeReturnNull() - { - $type = Phone::CELLPHONE; - - $result = $this->phone->setType($type); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Phone::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Phone::setType() - * @expectedException \InvalidArgumentException - */ - public function setTypeThrowsExceptionWhenNotInPreDefinedConstants() - { - $result = $this->phone->setType(4); - - $this->assertNull($result); - } -} diff --git a/tests/Common/Base/PurchaserTest.php b/tests/Common/Base/PurchaserTest.php deleted file mode 100644 index b7a94e4..0000000 --- a/tests/Common/Base/PurchaserTest.php +++ /dev/null @@ -1,115 +0,0 @@ - - */ -class PurchaserTest extends TestCase -{ - use ChangeProtectedAttribute; - - /** - * @var Purchaser - */ - private $purchaser; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->purchaser = new Purchaser(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->purchaser = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Purchaser::getPurchaserStateRegistration() - */ - public function getPurchaserStateRegistrationReturnPurchaserStateRegistrationAttribute() - { - $purchaser = 'foo'; - - $this->modifyAttribute($this->purchaser, 'purchaserStateRegistration', $purchaser); - - $this->assertEquals($purchaser, $this->purchaser->getPurchaserStateRegistration()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Purchaser::getPurchaserFantasyName() - */ - public function getPurchaserFantasyNameReturnPurchaserFantasyNameAttribute() - { - $purchaser = 'foo'; - - $this->modifyAttribute($this->purchaser, 'purchaserFantasyName', $purchaser); - - $this->assertEquals($purchaser, $this->purchaser->getPurchaserFantasyName()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Purchaser::getPurchaserSocialReason() - */ - public function getPurchaserSocialReasonReturnPurchaserSocialReasonAttribute() - { - $purchaser = 'foo'; - - $this->modifyAttribute($this->purchaser, 'purchaserSocialReason', $purchaser); - - $this->assertEquals($purchaser, $this->purchaser->getPurchaserSocialReason()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Purchaser::setPurchaserStateRegistration() - */ - public function setPurchaserStateRegistrationReturnEmpty() - { - $result = $this->purchaser->setPurchaserStateRegistration('Foo'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Purchaser::setPurchaserFantasyName() - */ - public function setPurchaserFantasyNameReturnEmpty() - { - $result = $this->purchaser->setPurchaserFantasyName(1); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Purchaser::setPurchaserSocialReason() - */ - public function setPurchaserSocialReasonReturnEmpty() - { - $result = $this->purchaser->setPurchaserSocialReason(1); - - $this->assertNull($result); - } -} diff --git a/tests/Common/Base/SellerTest.php b/tests/Common/Base/SellerTest.php deleted file mode 100644 index 0932329..0000000 --- a/tests/Common/Base/SellerTest.php +++ /dev/null @@ -1,74 +0,0 @@ - - */ -class SellerTest extends TestCase -{ - use ChangeProtectedAttribute; - - /** - * @var Seller - */ - private $seller; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->seller = new Seller(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->seller = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Seller::getCode() - */ - public function getCodeReturnCodeAttribute() - { - $this->modifyAttribute($this->seller, 'code', 1); - - $this->assertEquals($this->seller->getCode(), 1); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Seller::setCode() - */ - public function setCodeChangeCodeAttribute() - { - $this->seller->setCode(1); - - $this->assertEquals($this->seller->getCode(), 1); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Seller::setCode() - * @expectedException \InvalidArgumentException - */ - public function setCodeMustBeThrowsInvalidArgumentExceptionWhenEmpty() - { - $this->seller->setCode(''); - } -} diff --git a/tests/Common/Base/SequenceTest.php b/tests/Common/Base/SequenceTest.php deleted file mode 100644 index a0fd928..0000000 --- a/tests/Common/Base/SequenceTest.php +++ /dev/null @@ -1,67 +0,0 @@ - - */ -class SequenceTest extends TestCase -{ - use ChangeProtectedAttribute; - - /** - * @var Sequence - */ - private $sequence; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->sequence = new Sequence(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->sequence = null; - - parent::tearDown(); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Sequence::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Sequence::getValue() - */ - public function getValueReturnValueAttribute() - { - $this->modifyAttribute($this->sequence, 'value', 1); - - $this->assertEquals(1, $this->sequence->getValue()); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Base\Sequence::__construct() - * @covers \MrPrompt\Celesc\Common\Base\Sequence::setValue() - * @covers \MrPrompt\Celesc\Common\Base\Sequence::getValue() - */ - public function setValueModifyValueAttribute() - { - $this->sequence->setValue(1); - - $this->assertEquals(1, $this->sequence->getValue()); - } -} diff --git a/tests/Common/Util/NumberTest.php b/tests/Common/Util/NumberTest.php deleted file mode 100644 index c11bd74..0000000 --- a/tests/Common/Util/NumberTest.php +++ /dev/null @@ -1,77 +0,0 @@ - - */ -class NumberTest extends TestCase -{ - /** - * @test - * @covers \MrPrompt\Celesc\Common\Util\Number::zeroFill - */ - public function zeroFillMustBeReturnExactLengthWithoutFillSideParam() - { - $foo = Number::zeroFill(1, 10); - - $this->assertEquals(10, strlen($foo)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Util\Number::zeroFill - */ - public function zeroFillMustBeReturnExactStringWhenLengthIsEqualsWithoutFillSideParam() - { - $foo = Number::zeroFill(1, 3); - - $this->assertEquals(3, strlen($foo)); - } - /** - * @test - * @covers \MrPrompt\Celesc\Common\Util\Number::zeroFill - */ - public function zeroFillMustBeReturnExactLengthWithFillSideParam() - { - $foo = Number::zeroFill(1, 10, Number::FILL_LEFT); - - $this->assertEquals(10, strlen($foo)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Util\Number::zeroFill - */ - public function zeroFillMustBeReturnExactStringWhenLengthIsEqualsWithFillSideParam() - { - $foo = Number::zeroFill(1, 3, Number::FILL_LEFT); - - $this->assertEquals(3, strlen($foo)); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Util\Number::zeroFill - * @expectedException \InvalidArgumentException - */ - public function zeroFillThrowsExceptionWhenValueLengthIsGreaterThanLength() - { - Number::zeroFill(11111, 2); - } - - /** - * @test - * @covers \MrPrompt\Celesc\Common\Util\Number::zeroFill - */ - public function zeroFillThrowsExceptionWithoutParams() - { - $return = Number::zeroFill('', ''); - - $this->assertEmpty($return); - } -} diff --git a/tests/Mock.php b/tests/Mock.php index b517710..5a5e065 100644 --- a/tests/Mock.php +++ b/tests/Mock.php @@ -1,27 +1,27 @@