From 1c637ac01f6e82a1d5504a441fc109ed15071c76 Mon Sep 17 00:00:00 2001 From: Thiago Paes Date: Sat, 1 Dec 2018 01:12:18 -0200 Subject: [PATCH 1/4] refactory(shipment-common): Using ShipmentCommon project and remove Common namespace --- composer.json | 3 +- composer.lock | 68 +++- samples/cart.php | 10 +- samples/processado.php | 8 +- samples/recebido.php | 2 +- samples/remessa.php | 12 +- 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 | 147 ------- src/Common/Base/CreditCard.php | 168 -------- 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 | 143 ------- 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 | 51 --- src/Common/Type/Alphanumeric.php | 13 - src/Common/Type/Numeric.php | 13 - src/Common/Util/ChangeProtectedAttribute.php | 30 -- src/Common/Util/Number.php | 39 -- src/Factory.php | 40 +- src/Received/File.php | 6 +- src/Received/Partial/Detail.php | 18 +- src/Received/Partial/Footer.php | 2 +- src/Received/Partial/Header.php | 4 +- src/Shipment/File.php | 40 +- src/Shipment/Partial/Detail.php | 28 +- src/Shipment/Partial/Footer.php | 6 +- src/Shipment/Partial/Header.php | 8 +- tests/Common/Base/AddressTest.php | 325 ---------------- tests/Common/Base/AuthorizationTest.php | 66 ---- tests/Common/Base/BankAccountTest.php | 235 ------------ tests/Common/Base/BankTest.php | 151 -------- tests/Common/Base/BilletTest.php | 202 ---------- tests/Common/Base/CartTest.php | 86 ----- tests/Common/Base/ChargeTest.php | 104 ----- tests/Common/Base/ClientTest.php | 81 ---- tests/Common/Base/ConsumerUnityTest.php | 164 -------- tests/Common/Base/CreditCardTest.php | 214 ----------- tests/Common/Base/CustomerTest.php | 234 ------------ tests/Common/Base/DealershipTest.php | 103 ----- tests/Common/Base/DocumentTest.php | 131 ------- tests/Common/Base/EmailTest.php | 142 ------- tests/Common/Base/HolderTest.php | 95 ----- tests/Common/Base/OccurrenceTest.php | 229 ----------- tests/Common/Base/ParcelTest.php | 192 ---------- tests/Common/Base/ParcelsTest.php | 55 --- tests/Common/Base/PersonTest.php | 381 ------------------- tests/Common/Base/PhoneTest.php | 145 ------- tests/Common/Base/PurchaserTest.php | 118 ------ tests/Common/Base/SellerTest.php | 77 ---- tests/Common/Base/SequenceTest.php | 70 ---- tests/Common/Util/NumberTest.php | 77 ---- tests/Mock.php | 44 +-- tests/Received/FileTest.php | 12 +- tests/Received/Partial/DetailTest.php | 20 +- tests/Received/Partial/FooterTest.php | 6 +- tests/Received/Partial/HeaderTest.php | 8 +- tests/Shipment/FileTest.php | 12 +- tests/Shipment/Partial/DetailTest.php | 26 +- tests/Shipment/Partial/FooterTest.php | 4 +- tests/Shipment/Partial/HeaderTest.php | 6 +- 75 files changed, 226 insertions(+), 6428 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/CreditCard.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/Numeric.php delete mode 100644 src/Common/Util/ChangeProtectedAttribute.php delete mode 100755 src/Common/Util/Number.php 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/CreditCardTest.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/composer.json b/composer.json index 53a9420..4e89bd6 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,8 @@ ], "require": { "php": "^7.1", - "respect/validation": "^1.1.12" + "respect/validation": "^1.1.12", + "mrprompt/shipmentcommon": "dev-master" }, "require-dev": { "phpunit/phpunit": "^6.1.3", diff --git a/composer.lock b/composer.lock index 99d8a31..68d4bbf 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,65 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cb1e4977d8f101399a6ba5d04ff8ab31", + "content-hash": "916ae34e618011d060875f7ac155d3ec", "packages": [ + { + "name": "mrprompt/shipmentcommon", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/mrprompt/ShipmentCommon.git", + "reference": "98de4f3cfeed9fcb7032047e6acc7a008e7baec8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mrprompt/ShipmentCommon/zipball/98de4f3cfeed9fcb7032047e6acc7a008e7baec8", + "reference": "98de4f3cfeed9fcb7032047e6acc7a008e7baec8", + "shasum": "" + }, + "require": { + "php": "^7.1", + "respect/validation": "^1.1.12" + }, + "require-dev": { + "mockery/mockery": "dev-master@dev", + "phpunit/phpunit": "^6.1.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "MrPrompt\\ShipmentCommon\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-3.0-or-later" + ], + "authors": [ + { + "name": "Thiago Paes", + "email": "mrprompt@gmail.com", + "role": "Developer" + }, + { + "name": "Johnathan Cardoso", + "email": "git@spamhunter.johnathan.com.br", + "role": "Collaborator" + }, + { + "name": "Walter Discher Cechinel", + "email": "mistrim@gmail.com", + "role": "Collaborator" + }, + { + "name": "Luís Otávio Cobucci Oblonczyk", + "email": "lcobucci@gmail.com", + "role": "Collaborator" + } + ], + "description": "Common classes used in remittance libraries.", + "time": "2018-12-01T03:02:58+00:00" + }, { "name": "respect/validation", "version": "1.1.29", @@ -284,12 +341,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 +398,7 @@ "test double", "testing" ], - "time": "2018-10-12T09:41:15+00:00" + "time": "2018-11-22T06:31:11+00:00" }, { "name": "myclabs/deep-copy", @@ -1753,6 +1810,7 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { + "mrprompt/shipmentcommon": 20, "mockery/mockery": 20 }, "prefer-stable": false, diff --git a/samples/cart.php b/samples/cart.php index d227556..0fef0ab 100644 --- a/samples/cart.php +++ b/samples/cart.php @@ -4,11 +4,11 @@ * * @author Thiago Paes */ -use MrPrompt\Centercob\Common\Base\Bank; -use MrPrompt\Centercob\Common\Base\Charge; -use MrPrompt\Centercob\Common\Base\ConsumerUnity; -use MrPrompt\Centercob\Common\Base\CreditCard; -use MrPrompt\Centercob\Common\Base\Occurrence; +use MrPrompt\ShipmentCommon\Base\Bank; +use MrPrompt\ShipmentCommon\Base\Charge; +use MrPrompt\ShipmentCommon\Base\ConsumerUnity; +use MrPrompt\ShipmentCommon\Base\CreditCard; +use MrPrompt\ShipmentCommon\Base\Occurrence; /* @var $vencimento \DateTime */ $vencimento = (new DateTime())->add(new DateInterval('P30D')); diff --git a/samples/processado.php b/samples/processado.php index 792ea9a..f26dbeb 100644 --- a/samples/processado.php +++ b/samples/processado.php @@ -6,7 +6,7 @@ * * @author Thiago Paes */ -use MrPrompt\Centercob\Common\Base\Sequence; +use MrPrompt\ShipmentCommon\Base\Sequence; use MrPrompt\Centercob\Shipment\File; use MrPrompt\Centercob\Factory; @@ -19,10 +19,10 @@ /* @var $date \DateTime */ $date = new DateTime('2015-05-27'); - /* @var $sequence \MrPrompt\Centercob\Common\Base\Sequence */ + /* @var $sequence \MrPrompt\ShipmentCommon\Base\Sequence */ $sequence = new Sequence(6); - /* @var $customer \MrPrompt\Centercob\Common\Base\Customer */ + /* @var $customer \MrPrompt\ShipmentCommon\Base\Customer */ $customer = Factory::createCustomerFromArray(array_shift($lista)); /* @var $importer \MrPrompt\Centercob\Shipment\File */ @@ -31,7 +31,7 @@ // importing file data $result = $importer->read(); - /* @var \MrPrompt\Centercob\Common\Base\Cart */ + /* @var \MrPrompt\ShipmentCommon\Base\Cart */ $cart = $importer->getCart(); /* @var $lista array */ diff --git a/samples/recebido.php b/samples/recebido.php index 91af741..642b256 100644 --- a/samples/recebido.php +++ b/samples/recebido.php @@ -15,7 +15,7 @@ $lista = require __DIR__ . '/cart.php'; try { - /* @var $customer \MrPrompt\Centercob\Common\Base\Customer */ + /* @var $customer \MrPrompt\ShipmentCommon\Base\Customer */ $customer = Factory::createCustomerFromArray(array_shift($lista)); $date = new DateTime('2015-05-19 18:54:42'); diff --git a/samples/remessa.php b/samples/remessa.php index 247f736..ddcbea8 100644 --- a/samples/remessa.php +++ b/samples/remessa.php @@ -8,22 +8,22 @@ */ use MrPrompt\Centercob\Factory; use MrPrompt\Centercob\Shipment\File; -use MrPrompt\Centercob\Common\Base\Cart; -use MrPrompt\Centercob\Common\Base\Sequence; +use MrPrompt\ShipmentCommon\Base\Cart; +use MrPrompt\ShipmentCommon\Base\Sequence; require __DIR__ . '/../bootstrap.php'; /* @var $today \DateTime */ $today = new DateTime(); -/* @var $cart \MrPrompt\Centercob\Common\Base\Cart */ +/* @var $cart \MrPrompt\ShipmentCommon\Base\Cart */ $cart = new Cart(); /* @var $lista array */ $lista = require __DIR__ . '/cart.php'; foreach ($lista as $linha) { - if (in_array($linha['cobranca'], [\MrPrompt\Centercob\Common\Base\Charge::BILLET, \MrPrompt\Centercob\Common\Base\Charge::PAYMENT_SLIP])) { + if (in_array($linha['cobranca'], [\MrPrompt\ShipmentCommon\Base\Charge::BILLET, \MrPrompt\ShipmentCommon\Base\Charge::PAYMENT_SLIP])) { continue; } @@ -47,10 +47,10 @@ } try { - /* @var $sequence \MrPrompt\Centercob\Common\Base\Sequence */ + /* @var $sequence \MrPrompt\ShipmentCommon\Base\Sequence */ $sequence = new Sequence(8); - /* @var $customer \MrPrompt\Centercob\Common\Base\Customer */ + /* @var $customer \MrPrompt\ShipmentCommon\Base\Customer */ $customer = Factory::createCustomerFromArray(array_shift($lista)); /* @var $exporter \MrPrompt\Centercob\Shipment\File */ diff --git a/src/Common/Base/Address.php b/src/Common/Base/Address.php deleted file mode 100644 index c585861..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 c69ac68..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::length(0, 20)->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 7ebfed9..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 afdfae7..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 94081de..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 660537c..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 c2aa93d..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 983dace..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 57bdbc4..0000000 --- a/src/Common/Base/ConsumerUnity.php +++ /dev/null @@ -1,147 +0,0 @@ - - */ -class ConsumerUnity -{ - const BANDEIRANTE = 1; - const CPFL = 3; - const CPFL_PIRATININGA = 4; - const AMPLA = 5; - const ESCELSA_ES = 19; - const CELESC = 26; - const RGE_RS = 31; - const COELCE = 73; - - /** - * @var array - */ - private $codes = [ - self::BANDEIRANTE, - self::CPFL, - self::CPFL_PIRATININGA, - self::AMPLA, - self::ESCELSA_ES, - self::CELESC, - self::RGE_RS, - self::COELCE, - ]; - - /** - * @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()->numeric()->in($this->codes)->assert($code); - - $this->code = $code; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid consumer unity value %s', $code)); - } - } -} diff --git a/src/Common/Base/CreditCard.php b/src/Common/Base/CreditCard.php deleted file mode 100644 index 8002adb..0000000 --- a/src/Common/Base/CreditCard.php +++ /dev/null @@ -1,168 +0,0 @@ - - */ -class CreditCard -{ - const AMEX = 38; - const MASTERCARD = 39; - const HIPERCARD = 40; - const DINNERS = 41; - const DISCOVER = 45; - const VISA = 42; - const AURA = 51; - const ELO = 60; - const GOODCARD = 61; - const JCB = 62; - const MAIS = 63; - const CABAL = 64; - const SOROCRED = 65; - const SICREDI = 66; - const COOPERCRED = 67; - const AVISTA = 68; - - /** - * Valid flags - * - * @var array - */ - private $flags = [ - self::AMEX, - self::MASTERCARD, - self::HIPERCARD, - self::DINNERS, - self::DISCOVER, - self::VISA, - self::AURA, - self::ELO, - self::GOODCARD, - self::JCB, - self::MAIS, - self::CABAL, - self::SOROCRED, - self::SICREDI, - self::COOPERCRED, - self::AVISTA - ]; - - /** - * - * @var numeric - */ - private $number; - - /** - * - * @var DateTime - */ - private $validate; - - /** - * - * @var numeric - */ - private $security; - - /** - * @var numeric - */ - private $flag; - - /** - * Constructor - */ - public function __construct() - { - $this->validate = new DateTime(); - } - - /** - * @return the $number - */ - public function getNumber() - { - return $this->number; - } - - /** - * @param string $number - */ - public function setNumber($number) - { - try { - Validator::create()->notEmpty()->creditCard()->assert($number); - - $this->number = $number; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid credit card number: %s', $number)); - } - } - - /** - * @return the $validate - */ - public function getValidate() - { - return $this->validate; - } - - /** - * @param DateTime $validate - */ - public function setValidate(DateTime $validate) - { - $this->validate = $validate; - } - - /** - * @return the $security - */ - public function getSecurityNumber() - { - return $this->security; - } - - /** - * @param string $security - */ - public function setSecurityNumber($security) - { - try { - Validator::create()->notEmpty()->numeric()->assert($security); - - $this->security = $security; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid security number: %s', $security)); - } - } - - /** - * @return string - */ - public function getFlag() - { - return $this->flag; - } - - /** - * @param string $flag - */ - public function setFlag($flag) - { - try { - Validator::create()->notEmpty()->numeric()->in($this->flags)->assert($flag); - - $this->flag = $flag; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid flag: %s', $flag)); - } - } -} diff --git a/src/Common/Base/Customer.php b/src/Common/Base/Customer.php deleted file mode 100644 index 9c212e8..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 16f304b..0000000 --- a/src/Common/Base/Dealership.php +++ /dev/null @@ -1,71 +0,0 @@ - - */ -class Dealership -{ - /** - * @var int - */ - private $code; - - /** - * @var string - */ - private $name; - - /** - * Return the dealeship code - * - * @return int - */ - public function getCode() - { - return $this->code; - } - - /** - * Dealership code - * - * @param int $code - */ - public function setCode($code) - { - try { - Validator::stringType()->length(null, 6)->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 f64c887..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 9ea3901..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 20875e9..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 b98e500..0000000 --- a/src/Common/Base/Occurrence.php +++ /dev/null @@ -1,143 +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) - { - try { - Validator::numeric()->assert($return); - - $this->return = $return; - } catch (AllOfException $ex) { - throw new \InvalidArgumentException(sprintf('Invalid occurrence return value: %s', $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 1f2a985..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 84f410d..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 e97ab3f..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 f3cfd56..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 fa82a88..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 76bf30e..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 d21d3f1..0000000 --- a/src/Common/Base/Sequence.php +++ /dev/null @@ -1,51 +0,0 @@ - - */ -class Sequence -{ - /** - * @var int - */ - private $value; - - /** - * Construtor - * - * @param string $value - */ - public function __construct($value = 1) - { - $this->setValue($value); - } - - /** - * Return the value from sequence - * - * @return int - */ - public function getValue() - { - return $this->value; - } - - /** - * Set the value from sequence - * - * @param int $value - * @return void - * @throws InvalidArgumentException - */ - public function setValue($value) - { - $this->value = (int) $value; - } -} diff --git a/src/Common/Type/Alphanumeric.php b/src/Common/Type/Alphanumeric.php deleted file mode 100644 index 7e85bac..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/Numeric.php b/src/Common/Type/Numeric.php deleted file mode 100644 index e15f827..0000000 --- a/src/Common/Type/Numeric.php +++ /dev/null @@ -1,13 +0,0 @@ - - */ -abstract class Numeric -{ - const ALIGN = STR_PAD_LEFT; - const FILL = 0; -} \ No newline at end of file diff --git a/src/Common/Util/ChangeProtectedAttribute.php b/src/Common/Util/ChangeProtectedAttribute.php deleted file mode 100644 index 5e108de..0000000 --- a/src/Common/Util/ChangeProtectedAttribute.php +++ /dev/null @@ -1,30 +0,0 @@ - - */ -trait ChangeProtectedAttribute -{ - /** - * Configures the attribute with the given value - * - * @param object $object - * @param string $name - * @param mixed $value - */ - public function modifyAttribute($object, $name, $value) - { - $attribute = new ReflectionProperty($object, $name); - - $attribute->setAccessible(true); - $attribute->setValue($object, $value); - } -} diff --git a/src/Common/Util/Number.php b/src/Common/Util/Number.php deleted file mode 100755 index a4f8960..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 ba653b3..5da73d1 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -2,27 +2,27 @@ namespace MrPrompt\Centercob; use DateTime; -use MrPrompt\Centercob\Common\Base\Address; -use MrPrompt\Centercob\Common\Base\Authorization; -use MrPrompt\Centercob\Common\Base\Bank; -use MrPrompt\Centercob\Common\Base\BankAccount; -use MrPrompt\Centercob\Common\Base\Billet; -use MrPrompt\Centercob\Common\Base\Charge; -use MrPrompt\Centercob\Common\Base\ConsumerUnity; -use MrPrompt\Centercob\Common\Base\CreditCard; -use MrPrompt\Centercob\Common\Base\Customer; -use MrPrompt\Centercob\Common\Base\Document; -use MrPrompt\Centercob\Common\Base\Email; -use MrPrompt\Centercob\Common\Base\Holder; -use MrPrompt\Centercob\Common\Base\Occurrence; -use MrPrompt\Centercob\Common\Base\Parcel; -use MrPrompt\Centercob\Common\Base\Parcels; -use MrPrompt\Centercob\Common\Base\Person; -use MrPrompt\Centercob\Common\Base\Phone; -use MrPrompt\Centercob\Common\Base\Purchaser; -use MrPrompt\Centercob\Common\Base\Seller; -use MrPrompt\Centercob\Common\Base\Sequence; +use MrPrompt\ShipmentCommon\Base\Bank; +use MrPrompt\ShipmentCommon\Base\Email; +use MrPrompt\ShipmentCommon\Base\Phone; +use MrPrompt\ShipmentCommon\Base\Billet; +use MrPrompt\ShipmentCommon\Base\Charge; +use MrPrompt\ShipmentCommon\Base\Holder; +use MrPrompt\ShipmentCommon\Base\Parcel; +use MrPrompt\ShipmentCommon\Base\Person; +use MrPrompt\ShipmentCommon\Base\Seller; +use MrPrompt\ShipmentCommon\Base\Address; +use MrPrompt\ShipmentCommon\Base\Parcels; +use MrPrompt\ShipmentCommon\Base\Customer; +use MrPrompt\ShipmentCommon\Base\Document; +use MrPrompt\ShipmentCommon\Base\Sequence; +use MrPrompt\ShipmentCommon\Base\Purchaser; +use MrPrompt\ShipmentCommon\Base\CreditCard; +use MrPrompt\ShipmentCommon\Base\Occurrence; +use MrPrompt\ShipmentCommon\Base\BankAccount; use MrPrompt\Centercob\Shipment\Partial\Detail; +use MrPrompt\ShipmentCommon\Base\Authorization; +use MrPrompt\ShipmentCommon\Base\ConsumerUnity; /** * Common base factory diff --git a/src/Received/File.php b/src/Received/File.php index caee966..2c16385 100644 --- a/src/Received/File.php +++ b/src/Received/File.php @@ -2,9 +2,9 @@ namespace MrPrompt\Centercob\Received; use DateTime; -use MrPrompt\Centercob\Common\Base\Cart; -use MrPrompt\Centercob\Common\Base\Customer; -use MrPrompt\Centercob\Common\Util\Number; +use MrPrompt\ShipmentCommon\Base\Cart; +use MrPrompt\ShipmentCommon\Base\Customer; +use MrPrompt\ShipmentCommon\Util\Number; use MrPrompt\Centercob\Received\Partial\Detail; use MrPrompt\Centercob\Received\Partial\Footer; use MrPrompt\Centercob\Received\Partial\Header; diff --git a/src/Received/Partial/Detail.php b/src/Received/Partial/Detail.php index 6518ad9..482f204 100644 --- a/src/Received/Partial/Detail.php +++ b/src/Received/Partial/Detail.php @@ -1,15 +1,15 @@ - */ -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\Centercob\Common\Base\Address::getCity() - */ - public function getCityReturnCityAttribute() - { - $this->modifyAttribute($this->address, 'city', 'foo'); - - $this->assertEquals('foo', $this->address->getCity()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setCity() - */ - public function setCityReturnNull() - { - $result = $this->address->setCity('foo'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setCity() - */ - public function setCityReturnNullWhenEmpty() - { - $result = $this->address->setCity(''); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\Address::getState() - */ - public function getStateReturnStateAttribute() - { - $state = 'SC'; - - $this->modifyAttribute($this->address, 'state', $state); - - $this->assertEquals($state, $this->address->getState()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setState() - */ - public function setStateReturnNull() - { - $this->assertNull($this->address->setState('SC')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setState() - */ - public function setStateReturnNullWhenEmpty() - { - $this->assertNull($this->address->setState('')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setState() - * @expectedException \InvalidArgumentException - */ - public function setStateThrowsExceptionWhenDiferentOfTwoChars() - { - $this->assertNull($this->address->setState('SCS')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::getPostalCode() - */ - public function getPostalCodeReturnPostalCodeAttribute() - { - $postalCode = '88090080'; - - $this->modifyAttribute($this->address, 'postalCode', $postalCode); - - $this->assertEquals($postalCode, $this->address->getPostalCode()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setPostalCode() - */ - public function setPostalCodeReturnNull() - { - $result = $this->address->setPostalCode('88080090'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setPostalCode() - * @expectedException \InvalidArgumentException - */ - public function setPostalCodeThrowsExceptionWhenExceedMaxLength() - { - $result = $this->address->setPostalCode('8808009012'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setPostalCode() - * @expectedException \InvalidArgumentException - */ - public function setPostalCodeThrowsExceptionWhenEmpty() - { - $result = $this->address->setPostalCode(''); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setPostalCode() - * @expectedException \InvalidArgumentException - */ - public function setPostalCodeThrowsExceptionWhenMinorOfMinLength() - { - $result = $this->address->setPostalCode('88090'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::getAddress() - */ - public function getAddressReturnAddressAttribute() - { - $address = 'fooo'; - - $this->modifyAttribute($this->address, 'address', $address); - - $this->assertEquals($address, $this->address->getAddress()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setAddress() - */ - public function setAddressReturnNull() - { - $this->assertNull($this->address->setAddress('foo')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setAddress() - */ - public function setAddressReturnNullWhemEmpty() - { - $this->assertNull($this->address->setAddress(' ')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setAddress() - * @expectedException \InvalidArgumentException - */ - public function setAddressThrowsExceptionWhenExceedMaxLength() - { - $this->assertNull($this->address->setAddress(str_pad('x', 160, 'x'))); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::getNumber() - */ - public function getNumberReturnNumberAttribute() - { - $number = 5; - - $this->modifyAttribute($this->address, 'number', $number); - - $this->assertEquals($number, $this->address->getNumber()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setNumber() - */ - public function setNumberReturnNull() - { - $this->assertNull($this->address->setNumber(1)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setNumber() - * @expectedException \InvalidArgumentException - */ - public function setNumberThrowsExceptionWhenNotNumber() - { - $this->assertNull($this->address->setNumber('A2')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::getDistrict() - */ - public function getDistrictReturnDistrictAttribute() - { - $district = 'allaa'; - - $this->modifyAttribute($this->address, 'district', $district); - - $this->assertEquals($district, $this->address->getDistrict()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setDistrict() - */ - public function setDistrictReturnNull() - { - $this->assertNull($this->address->setDistrict('lalala')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setDistrict() - * @expectedException \InvalidArgumentException - */ - public function setDistrictThrowsExceptionWhenExceedMaximumValue() - { - $this->assertNull($this->address->setDistrict(str_pad('x', 201, 'x'))); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::getComplement() - */ - public function getComplementReturnComplementAttribute() - { - $complement = 'lalala'; - - $this->modifyAttribute($this->address, 'complement', $complement); - - $this->assertEquals($complement, $this->address->getComplement()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Address::setComplement() - */ - public function setComplementReturnNull() - { - $this->assertNull($this->address->setComplement('lalajd')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\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 d8330be..0000000 --- a/tests/Common/Base/AuthorizationTest.php +++ /dev/null @@ -1,66 +0,0 @@ - - */ -class AuthorizationTest extends TestCase -{ - /** - * @see \Centercob\Tests\ChangeProctedAttribute - */ - use ChangeProtectedAttribute; - - /** - * @var Authorization - */ - private $authorization; - - public function setUp() - { - parent::setUp(); - - $this->authorization = new Authorization(); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Authorization::getNumber - */ - public function getNumberMustBeReturnNumberAttribute() - { - $this->modifyAttribute($this->authorization, 'number', 1); - - $this->assertEquals(1, $this->authorization->getNumber()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Authorization::setNumber - */ - public function setNumberMustBeReturnNull() - { - $result = $this->authorization->setNumber('lajskfsla'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Authorization::setNumber - * @expectedException \InvalidArgumentException - */ - public function setNumberThrowsExceptionWhenExceedMaximumValue() - { - $number = str_pad('x', 25, 'x'); - $result = $this->authorization->setNumber($number); - - $this->assertNull($result); - } -} diff --git a/tests/Common/Base/BankAccountTest.php b/tests/Common/Base/BankAccountTest.php deleted file mode 100644 index a4583d0..0000000 --- a/tests/Common/Base/BankAccountTest.php +++ /dev/null @@ -1,235 +0,0 @@ - - */ -class BankAccountTest extends TestCase -{ - use ChangeProtectedAttribute; - use CentercobMock; - - /** - * @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\Centercob\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::getNumber() - */ - public function getNumberReturnAccountAttribute() - { - $account = 332; - - $this->modifyAttribute($this->bank, 'account', $account); - - $this->assertEquals($account, $this->bank->getNumber()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::getDigit() - */ - public function getDigitReturnAccountDigitAttribute() - { - $digit = 03; - - $this->modifyAttribute($this->bank, 'accountDigit', $digit); - - $this->assertEquals($digit, $this->bank->getDigit()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::getOperation() - */ - public function getOperationReturnAccountOperationAttribute() - { - $operation = 013; - - $this->modifyAttribute($this->bank, 'accountOperation', $operation); - - $this->assertEquals($operation, $this->bank->getOperation()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::getSecurity() - */ - public function getSecurityReturnSecurityAttribute() - { - $security = 'N'; - - $this->modifyAttribute($this->bank, 'security', $security); - - $this->assertEquals($security, $this->bank->getSecurity()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::setNumber() - */ - public function setNumberReturnNull() - { - $this->assertNull($this->bank->setNumber(233)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::setNumber() - * @expectedException \InvalidArgumentException - */ - public function setNumberThrowsExceptionWhenReceiveNotNumberValue() - { - $this->assertNull($this->bank->setNumber('XDS')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::setDigit() - */ - public function setDigitReturnNull() - { - $this->assertNull($this->bank->setDigit(233)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::setDigit() - * @expectedException \InvalidArgumentException - */ - public function setDigitThrowsExceptionWhenReceiveNotNumberValue() - { - $this->assertNull($this->bank->setDigit('XDE')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::setOperation() - */ - public function setOperationReturnNull() - { - $this->assertNull($this->bank->setOperation(233)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::setOperation() - * @expectedException \InvalidArgumentException - */ - public function setOperationThrowsExceptionWhenReceiveNotNumberValue() - { - $this->assertNull($this->bank->setOperation('XDS')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::setSecurity() - */ - public function setSecurityReturnNull() - { - $this->assertNull($this->bank->setSecurity(true)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::setSecurity() - * @expectedException \InvalidArgumentException - */ - public function setSecurityThrowsExceptionWhenReceiveNotBooleanValue() - { - $this->assertNull($this->bank->setSecurity('S')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::setBank() - */ - public function setBankReturnNull() - { - $this->assertNull($this->bank->setBank($this->bankMock())); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\BankAccount::__construct() - * @covers \MrPrompt\Centercob\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 a688ef4..0000000 --- a/tests/Common/Base/BankTest.php +++ /dev/null @@ -1,151 +0,0 @@ - - */ -class BankTest extends TestCase -{ - /** - * @see \Centercob\Tests\ChangeProctedAttribute - */ - 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\Centercob\Common\Base\Bank::getAgency() - */ - public function getAgencyReturnAgencyAttribute() - { - $agency = 55; - - $this->modifyAttribute($this->bank, 'agency', $agency); - - $this->assertEquals($agency, $this->bank->getAgency()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Bank::setAgency() - */ - public function setAgencyReturnNull() - { - $this->assertNull($this->bank->setAgency(55)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Bank::setAgency() - * @expectedException \InvalidArgumentException - */ - public function setAgencyThrowsExceptionWhenNotNumericValue() - { - $this->assertNull($this->bank->setAgency('SS')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Bank::getDigit() - */ - public function getDigitReturnDigitAttribute() - { - $agency = 55; - - $this->modifyAttribute($this->bank, 'digit', $agency); - - $this->assertEquals($agency, $this->bank->getDigit()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Bank::setDigit() - */ - public function setDigitReturnNull() - { - $this->assertNull($this->bank->setDigit(45)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Bank::setDigit() - * @expectedException \InvalidArgumentException - */ - public function setDigitThrowsExceptionWhenNotNumericValue() - { - $this->assertNull($this->bank->setDigit('AS')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Bank::getCode() - */ - public function getCodeMustBeReturnCodeAttribute() - { - $this->modifyAttribute($this->bank, 'code', Bank::SICRED); - - $this->assertEquals(Bank::SICRED, $this->bank->getCode()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Bank::setCode() - */ - public function setCodeMustBeReturnNull() - { - $result = $this->bank->setCode(Bank::SICRED); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Bank::setCode() - * @expectedException \InvalidArgumentException - */ - public function setCodeMustBeThrowsExceptionWhenReceiveStringName() - { - $this->bank->setCode('Banco do Brasil'); - } - - /** - * @test - * @covers \MrPrompt\Centercob\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 b9aec2f..0000000 --- a/tests/Common/Base/BilletTest.php +++ /dev/null @@ -1,202 +0,0 @@ - - */ -class BilletTest extends TestCase -{ - /** - * @see \Centercob\Common\Util\ChangeProctedAttribute - */ - use ChangeProtectedAttribute; - - /** - * @see \Centercob\Tests\Gateway\Mock - */ - 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\Centercob\Common\Base\Billet::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Billet::getDetails() - */ - public function getDetailsReturnDetailsAttribute() - { - $this->assertInstanceOf(\ArrayObject::class, $this->billet->getDetails()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Billet::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Billet::setDetails() - */ - public function setDetailsMustBeReturnNull() - { - $result = $this->billet->setDetails(new \ArrayObject()); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Billet::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Billet::addDetail() - */ - public function addDetailMustBeReturnNull() - { - $detail = new Detail( - $this->customerMock(), - $this->chargeMock(), - $this->sellerMock(), - $this->purchaserMock(), - $this->parcelsMock(), - $this->authorizationMock(), - $this->creditCardMock(), - $this->bankAccountMock(), - $this->consumerUnityMock(), - $this->sequenceMock() - ); - - $result = $this->billet->addDetail($detail); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Billet::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Billet::getRate() - */ - public function getRateReturnRatesAttribute() - { - $rate = 1; - - $this->modifyAttribute($this->billet, 'rate', $rate); - - $this->assertEquals($rate, $this->billet->getRate()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Billet::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Billet::setRate() - */ - public function setRateMustBeReturnNull() - { - $result = $this->billet->setRate(1); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Billet::__construct() - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\Billet::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Billet::setBankAccount() - */ - public function setBankAccountMustBeReturnNull() - { - $result = $this->billet->setBankAccount($this->bankAccountMock()); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Billet::__construct() - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\Billet::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Billet::setAssignor() - */ - public function setAssignorMustBeReturnNull() - { - $result = $this->billet->setAssignor($this->sellerMock()); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Billet::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Billet::getNumber() - */ - public function getNumberReturnNumbersAttribute() - { - $number = 1; - - $this->modifyAttribute($this->billet, 'number', 1); - - $this->assertEquals(1, $this->billet->getNumber()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Billet::__construct() - * @covers \MrPrompt\Centercob\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 65f2b3d..0000000 --- a/tests/Common/Base/CartTest.php +++ /dev/null @@ -1,86 +0,0 @@ - - */ -class CartTest extends TestCase -{ - /** - * @see \Centercob\Tests\ChangeProctedAttribute - */ - 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\Centercob\Common\Base\Cart::addItem() - */ - public function addItem() - { - $item = m::mock(Detail::class); - - $result = $this->cart->addItem($item); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Cart::removeItem() - */ - public function removeItem() - { - $item = 0; - $result = $this->cart->removeItem($item); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\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 a9c5d57..0000000 --- a/tests/Common/Base/ChargeTest.php +++ /dev/null @@ -1,104 +0,0 @@ - - */ -class ChargeTest extends TestCase -{ - /** - * @see \Centercob\Tests\ChangeProctedAttribute - */ - use ChangeProtectedAttribute; - - /** - * @see \Centercob\Tests\Gateway\Mock - */ - 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\Centercob\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\Centercob\Common\Base\Charge::setCharging() - */ - public function setChargingReturnNull() - { - $this->assertNull($this->charge->setCharging(Charge::ENERGY)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Charge::setCharging() - * @expectedException \InvalidArgumentException - */ - public function setChargingThrowsExceptionWhenNotValidChargingType() - { - $this->assertNull($this->charge->setCharging('CC')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Charge::getOccurrence() - */ - public function getOccurrenceReturnOccurrenceAttribute() - { - $occurrence = 'I'; - - $this->modifyAttribute($this->charge, 'occurrence', $occurrence); - - $this->assertEquals($occurrence, $this->charge->getOccurrence()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\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 fc09079..0000000 --- a/tests/Common/Base/ClientTest.php +++ /dev/null @@ -1,81 +0,0 @@ - - */ -class ClientTest extends TestCase -{ - /** - * @see \Centercob\Tests\ChangeProctedAttribute - */ - 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\Centercob\Common\Base\Client::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Client::getCode() - */ - public function getCodeReturnCodeAttribute() - { - $this->modifyAttribute($this->client, 'code', 1); - - $this->assertEquals($this->client->getCode(), 1); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Client::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Client::setCode() - * @covers \MrPrompt\Centercob\Common\Base\Client::getCode() - */ - public function setCodeChangeCodeAttribute() - { - $this->client->setCode(1); - - $this->assertEquals($this->client->getCode(), 1); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Client::__construct() - * @covers \MrPrompt\Centercob\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 9b8028b..0000000 --- a/tests/Common/Base/ConsumerUnityTest.php +++ /dev/null @@ -1,164 +0,0 @@ - - */ -class ConsumerUnityTest extends TestCase -{ - /** - * @see \Centercob\Tests\ChangeProctedAttribute - */ - 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\Centercob\Common\Base\ConsumerUnity::__construct() - * @covers \MrPrompt\Centercob\Common\Base\ConsumerUnity::getNumber() - */ - public function getNumberReturnNumberAttribute() - { - $number = rand(); - - $this->modifyAttribute($this->unity, 'number', $number); - - $this->assertEquals($number, $this->unity->getNumber()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\ConsumerUnity::__construct() - * @covers \MrPrompt\Centercob\Common\Base\ConsumerUnity::setNumber() - */ - public function setNumberReturnNull() - { - $this->assertNull($this->unity->setNumber(rand())); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\ConsumerUnity::__construct() - * @covers \MrPrompt\Centercob\Common\Base\ConsumerUnity::setNumber() - * @expectedException \InvalidArgumentException - */ - public function setNumberThrowsExceptionWhenEmpty() - { - $this->assertNull($this->unity->setNumber('')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\ConsumerUnity::__construct() - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\ConsumerUnity::__construct() - * @covers \MrPrompt\Centercob\Common\Base\ConsumerUnity::setRead() - */ - public function setReadReturnNull() - { - $this->assertNull($this->unity->setRead(new \DateTime())); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\ConsumerUnity::__construct() - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\ConsumerUnity::__construct() - * @covers \MrPrompt\Centercob\Common\Base\ConsumerUnity::setMaturity() - */ - public function setMaturityReturnNull() - { - $this->assertNull($this->unity->setMaturity(new \DateTime())); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Consumerunity::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Consumerunity::getCode() - */ - public function getCodeReturnCodeAttribute() - { - $this->modifyAttribute($this->unity, 'code', 1); - - $this->assertEquals($this->unity->getCode(), 1); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Consumerunity::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Consumerunity::setCode() - * @covers \MrPrompt\Centercob\Common\Base\Consumerunity::getCode() - */ - public function setCodeChangeCodeAttribute() - { - $this->unity->setCode(1); - - $this->assertEquals($this->unity->getCode(), 1); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Consumerunity::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Consumerunity::setCode() - * @expectedException InvalidArgumentException - */ - public function setCodeOnlyAcceptIntegerValue() - { - $this->unity->setCode('A'); - } -} diff --git a/tests/Common/Base/CreditCardTest.php b/tests/Common/Base/CreditCardTest.php deleted file mode 100644 index da0aae7..0000000 --- a/tests/Common/Base/CreditCardTest.php +++ /dev/null @@ -1,214 +0,0 @@ - - */ -class CreditCardTest extends TestCase -{ - /** - * @see \Centercob\Tests\ChangeProctedAttribute - */ - use ChangeProtectedAttribute; - - /** - * @var CreditCard - */ - private $card; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->card = new CreditCard(); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - parent::tearDown(); - } - - /** - * @return array - */ - public function loadCardsProvider() - { - return [ - [ - [ - 'number' => '4012001037141112', - 'validate' => '201512', - 'security' => '123', - 'flag' => 68 - ] - ] - ]; - - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::__construct() - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::getNumber() - */ - public function getNumberReturnNumberAttribute() - { - $this->modifyAttribute($this->card, 'number', 1); - - $this->assertEquals(1, $this->card->getNumber()); - } - - /** - * @test - * @dataProvider loadCardsProvider - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::__construct() - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::setNumber() - */ - public function setNumberReturnNull($card) - { - $this->assertNull($this->card->setNumber($card['number'])); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::__construct() - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::setNumber() - * @expectedException \InvalidArgumentException - */ - public function setNumberThrowsExceptionWhenNotValidCard() - { - $this->card->setNumber('333232'); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::__construct() - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::setNumber() - * @expectedException \InvalidArgumentException - */ - public function setNumberThrowsExceptionWhenEmpty() - { - $this->card->setNumber(''); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::__construct() - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::setNumber() - * @expectedException \InvalidArgumentException - */ - public function setNumberThrowsExceptionWhenNotNumericValue() - { - $this->card->setNumber('938SDS@'); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::__construct() - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::getValidate() - */ - public function getValidateMustBeReturnCreditCardValidateAttribute() - { - $validate = new DateTime(); - - $this->modifyAttribute($this->card, 'validate', $validate); - - $this->assertSame($validate, $this->card->getValidate()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::__construct() - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::setValidate() - */ - public function setValidateMustBeReturnNull() - { - $this->assertNull($this->card->setValidate(new DateTime())); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::__construct - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::getSecurityNumber - */ - public function getSecurityNumberMustBeReturnCreditCardSecurityNumberAttribute() - { - $this->modifyAttribute($this->card, 'security', 232); - - $this->assertSame(232, $this->card->getSecurityNumber()); - } - - /** - * @test - * @dataProvider loadCardsProvider - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::__construct() - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::setSecurityNumber() - */ - public function setSecurityNumberMustBeReturnNull($card) - { - $this->assertNull($this->card->setSecurityNumber($card['security'])); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::__construct - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::setSecurityNumber - * @expectedException \InvalidArgumentException - */ - public function setSecurityNumberrThrowsExceptionNotNumericValue() - { - $this->card->setSecurityNumber('SDS'); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::__construct() - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::getFlag() - */ - public function getFlagMustBeReturnFlagAttribute() - { - $this->modifyAttribute($this->card, 'flag', CreditCard::VISA); - - $this->assertEquals(CreditCard::VISA, $this->card->getFlag()); - } - - /** - * @test - * @dataProvider loadCardsProvider - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::__construct() - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::setFlag() - */ - public function setFlagMustBeReturnNull($card) - { - $result = $this->card->setFlag($card['flag']); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::__construct() - * @covers \MrPrompt\Centercob\Common\Base\CreditCard::setFlag() - * @expectedException \InvalidArgumentException - */ - public function setFlagMustBeReturnThrowsExceptionWhenEmpty() - { - $result = $this->card->setFlag('Mastercard'); - - $this->assertNull($result); - } -} diff --git a/tests/Common/Base/CustomerTest.php b/tests/Common/Base/CustomerTest.php deleted file mode 100644 index 739b845..0000000 --- a/tests/Common/Base/CustomerTest.php +++ /dev/null @@ -1,234 +0,0 @@ - - */ -class CustomerTest extends TestCase -{ - /** - * @see \Centercob\Common\Util\ChangeProtectedAttribute - */ - 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\Centercob\Common\Base\Customer::getCode() - */ - public function getCodeReturnCodeAttribute() - { - $this->modifyAttribute($this->customer, 'code', 1); - - $this->assertEquals($this->customer->getCode(), 1); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::setCode() - */ - public function setCodeMustBeReturnNullWhenReceiveIntegerValue() - { - $this->assertNull($this->customer->setCode(1)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::setCode() - */ - public function setCodeMustBeReturnNullWhenReceiveNotNumericValue() - { - $this->assertNull($this->customer->setCode('A')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::setCode() - * @expectedException \InvalidArgumentException - */ - public function setCodeOnlyThrowsExceptionWhenEmpty() - { - $this->customer->setCode(''); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::setCode() - */ - public function setCodeMustBeReturnNullWhenReceiveFloatValue() - { - $this->assertNull($this->customer->setCode(7.9837)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::getIdentityNumber() - */ - public function getIdentityNumberReturnIdentityNumberAttribute() - { - $this->modifyAttribute($this->customer, 'identityNumber', 1); - - $this->assertEquals($this->customer->getIdentityNumber(), 1); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::setIdentityNumber() - */ - public function setIdentityNumberReturnNullWhenReceiveNumericValue() - { - $this->assertNull($this->customer->setIdentityNumber(1)); - $this->assertNull($this->customer->setIdentityNumber(1.5)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::setIdentityNumber() - * @expectedException \InvalidArgumentException - */ - public function setIdentityNumberThrowsExceptionWhenNotNumericValue() - { - $this->customer->setIdentityNumber('A'); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::setIdentityNumber() - * @expectedException \InvalidArgumentException - */ - public function setIdentityNumberThrowsExceptionWhenEmpty() - { - $this->customer->setIdentityNumber(''); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::getWorkingDays() - */ - public function getWorkingDaysReturnWorkingDaysAttribute() - { - $this->modifyAttribute($this->customer, 'workingDays', 1); - - $this->assertEquals($this->customer->getWorkingDays(), 1); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::setWorkingDays() - */ - public function setWorkingDaysReturnNullWhenReceiveNumericValue() - { - $this->assertNull($this->customer->setWorkingDays(1)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::setWorkingDays() - * @expectedException \InvalidArgumentException - */ - public function setWorkingDaysThrowsExceptionWhenNotNumericValue() - { - $this->customer->setWorkingDays('A'); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::setWorkingDays() - * @expectedException \InvalidArgumentException - */ - public function setWorkingDaysThrowsExceptionWhenEmpty() - { - $this->customer->setWorkingDays(''); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::setWorkingDays() - * @expectedException \InvalidArgumentException - */ - public function setWorkingDaysThrowsExceptionWhenNotInteger() - { - $this->customer->setWorkingDays(5.43); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::getHelpfulMaturity() - */ - public function getHelpfulMaturityReturnHelpfulMaturityAttribute() - { - $this->modifyAttribute($this->customer, 'helpfulMaturity', true); - - $this->assertTrue($this->customer->getHelpfulMaturity()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::setHelpfulMaturity() - */ - public function setHelpfulMaturityReturnNullWhenReceiveBooleanValue() - { - $this->assertNull($this->customer->setHelpfulMaturity(true)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::setHelpfulMaturity() - * @expectedException \InvalidArgumentException - */ - public function setHelpfulMaturityThrowsExceptionWhenNotBooleanValue() - { - $this->customer->setHelpfulMaturity('A'); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Customer::setHelpfulMaturity() - * @expectedException \InvalidArgumentException - */ - public function setHelpfulMaturityThrowsExceptionWhenReceiveEmpty() - { - $this->customer->setHelpfulMaturity(''); - } - - /** - * @test - * @covers \MrPrompt\Centercob\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 c1c7633..0000000 --- a/tests/Common/Base/DealershipTest.php +++ /dev/null @@ -1,103 +0,0 @@ - - */ -class DealershipTest extends TestCase -{ - /** - * @see \Centercob\Tests\ChangeProctedAttribute - */ - 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\Centercob\Common\Base\Dealership::getCode() - */ - public function getCodeReturnCodeAttribute() - { - $this->modifyAttribute($this->dealership, 'code', 1); - - $this->assertEquals(1, $this->dealership->getCode()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Dealership::setCode() - */ - public function setCodeMustBeReturnNull() - { - $this->assertNull($this->dealership->setCode('1')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Dealership::setCode() - * @expectedException \InvalidArgumentException - */ - public function setCodeThrowsExceptionWhenExceedMaxLengh() - { - $this->assertNull($this->dealership->setCode('999999999')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Dealership::getName() - */ - public function getNameReturnNameAttribute() - { - $this->modifyAttribute($this->dealership, 'name', 1); - - $this->assertEquals(1, $this->dealership->getName()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Dealership::setName() - */ - public function setNameMustBeReturnNull() - { - $this->assertNull($this->dealership->setName('1')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\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 369b5ac..0000000 --- a/tests/Common/Base/DocumentTest.php +++ /dev/null @@ -1,131 +0,0 @@ - - */ -class DocumentTest extends TestCase -{ - /** - * @see \Centercob\Tests\ChangeProctedAttribute - */ - 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\Centercob\Common\Base\Document::__construct - * @covers \MrPrompt\Centercob\Common\Base\Document::getType - */ - public function getTypeMustBeReturnTypeAttribute() - { - $this->modifyAttribute($this->document, 'type', 2); - - $this->assertEquals(2, $this->document->getType()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Document::__construct - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\Document::__construct - * @covers \MrPrompt\Centercob\Common\Base\Document::setType - * @expectedException \InvalidArgumentException - */ - public function setTypeThrowsExceptionWhenInvalidtype() - { - $this->document->setType('PASSPORT'); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Document::__construct - * @covers \MrPrompt\Centercob\Common\Base\Document::setType - * @expectedException \InvalidArgumentException - */ - public function setTypeThrowsExceptionWhenEmptyValue() - { - $this->document->setType(''); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Document::__construct - * @covers \MrPrompt\Centercob\Common\Base\Document::getNumber - */ - public function getNumberMustBeReturnNumberAttribute() - { - $this->modifyAttribute($this->document, 'number', 2); - - $this->assertEquals(2, $this->document->getNumber()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Document::__construct - * @covers \MrPrompt\Centercob\Common\Base\Document::setNumber - */ - public function setNumberMustBeReturnNull() - { - $result = $this->document->setNumber('11122233344'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Document::__construct - * @covers \MrPrompt\Centercob\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 9fc342e..0000000 --- a/tests/Common/Base/EmailTest.php +++ /dev/null @@ -1,142 +0,0 @@ - - */ -class EmailTest extends TestCase -{ - /** - * @see \Centercob\Tests\ChangeProctedAttribute - */ - use ChangeProtectedAttribute; - - /** - * @see \Centercob\Tests\Gateway\Mock - */ - 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\Centercob\Common\Base\Email::__construct() - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\Email::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Email::setAddress() - */ - public function setAddressReturnNull() - { - $address = 'foo@foo.net'; - - $result = $this->email->setAddress($address); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Email::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Email::setAddress() - * @expectedException \InvalidArgumentException - */ - public function setAddressThrowsExceptionWhenAddressIsInvalid() - { - $address = '1234'; - - $result = $this->email->setAddress($address); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Email::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Email::getPrimary() - */ - public function getPrimaryReturnPrimaryAttribute() - { - $this->modifyAttribute($this->email, 'primary', true); - - $this->assertEquals(true, $this->email->getPrimary()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Email::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Email::isPrimary() - */ - public function isPrimaryReturnPrimaryAttribute() - { - $this->modifyAttribute($this->email, 'primary', true); - - $this->assertEquals(true, $this->email->isPrimary()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Email::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Email::setPrimary() - */ - public function setPrimaryReturnNull() - { - $result = $this->email->setPrimary(true); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Email::__construct() - * @covers \MrPrompt\Centercob\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 1591bbf..0000000 --- a/tests/Common/Base/HolderTest.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ -class HolderTest extends TestCase -{ - /** - * @see \Centercob\Common\Util\ChangeProtectedAttribute - */ - 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\Centercob\Common\Base\Holder::getCode() - */ - public function getCodeReturnCodeAttribute() - { - $this->modifyAttribute($this->holder, 'code', 1); - - $this->assertEquals($this->holder->getCode(), 1); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Holder::setCode() - */ - public function setCodeMustBeReturnNullWhenReceiveIntegerValue() - { - $this->assertNull($this->holder->setCode(1)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Holder::setCode() - * @expectedException \InvalidArgumentException - */ - public function setCodeThrowsExceptionWhenNotNumericValue() - { - $this->holder->setCode('A'); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Holder::setCode() - * @expectedException \InvalidArgumentException - */ - public function setCodeOnlyThrowsExceptionWhenEmpty() - { - $this->holder->setCode(''); - } - - /** - * @test - * @covers \MrPrompt\Centercob\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 1f2acdb..0000000 --- a/tests/Common/Base/OccurrenceTest.php +++ /dev/null @@ -1,229 +0,0 @@ - - */ -class OccurrenceTest extends TestCase -{ - /** - * @see \Centercob\Tests\ChangeProctedAttribute - */ - 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\Centercob\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\Centercob\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\Centercob\Common\Base\Occurrence::setType() - * @expectedException \InvalidArgumentException - */ - public function setTypeThrowsExceptionWhenNotPredefinedTypes() - { - $type = 'X'; - - $this->occurrence->setType($type); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Occurrence::setType() - * @expectedException \InvalidArgumentException - */ - public function setTypeThrowsExceptionWhenEmpty() - { - $type = ' '; - - $this->occurrence->setType($type); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Occurrence::getReturn() - */ - public function getReturnMustBeReturnReturnAttribute() - { - $this->modifyAttribute($this->occurrence, 'return', 1); - - $this->assertEquals(1, $this->occurrence->getReturn()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Occurrence::setReturn() - */ - public function setReturnMustBeReturnNullWhenReceiveNumericValue() - { - $this->assertNull($this->occurrence->setReturn(1)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Occurrence::setReturn() - */ - public function setReturnMustBeReturnNullWhenNotReceiveAnyParameter() - { - $this->assertNull($this->occurrence->setReturn()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Occurrence::setReturn() - * @expectedException \InvalidArgumentException - */ - public function setReturnThrowsExceptionWhenReceiveNonNumericValue() - { - $type = 'X'; - - $this->occurrence->setReturn($type); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Occurrence::setReturn() - * @expectedException \InvalidArgumentException - */ - public function setReturnThrowsExceptionWhenReceiveEmptyValue() - { - $this->occurrence->setReturn(''); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Occurrence::setReturn() - */ - public function setReturnReturnNullWhenReceiveNumericAsStringValue() - { - $this->assertNull($this->occurrence->setReturn('4')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Occurrence::setDescription() - */ - public function setDescriptionMustBeReturnNullWhenReceiveStringValue() - { - $this->assertNull($this->occurrence->setDescription('foo')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Occurrence::getDescription() - */ - public function getDescriptionMustBeReturnDescriptionAttribute() - { - $this->modifyAttribute($this->occurrence, 'description', 'foo'); - - $this->assertEquals('foo', $this->occurrence->getDescription()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Occurrence::setDescription() - */ - public function setDescriptionReturnNullWhenReceiveEmptyValue() - { - $this->assertNull($this->occurrence->setDescription('')); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Occurrence::setDescription() - */ - public function setDescriptionReturnNullWhenNotReceiveAnyParameter() - { - $this->assertNull($this->occurrence->setDescription()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Occurrence::setDescription() - * @expectedException \InvalidArgumentException - */ - public function setDescriptionThrowsExceptionWhenNotReceiveNotString() - { - $this->assertNull($this->occurrence->setDescription(33)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\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\Centercob\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 e7ae1c9..0000000 --- a/tests/Common/Base/ParcelTest.php +++ /dev/null @@ -1,192 +0,0 @@ - - */ -class ParcelTest extends TestCase -{ - /** - * @see \Centercob\Tests\ChangeProctedAttribute - */ - 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\Centercob\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\Centercob\Common\Base\Parcel::setMaturity() - */ - public function setMaturity() - { - $result = $this->parcel->setMaturity(new DateTime()); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\Parcel::setPrice() - */ - public function setPrice() - { - $result = $this->parcel->setPrice(1); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Parcel::setPrice() - * @expectedException \InvalidArgumentException - */ - public function setPriceThrowsExceptionWhenReceiveNotNumericValue() - { - $this->parcel->setPrice('SD'); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Parcel::setPrice() - * @expectedException \InvalidArgumentException - */ - public function setPriceThrowsExceptionWhenReceiveEmptyValue() - { - $this->parcel->setPrice(''); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Parcel::getKey() - */ - public function getKey() - { - $parcel = 1; - - $this->modifyAttribute($this->parcel, 'key', $parcel); - - $this->assertEquals($parcel, $this->parcel->getKey()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Parcel::setKey() - */ - public function setKey() - { - $result = $this->parcel->setKey(1); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Parcel::setKey() - * @expectedException \InvalidArgumentException - */ - public function setKeyThrowsExceptionWhenReceiveNotNumericValue() - { - $this->parcel->setKey('SD'); - } - - /** - * @test - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\Parcel::setQuantity() - */ - public function setQuantity() - { - $result = $this->parcel->setQuantity(1); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Parcel::setQuantity() - * @expectedException \InvalidArgumentException - */ - public function setQuantityThrowsExceptionWhenReceiveNotNumericValue() - { - $this->parcel->setQuantity('SD'); - } - - /** - * @test - * @covers \MrPrompt\Centercob\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 98d95e2..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\Centercob\Common\Base\Parcels::__construct - * @covers \MrPrompt\Centercob\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 7b0d7b5..0000000 --- a/tests/Common/Base/PersonTest.php +++ /dev/null @@ -1,381 +0,0 @@ - - */ -class PersonTest extends TestCase -{ - /** - * @see \Centercob\Tests\ChangeProctedAttribute - */ - use ChangeProtectedAttribute; - - /** - * @see Centercob\Tests\Gateway\Mock; - */ - 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\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::setDocument() - */ - public function setDocumentReturnEmpty() - { - $document = $this->documentMock(); - - $this->assertNull($this->person->setDocument($document)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::setHomePhone() - */ - public function setHomePhoneReturnEmpty() - { - $telephone = $this->phoneMock(); - - $result = $this->person->setHomePhone($telephone); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::setHomePhoneSecondary() - */ - public function setHomePhoneSecondaryReturnEmpty() - { - $telephone = $this->phoneMock(); - - $result = $this->person->setHomePhoneSecondary($telephone); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::getName() - */ - public function getNameReturnNameAttribute() - { - $this->modifyAttribute($this->person, 'name', 'foo'); - - $this->assertEquals('foo', $this->person->getName()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::setName() - */ - public function setNameReturnEmpty() - { - $result = $this->person->setName('foo'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::setEmail() - */ - public function setEmailReturnEmpty() - { - $email = $this->emailMock(); - - $result = $this->person->setEmail($email); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::setCellPhone() - */ - public function setCellPhoneReturnEmpty() - { - $cel = $this->phoneMock(); - - $result = $this->person->setCellPhone($cel); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::getFatherName() - */ - public function getFatherNameReturnFatherNameAttribute() - { - $fatherName = 'bar'; - - $this->modifyAttribute($this->person, 'fatherName', $fatherName); - - $this->assertEquals($fatherName, $this->person->getFatherName()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::setFatherName() - */ - public function setFatherNameReturnEmpty() - { - $result = $this->person->setFatherName('bar'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::getMotherName() - */ - public function getMotherNameReturnMotherNameAttribute() - { - $motherName = 'bar'; - - $this->modifyAttribute($this->person, 'motherName', $motherName); - - $this->assertEquals($motherName, $this->person->getMotherName()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::setMotherName() - */ - public function setMotherNameReturnEmpty() - { - $result = $this->person->setMotherName('bar'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::getPerson() - */ - public function getPersonReturnPersonAttribute() - { - $person = 'F'; - - $this->modifyAttribute($this->person, 'person', $person); - - $this->assertEquals($person, $this->person->getPerson()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::setPerson() - */ - public function setPersonReturnEmpty() - { - $result = $this->person->setPerson('F'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::setPerson() - * @expectedException \InvalidArgumentException - */ - public function setPersonThrowsExceptionWhenEmpty() - { - $this->person->setPerson(''); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::getSalaried() - */ - public function getSalariedMustBeReturnSalariedAttribute() - { - $this->modifyAttribute($this->person, 'salaried', true); - - $this->assertEquals(true, $this->person->getSalaried()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::setSalaried() - */ - public function setSalariedMustBeReturnNull() - { - $salaried = true; - - $result = $this->person->setSalaried($salaried); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Person::setBirth() - */ - public function setBirthMustBeReturnNull() - { - $birth = new \DateTime(); - - $result = $this->person->setBirth($birth); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\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\Centercob\Common\Base\Person::__construct() - * @covers \MrPrompt\Centercob\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 5a55814..0000000 --- a/tests/Common/Base/PhoneTest.php +++ /dev/null @@ -1,145 +0,0 @@ - - */ -class PhoneTest extends TestCase -{ - /** - * @see \Centercob\Tests\ChangeProctedAttribute - */ - use ChangeProtectedAttribute; - - /** - * @see \Centercob\Tests\Gateway\Mock - */ - 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\Centercob\Common\Base\Phone::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Phone::getNumber() - */ - public function getNumberReturnNumberAttribute() - { - $this->modifyAttribute($this->phone, 'number', 1); - - $this->assertEquals(1, $this->phone->getNumber()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Phone::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Phone::setNumber() - */ - public function setNumberReturnNull() - { - $number = '12341234'; - - $result = $this->phone->setNumber($number); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Phone::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Phone::setNumber() - * @expectedException \InvalidArgumentException - */ - public function setNumberThrowsExceptionWhenNumberIsToShort() - { - $number = '1234'; - - $result = $this->phone->setNumber($number); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Phone::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Phone::setNumber() - * @expectedException \InvalidArgumentException - */ - public function setNumberThrowsExceptionWhenNumberIsToLong() - { - $number = '12343434234432423432233432'; - - $result = $this->phone->setNumber($number); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Phone::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Phone::getType() - */ - public function getTypeReturnTypeAttribute() - { - $this->modifyAttribute($this->phone, 'type', 1); - - $this->assertEquals(1, $this->phone->getType()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Phone::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Phone::setType() - */ - public function setTypeReturnNull() - { - $type = Phone::CELLPHONE; - - $result = $this->phone->setType($type); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Phone::__construct() - * @covers \MrPrompt\Centercob\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 51f0640..0000000 --- a/tests/Common/Base/PurchaserTest.php +++ /dev/null @@ -1,118 +0,0 @@ - - */ -class PurchaserTest extends TestCase -{ - /** - * @see \Centercob\Common\Util\ChangeProtectedAttribute - */ - 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\Centercob\Common\Base\Purchaser::getPurchaserStateRegistration() - */ - public function getPurchaserStateRegistrationReturnPurchaserStateRegistrationAttribute() - { - $purchaser = 'foo'; - - $this->modifyAttribute($this->purchaser, 'purchaserStateRegistration', $purchaser); - - $this->assertEquals($purchaser, $this->purchaser->getPurchaserStateRegistration()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Purchaser::getPurchaserFantasyName() - */ - public function getPurchaserFantasyNameReturnPurchaserFantasyNameAttribute() - { - $purchaser = 'foo'; - - $this->modifyAttribute($this->purchaser, 'purchaserFantasyName', $purchaser); - - $this->assertEquals($purchaser, $this->purchaser->getPurchaserFantasyName()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Purchaser::getPurchaserSocialReason() - */ - public function getPurchaserSocialReasonReturnPurchaserSocialReasonAttribute() - { - $purchaser = 'foo'; - - $this->modifyAttribute($this->purchaser, 'purchaserSocialReason', $purchaser); - - $this->assertEquals($purchaser, $this->purchaser->getPurchaserSocialReason()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Purchaser::setPurchaserStateRegistration() - */ - public function setPurchaserStateRegistrationReturnEmpty() - { - $result = $this->purchaser->setPurchaserStateRegistration('Foo'); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Purchaser::setPurchaserFantasyName() - */ - public function setPurchaserFantasyNameReturnEmpty() - { - $result = $this->purchaser->setPurchaserFantasyName(1); - - $this->assertNull($result); - } - - /** - * @test - * @covers \MrPrompt\Centercob\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 538b192..0000000 --- a/tests/Common/Base/SellerTest.php +++ /dev/null @@ -1,77 +0,0 @@ - - */ -class SellerTest extends TestCase -{ - /** - * @see \Centercob\Tests\ChangeProctedAttribute - */ - 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\Centercob\Common\Base\Seller::getCode() - */ - public function getCodeReturnCodeAttribute() - { - $this->modifyAttribute($this->seller, 'code', 1); - - $this->assertEquals($this->seller->getCode(), 1); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Seller::setCode() - */ - public function setCodeChangeCodeAttribute() - { - $this->seller->setCode(1); - - $this->assertEquals($this->seller->getCode(), 1); - } - - /** - * @test - * @covers \MrPrompt\Centercob\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 9017387..0000000 --- a/tests/Common/Base/SequenceTest.php +++ /dev/null @@ -1,70 +0,0 @@ - - */ -class SequenceTest extends TestCase -{ - /** - * @see \Centercob\Common\Util\ChangeProtectedAttribute - */ - 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\Centercob\Common\Base\Sequence::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Sequence::getValue() - */ - public function getValueReturnValueAttribute() - { - $this->modifyAttribute($this->sequence, 'value', 1); - - $this->assertEquals(1, $this->sequence->getValue()); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Base\Sequence::__construct() - * @covers \MrPrompt\Centercob\Common\Base\Sequence::setValue() - * @covers \MrPrompt\Centercob\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 0f85f72..0000000 --- a/tests/Common/Util/NumberTest.php +++ /dev/null @@ -1,77 +0,0 @@ - - */ -class NumberTest extends TestCase -{ - /** - * @test - * @covers \MrPrompt\Centercob\Common\Util\Number::zeroFill - */ - public function zeroFillMustBeReturnExactLengthWithoutFillSideParam() - { - $foo = Number::zeroFill(1, 10); - - $this->assertEquals(10, strlen($foo)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Util\Number::zeroFill - */ - public function zeroFillMustBeReturnExactStringWhenLengthIsEqualsWithoutFillSideParam() - { - $foo = Number::zeroFill(1, 3); - - $this->assertEquals(3, strlen($foo)); - } - /** - * @test - * @covers \MrPrompt\Centercob\Common\Util\Number::zeroFill - */ - public function zeroFillMustBeReturnExactLengthWithFillSideParam() - { - $foo = Number::zeroFill(1, 10, Number::FILL_LEFT); - - $this->assertEquals(10, strlen($foo)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Util\Number::zeroFill - */ - public function zeroFillMustBeReturnExactStringWhenLengthIsEqualsWithFillSideParam() - { - $foo = Number::zeroFill(1, 3, Number::FILL_LEFT); - - $this->assertEquals(3, strlen($foo)); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Util\Number::zeroFill - * @expectedException \InvalidArgumentException - */ - public function zeroFillThrowsExceptionWhenValueLengthIsGreaterThanLength() - { - Number::zeroFill(11111, 2); - } - - /** - * @test - * @covers \MrPrompt\Centercob\Common\Util\Number::zeroFill - */ - public function zeroFillThrowsExceptionWithoutParams() - { - $return = Number::zeroFill('', ''); - - $this->assertEmpty($return); - } -} diff --git a/tests/Mock.php b/tests/Mock.php index 4529850..99a8853 100644 --- a/tests/Mock.php +++ b/tests/Mock.php @@ -1,30 +1,30 @@ Date: Sat, 1 Dec 2018 23:35:56 -0200 Subject: [PATCH 2/4] fix(bugs-and-types): Fix bugs and types --- composer.json | 2 +- composer.lock | 11 +++++------ samples/cart.php | 6 +++--- samples/processado.php | 2 +- samples/recebido.php | 2 +- samples/remessa.php | 4 ++-- src/Factory.php | 2 +- src/Received/Partial/Detail.php | 6 +++--- src/Shipment/File.php | 4 ++-- src/Shipment/Partial/Detail.php | 8 ++++---- 10 files changed, 23 insertions(+), 24 deletions(-) diff --git a/composer.json b/composer.json index 4e89bd6..e78a21c 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "require": { "php": "^7.1", "respect/validation": "^1.1.12", - "mrprompt/shipmentcommon": "dev-master" + "mrprompt/shipmentcommon": "^2.0.2" }, "require-dev": { "phpunit/phpunit": "^6.1.3", diff --git a/composer.lock b/composer.lock index 68d4bbf..b102f1d 100644 --- a/composer.lock +++ b/composer.lock @@ -12,17 +12,16 @@ "source": { "type": "git", "url": "https://github.com/mrprompt/ShipmentCommon.git", - "reference": "98de4f3cfeed9fcb7032047e6acc7a008e7baec8" + "reference": "701580f1a1d9cb50bee6423a14412f73ad260733" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mrprompt/ShipmentCommon/zipball/98de4f3cfeed9fcb7032047e6acc7a008e7baec8", - "reference": "98de4f3cfeed9fcb7032047e6acc7a008e7baec8", + "url": "https://api.github.com/repos/mrprompt/ShipmentCommon/zipball/701580f1a1d9cb50bee6423a14412f73ad260733", + "reference": "701580f1a1d9cb50bee6423a14412f73ad260733", "shasum": "" }, "require": { - "php": "^7.1", - "respect/validation": "^1.1.12" + "php": "^7.1" }, "require-dev": { "mockery/mockery": "dev-master@dev", @@ -61,7 +60,7 @@ } ], "description": "Common classes used in remittance libraries.", - "time": "2018-12-01T03:02:58+00:00" + "time": "2018-12-02T01:23:06+00:00" }, { "name": "respect/validation", diff --git a/samples/cart.php b/samples/cart.php index 0fef0ab..95423dc 100644 --- a/samples/cart.php +++ b/samples/cart.php @@ -21,7 +21,7 @@ 'vendedor' => [ 'codigo' => 1234, // Código de Cliente na Centercob 'nome' => 'NOME DA EMPRESA', - 'documento' => '', // cpf/cnpj de cadastro do vendedor + 'documento' => '11111111111', // cpf/cnpj de cadastro do vendedor 'nascimento' => '01011970', // data de nascimento do vendeor 'email' => 'vendedor@loja.com.br', // email do vendedor 'telefone1' => '4811111111', @@ -107,7 +107,7 @@ 'vendedor' => [ 'codigo' => 1234, // Código de Cliente na Centercob 'nome' => 'NOME DA EMPRESA', - 'documento' => '', // cpf/cnpj de cadastro do vendedor + 'documento' => '11111111111', // cpf/cnpj de cadastro do vendedor 'nascimento' => '01011970', // data de nascimento do vendeor 'email' => 'vendedor@loja.com.br', // email do vendedor 'telefone1' => '4811111111', @@ -226,7 +226,7 @@ 'vendedor' => [ 'codigo' => 1234, // Código de Cliente na Centercob 'nome' => 'NOME DA EMPRESA', - 'documento' => '', // cpf/cnpj de cadastro do vendedor + 'documento' => '111111111', // cpf/cnpj de cadastro do vendedor 'nascimento' => '01011970', // data de nascimento do vendeor 'email' => 'vendedor@loja.com.br', // email do vendedor 'telefone1' => '4811111111', diff --git a/samples/processado.php b/samples/processado.php index f26dbeb..1ca9100 100644 --- a/samples/processado.php +++ b/samples/processado.php @@ -10,7 +10,7 @@ use MrPrompt\Centercob\Shipment\File; use MrPrompt\Centercob\Factory; -require __DIR__ . '/../bootstrap.php'; +require __DIR__ . '/bootstrap.php'; /* @var $lista array */ $lista = require __DIR__ . '/cart.php'; diff --git a/samples/recebido.php b/samples/recebido.php index 642b256..c035777 100644 --- a/samples/recebido.php +++ b/samples/recebido.php @@ -9,7 +9,7 @@ use MrPrompt\Centercob\Factory; use MrPrompt\Centercob\Received\File; -require __DIR__ . '/../bootstrap.php'; +require __DIR__ . '/bootstrap.php'; /* @var $lista array */ $lista = require __DIR__ . '/cart.php'; diff --git a/samples/remessa.php b/samples/remessa.php index ddcbea8..097d1a5 100644 --- a/samples/remessa.php +++ b/samples/remessa.php @@ -11,7 +11,7 @@ use MrPrompt\ShipmentCommon\Base\Cart; use MrPrompt\ShipmentCommon\Base\Sequence; -require __DIR__ . '/../bootstrap.php'; +require __DIR__ . '/bootstrap.php'; /* @var $today \DateTime */ $today = new DateTime(); @@ -40,7 +40,7 @@ echo ' Qtd ', $parcel->getQuantity(), PHP_EOL; } - echo 'Status: ', $item->getCharge()->getOccurrence()->getDescription(), PHP_EOL; + // echo 'Status: ', $item->getCharge()->getOccurrence()->getDescription(), PHP_EOL; echo PHP_EOL, PHP_EOL; $cart->addItem($item); diff --git a/src/Factory.php b/src/Factory.php index 5da73d1..b84321b 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -39,7 +39,7 @@ public static function createDocumentFromArray(array $campos = []) { $document = new Document(); $document->setType(strlen($campos['documento']) === 11 ? Document::CPF : Document::CNPJ); - $document->setNumber($campos['documento']); + $document->setNumber((int) $campos['documento']); return $document; } diff --git a/src/Received/Partial/Detail.php b/src/Received/Partial/Detail.php index 482f204..0b534b3 100644 --- a/src/Received/Partial/Detail.php +++ b/src/Received/Partial/Detail.php @@ -16,7 +16,7 @@ * * @author Thiago Paes */ -class Detail +class Detail extends \stdClass { /** * Type of register @@ -72,7 +72,7 @@ class Detail public function __construct($row) { $consumerUnity = new ConsumerUnity(); - $consumerUnity->setNumber(substr($row, 1, 25)); + $consumerUnity->setNumber((int) substr($row, 1, 25)); $date = substr($row, 28, 8); $occurrence = new Occurrence(); @@ -90,7 +90,7 @@ public function __construct($row) $document->setNumber(preg_replace('/[^[:digit:]]/', '', substr($row, 134, 20))); $authorization = new Authorization(); - $authorization->setNumber(substr($row, 154, 10)); + $authorization->setNumber((int) substr($row, 154, 10)); $dealership = new Dealership(); $dealership->setCode(substr($row, 164, 6)); diff --git a/src/Shipment/File.php b/src/Shipment/File.php index 2c5d165..85e3440 100644 --- a/src/Shipment/File.php +++ b/src/Shipment/File.php @@ -373,8 +373,8 @@ private function createPurchaser($row) $purchaser = new Purchaser(); $purchaser->setPerson(substr($row, 157, 1)); $purchaser->setName(substr($row, 158, 70)); - $purchaser->setPurchaserFantasyName(substr($row, 228, 70)); - $purchaser->setPurchaserSocialReason(substr($row, 298, 70)); + $purchaser->setFantasyName(substr($row, 228, 70)); + $purchaser->setSocialReason(substr($row, 298, 70)); $purchaser->setBirth(DateTime::createFromFormat('dmY', substr($row, 403, 8))); $purchaser->setEmail(new Email(substr($row, 411, 50))); $purchaser->setHomePhone(new Phone(substr($row, 577, 11), Phone::TELEPHONE)); diff --git a/src/Shipment/Partial/Detail.php b/src/Shipment/Partial/Detail.php index 4570f4c..842e5fa 100644 --- a/src/Shipment/Partial/Detail.php +++ b/src/Shipment/Partial/Detail.php @@ -21,7 +21,7 @@ * * @author Thiago Paes */ -class Detail +class Detail extends \stdClass { /** * Type of register @@ -399,14 +399,14 @@ public function render() $result .= substr(str_pad($this->purchaser->getName(), 70, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 70); // fantasy name - $result .= substr(str_pad($this->purchaser->getPurchaserFantasyName(), 70, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 70); + $result .= substr(str_pad($this->purchaser->getFantasyName(), 70, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 70); // social reason - $result .= substr(str_pad($this->purchaser->getPurchaserSocialReason(), 70, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 70); + $result .= substr(str_pad($this->purchaser->getSocialReason(), 70, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 70); // document number $result .= substr(str_pad($this->purchaser->getDocument()->getNumber(), 15, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 15); - $result .= substr(str_pad($this->purchaser->getPurchaserStateRegistration(), 20, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 20); + $result .= substr(str_pad($this->purchaser->getStateRegistration(), 20, Alphanumeric::FILL, Alphanumeric::ALIGN), 0, 20); // purchaser birth day $result .= $this->purchaser->getBirth()->format(self::DATE_FORMAT); From 6d3403d7764eec90f4ecad6c937eb5ae7ebd0879 Mon Sep 17 00:00:00 2001 From: Thiago Paes Date: Sat, 1 Dec 2018 23:40:06 -0200 Subject: [PATCH 3/4] fix(tests): Fix tests --- composer.json | 1 - composer.lock | 127 +------------------------- phpunit.xml.dist | 8 +- tests/ChangeProtectedAttribute.php | 27 ++++++ tests/Received/FileTest.php | 2 +- tests/Received/Partial/DetailTest.php | 2 +- tests/Received/Partial/FooterTest.php | 2 +- tests/Received/Partial/HeaderTest.php | 2 +- tests/Shipment/FileTest.php | 4 +- tests/Shipment/Partial/DetailTest.php | 2 +- tests/Shipment/Partial/FooterTest.php | 2 +- tests/Shipment/Partial/HeaderTest.php | 2 +- 12 files changed, 39 insertions(+), 142 deletions(-) create mode 100644 tests/ChangeProtectedAttribute.php diff --git a/composer.json b/composer.json index e78a21c..420803f 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,6 @@ ], "require": { "php": "^7.1", - "respect/validation": "^1.1.12", "mrprompt/shipmentcommon": "^2.0.2" }, "require-dev": { diff --git a/composer.lock b/composer.lock index b102f1d..69aaaad 100644 --- a/composer.lock +++ b/composer.lock @@ -4,11 +4,11 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "916ae34e618011d060875f7ac155d3ec", + "content-hash": "03804497ca2343c3359ecd198c747ba9", "packages": [ { "name": "mrprompt/shipmentcommon", - "version": "dev-master", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/mrprompt/ShipmentCommon.git", @@ -61,128 +61,6 @@ ], "description": "Common classes used in remittance libraries.", "time": "2018-12-02T01:23:06+00:00" - }, - { - "name": "respect/validation", - "version": "1.1.29", - "source": { - "type": "git", - "url": "https://github.com/Respect/Validation.git", - "reference": "f8c90fa36859ca41c766efcf0c476d58913a7767" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Respect/Validation/zipball/f8c90fa36859ca41c766efcf0c476d58913a7767", - "reference": "f8c90fa36859ca41c766efcf0c476d58913a7767", - "shasum": "" - }, - "require": { - "php": ">=5.4", - "symfony/polyfill-mbstring": "^1.2" - }, - "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" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "psr-4": { - "Respect\\Validation\\": "library/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "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\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "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" } ], "packages-dev": [ @@ -1809,7 +1687,6 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { - "mrprompt/shipmentcommon": 20, "mockery/mockery": 20 }, "prefer-stable": false, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f3d0556..650aef7 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/tests/ChangeProtectedAttribute.php b/tests/ChangeProtectedAttribute.php new file mode 100644 index 0000000..a42a27f --- /dev/null +++ b/tests/ChangeProtectedAttribute.php @@ -0,0 +1,27 @@ + + */ +trait ChangeProtectedAttribute +{ + /** + * Configures the attribute with the given value + * + * @param object $object + * @param string $name + * @param mixed $value + */ + public function modifyAttribute($object, $name, $value) + { + $attribute = new ReflectionProperty($object, $name); + + $attribute->setAccessible(true); + $attribute->setValue($object, $value); + } +} diff --git a/tests/Received/FileTest.php b/tests/Received/FileTest.php index 05c38f4..9511067 100644 --- a/tests/Received/FileTest.php +++ b/tests/Received/FileTest.php @@ -9,7 +9,7 @@ use MrPrompt\ShipmentCommon\Base\Cart; use MrPrompt\Centercob\Received\Partial\Footer; use MrPrompt\Centercob\Received\Partial\Header; -use MrPrompt\ShipmentCommon\Util\ChangeProtectedAttribute; +use MrPrompt\Centercob\Tests\ChangeProtectedAttribute; /** * Signup test case. diff --git a/tests/Received/Partial/DetailTest.php b/tests/Received/Partial/DetailTest.php index 79ae364..c792df0 100644 --- a/tests/Received/Partial/DetailTest.php +++ b/tests/Received/Partial/DetailTest.php @@ -12,7 +12,7 @@ use MrPrompt\Centercob\Received\Partial\Detail; use MrPrompt\ShipmentCommon\Base\Authorization; use MrPrompt\ShipmentCommon\Base\ConsumerUnity; -use MrPrompt\ShipmentCommon\Util\ChangeProtectedAttribute; +use MrPrompt\Centercob\Tests\ChangeProtectedAttribute; /** * Detail test case. diff --git a/tests/Received/Partial/FooterTest.php b/tests/Received/Partial/FooterTest.php index db7603a..92d5ed1 100644 --- a/tests/Received/Partial/FooterTest.php +++ b/tests/Received/Partial/FooterTest.php @@ -5,7 +5,7 @@ use MrPrompt\Centercob\Tests\Mock; use MrPrompt\ShipmentCommon\Base\Sequence; use MrPrompt\Centercob\Received\Partial\Footer; -use MrPrompt\ShipmentCommon\Util\ChangeProtectedAttribute; +use MrPrompt\Centercob\Tests\ChangeProtectedAttribute; /** * Footer test case. diff --git a/tests/Received/Partial/HeaderTest.php b/tests/Received/Partial/HeaderTest.php index ec4bd78..ce9b41f 100644 --- a/tests/Received/Partial/HeaderTest.php +++ b/tests/Received/Partial/HeaderTest.php @@ -7,7 +7,7 @@ use MrPrompt\ShipmentCommon\Base\Customer; use MrPrompt\ShipmentCommon\Base\Sequence; use MrPrompt\Centercob\Received\Partial\Header; -use MrPrompt\ShipmentCommon\Util\ChangeProtectedAttribute; +use MrPrompt\Centercob\Tests\ChangeProtectedAttribute; /** * Header test case. diff --git a/tests/Shipment/FileTest.php b/tests/Shipment/FileTest.php index dd6a859..c38670d 100644 --- a/tests/Shipment/FileTest.php +++ b/tests/Shipment/FileTest.php @@ -11,7 +11,7 @@ use MrPrompt\ShipmentCommon\Base\Sequence; use MrPrompt\Centercob\Shipment\Partial\Footer; use MrPrompt\Centercob\Shipment\Partial\Header; -use MrPrompt\ShipmentCommon\Util\ChangeProtectedAttribute; +use MrPrompt\Centercob\Tests\ChangeProtectedAttribute; /** * file test case. @@ -21,7 +21,7 @@ class FileTest extends TestCase { /** - * @see \MrPrompt\ShipmentCommon\Util\ChangeProtectedAttribute + * @see \MrPrompt\Centercob\Tests\ChangeProtectedAttribute */ use ChangeProtectedAttribute; diff --git a/tests/Shipment/Partial/DetailTest.php b/tests/Shipment/Partial/DetailTest.php index a60d55b..64644c8 100644 --- a/tests/Shipment/Partial/DetailTest.php +++ b/tests/Shipment/Partial/DetailTest.php @@ -16,7 +16,7 @@ use MrPrompt\ShipmentCommon\Base\Authorization; use MrPrompt\ShipmentCommon\Base\ConsumerUnity; use MrPrompt\Centercob\Tests\Mock as CentercobMock; -use MrPrompt\ShipmentCommon\Util\ChangeProtectedAttribute; +use MrPrompt\Centercob\Tests\ChangeProtectedAttribute; /** * Detail test case. diff --git a/tests/Shipment/Partial/FooterTest.php b/tests/Shipment/Partial/FooterTest.php index a9efd42..85bc6f1 100644 --- a/tests/Shipment/Partial/FooterTest.php +++ b/tests/Shipment/Partial/FooterTest.php @@ -5,7 +5,7 @@ use PHPUnit\Framework\TestCase; use MrPrompt\Centercob\Shipment\Partial\Footer; use MrPrompt\Centercob\Tests\Mock as CentercobMock; -use MrPrompt\ShipmentCommon\Util\ChangeProtectedAttribute; +use MrPrompt\Centercob\Tests\ChangeProtectedAttribute; /** * Footer test case. diff --git a/tests/Shipment/Partial/HeaderTest.php b/tests/Shipment/Partial/HeaderTest.php index a8f43b0..82ef873 100644 --- a/tests/Shipment/Partial/HeaderTest.php +++ b/tests/Shipment/Partial/HeaderTest.php @@ -8,7 +8,7 @@ use MrPrompt\ShipmentCommon\Base\Sequence; use MrPrompt\Centercob\Shipment\Partial\Header; use MrPrompt\Centercob\Tests\Mock as CentercobMock; -use MrPrompt\ShipmentCommon\Util\ChangeProtectedAttribute; +use MrPrompt\Centercob\Tests\ChangeProtectedAttribute; /** * Header test case. From 5bc93808125907d21776e4f9c43db817c63ca550 Mon Sep 17 00:00:00 2001 From: Thiago Paes Date: Sat, 1 Dec 2018 23:45:15 -0200 Subject: [PATCH 4/4] fix(mock): Fixing mock --- tests/Mock.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Mock.php b/tests/Mock.php index 99a8853..cdd0517 100644 --- a/tests/Mock.php +++ b/tests/Mock.php @@ -262,7 +262,7 @@ protected function purchaserMock() ->byDefault(); $purchaser - ->shouldReceive('getPurchaserFantasyName') + ->shouldReceive('getFantasyName') ->andReturn('Fantasy name') ->byDefault(); @@ -272,17 +272,17 @@ protected function purchaserMock() ->byDefault(); $purchaser - ->shouldReceive('getPurchaserSocialReason') + ->shouldReceive('getSocialReason') ->andReturn('Social Reason') ->byDefault(); $purchaser - ->shouldReceive('getPurchaserDocument') + ->shouldReceive('getDocument') ->andReturn($this->documentMock()) ->byDefault(); $purchaser - ->shouldReceive('getPurchaserStateRegistration') + ->shouldReceive('getStateRegistration') ->andReturn(1) ->byDefault();