diff --git a/.gitignore b/.gitignore index 10f1ad48..8d9977e7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,6 @@ demos/paymentDirect/MangoPaySdkStorage.tmp.php /vendor/ composer.lock -.idea - -.phpunit.result.cache \ No newline at end of file +.* +!.php_cs +!.gitignore diff --git a/.php_cs b/.php_cs new file mode 100644 index 00000000..be623c27 --- /dev/null +++ b/.php_cs @@ -0,0 +1,16 @@ +in(__DIR__.'/MangoPay') + ->in(__DIR__.'/tests') +; + +$config = new PhpCsFixer\Config(); + +return $config->setRules([ + '@PSR12' => true, + 'fully_qualified_strict_types' => true, + 'array_syntax' => ['syntax' => 'short'], + ]) + ->setFinder($finder) +; diff --git a/Makefile b/Makefile index e269629e..fa8f28da 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,38 @@ +.PHONY: help help: @echo "Please use \`make ' where is one of" @echo " tag to modify the version" +.PHONY: tag tag: $(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=2.5.1")) @echo Tagging $(TAG) sed -i "s/const VERSION = '.*';/const VERSION = '$(TAG)';/" MangoPay/Libraries/RestTool.php php -l MangoPay/Libraries/RestTool.php + +.PHONY: docker-test-php-56 +docker-test-php-56: ## Test on PHP 5.6 + docker build -t php-test-env:5.6 php_env/PHP_5.6 + docker run -it -v "${PWD}":/usr/src/mangopay2-php-sdk \ + -w /usr/src/mangopay2-php-sdk \ + --user $(shell id -u):$(shell id -g) \ + php-test-env:5.6 \ + /bin/bash -c "composer update -no --no-progress --no-suggest && vendor/bin/phpunit tests" + +.PHONY: docker-test-php-70 +docker-test-php-70: ## Test on PHP 7.0 + docker build -t php-test-env:7.0 php_env/PHP_7.0 + docker run -it -v "${PWD}":/usr/src/mangopay2-php-sdk \ + -w /usr/src/mangopay2-php-sdk \ + --user $(shell id -u):$(shell id -g) \ + php-test-env:7.0 \ + /bin/bash -c "composer update -no --no-progress --no-suggest && vendor/bin/phpunit tests" + +.PHONY: docker-test-php-80 +docker-test-php-80: ## Test on PHP 8.0 + docker build -t php-test-env:8.0 php_env/PHP_8.0 + docker run -it -v "${PWD}":/usr/src/mangopay2-php-sdk \ + -w /usr/src/mangopay2-php-sdk \ + --user $(shell id -u):$(shell id -g) \ + php-test-env:8.0 \ + /bin/bash -c "composer update -no --no-progress --no-suggest --ignore-platform-reqs && vendor/bin/phpunit tests" diff --git a/MangoPay/AVSResult.php b/MangoPay/AVSResult.php index 92b7161b..8d358ddc 100644 --- a/MangoPay/AVSResult.php +++ b/MangoPay/AVSResult.php @@ -1,4 +1,5 @@ IsEmpty($this->AddressLine1) - && $this->IsEmpty($this->AddressLine2) - && $this->IsEmpty($this->City) - && $this->IsEmpty($this->Region) - && $this->IsEmpty($this->PostalCode) + return $this->IsEmpty($this->AddressLine1) + && $this->IsEmpty($this->AddressLine2) + && $this->IsEmpty($this->City) + && $this->IsEmpty($this->Region) + && $this->IsEmpty($this->PostalCode) && $this->IsEmpty($this->Country); } - - private function IsEmpty($value){ + + private function IsEmpty($value) + { return is_null($value) || empty($value); } } diff --git a/MangoPay/ApiBankAccounts.php b/MangoPay/ApiBankAccounts.php index 46e27ee0..c57e85f7 100644 --- a/MangoPay/ApiBankAccounts.php +++ b/MangoPay/ApiBankAccounts.php @@ -1,4 +1,5 @@ GetList('banking_aliases_all', $pagination, null, $walletId, null, $sorting); - return array_map(array($this, "GetBankingAliasResponse"), $bankingAliases); + return array_map([$this, "GetBankingAliasResponse"], $bankingAliases); } /** @@ -79,5 +80,4 @@ private function GetBankingAliasResponse($response) throw new Libraries\Exception('Unexpected response. Missing BankingAlias Type property'); } } - } diff --git a/MangoPay/ApiCardPreAuthorizations.php b/MangoPay/ApiCardPreAuthorizations.php index 1715d8d1..6a70bf5c 100644 --- a/MangoPay/ApiCardPreAuthorizations.php +++ b/MangoPay/ApiCardPreAuthorizations.php @@ -1,4 +1,5 @@ CreateObject('preauthorization_create', $cardPreAuthorization, '\MangoPay\CardPreAuthorization', null, null, $idempotencyKey); } - + /** * Get pre-authorization object * @param string $cardPreAuthorizationId PreAuthorization identifier @@ -25,7 +26,7 @@ public function Get($cardPreAuthorizationId) { return $this->GetObject('preauthorization_get', '\MangoPay\CardPreAuthorization', $cardPreAuthorizationId); } - + /** * Update pre-authorization object * @param \MangoPay\CardPreAuthorization $cardPreAuthorization PreAuthorization object to save diff --git a/MangoPay/ApiCards.php b/MangoPay/ApiCards.php index e4894783..81c364d3 100644 --- a/MangoPay/ApiCards.php +++ b/MangoPay/ApiCards.php @@ -73,7 +73,8 @@ public function GetTransactions($cardId, & $pagination = null, $filter = null, $ * @return \MangoPay\Card * @throws Libraries\Exception */ - public function ValidateCard($cardId){ + public function ValidateCard($cardId) + { return $this->GetObject('card_validate', '\MangoPay\Card', $cardId); } -} \ No newline at end of file +} diff --git a/MangoPay/ApiClients.php b/MangoPay/ApiClients.php index 232908e5..584b5027 100644 --- a/MangoPay/ApiClients.php +++ b/MangoPay/ApiClients.php @@ -97,9 +97,9 @@ public function GetWallets($fundsType = null, $sorting = null) if (is_null($fundsType)) { return $this->GetList('client_wallets', $pagination, '\MangoPay\Wallet', null, null, $sorting); - } else if ($fundsType == FundsType::FEES) { + } elseif ($fundsType == FundsType::FEES) { return $this->GetList('client_wallets_fees', $pagination, '\MangoPay\Wallet', null, null, $sorting); - } else if ($fundsType == FundsType::CREDIT) { + } elseif ($fundsType == FundsType::CREDIT) { return $this->GetList('client_wallets_credit', $pagination, '\MangoPay\Wallet', null, null, $sorting); } @@ -118,18 +118,20 @@ public function GetWallet($fundsType, $currencyIso) { if (is_null($fundsType)) { throw new \MangoPay\Libraries\Exception( - 'First parameter in function GetWallet in class ApiClients is required.'); + 'First parameter in function GetWallet in class ApiClients is required.' + ); } if (is_null($currencyIso)) { throw new \MangoPay\Libraries\Exception( - 'Second parameter in function GetWallet in class ApiClients is required.'); + 'Second parameter in function GetWallet in class ApiClients is required.' + ); } $methodKey = null; if ($fundsType == FundsType::FEES) { $methodKey = 'client_wallets_fees_currency'; - } else if ($fundsType == FundsType::CREDIT) { + } elseif ($fundsType == FundsType::CREDIT) { $methodKey = 'client_wallets_credit_currency'; } else { throw new \MangoPay\Libraries\Exception('\MangoPay\FundsType object has wrong value and cannot get wallets'); @@ -152,18 +154,20 @@ public function GetWalletTransactions($fundsType = null, $currencyIso = null, & { if (is_null($fundsType)) { $methodKey = 'client_wallets_transactions'; - } else if ($fundsType == FundsType::FEES) { + } elseif ($fundsType == FundsType::FEES) { $methodKey = 'client_wallets_transactions_fees_currency'; - } else if ($fundsType == FundsType::CREDIT) { + } elseif ($fundsType == FundsType::CREDIT) { $methodKey = 'client_wallets_transactions_credit_currency'; } else { throw new \MangoPay\Libraries\Exception( - '\MangoPay\FundsType object has wrong value.'); + '\MangoPay\FundsType object has wrong value.' + ); } if (!is_null($fundsType) && is_null($currencyIso)) { throw new \MangoPay\Libraries\Exception( - 'If FundsType is defined the second parameter (currency) is required.'); + 'If FundsType is defined the second parameter (currency) is required.' + ); } return $this->GetList($methodKey, $pagination, '\MangoPay\Transaction', $currencyIso, $filter, null); diff --git a/MangoPay/ApiDisputes.php b/MangoPay/ApiDisputes.php index 30ac43a9..de041b1a 100644 --- a/MangoPay/ApiDisputes.php +++ b/MangoPay/ApiDisputes.php @@ -12,7 +12,6 @@ */ class ApiDisputes extends Libraries\ApiBase { - /** * Gets dispute * @param string $disputeId Dispute identifier diff --git a/MangoPay/ApiEvents.php b/MangoPay/ApiEvents.php index 6259edad..3b6059f4 100644 --- a/MangoPay/ApiEvents.php +++ b/MangoPay/ApiEvents.php @@ -1,4 +1,5 @@ ReportType; - if (is_null($type) || strlen($type) == 0) + if (is_null($type) || strlen($type) == 0) { throw new Libraries\Exception('Report type property is required when create a report request.'); + } switch ($type) { case ReportType::Transactions: diff --git a/MangoPay/ApiRepudiations.php b/MangoPay/ApiRepudiations.php index fa367819..16c71cd9 100644 --- a/MangoPay/ApiRepudiations.php +++ b/MangoPay/ApiRepudiations.php @@ -27,4 +27,4 @@ public function GetRefunds($repudiationId, & $pagination = null, $filter = null, { return $this->GetList('refunds_get_for_repudiation', $pagination, '\MangoPay\Repudiation', $repudiationId, $filter, $sorting); } -} \ No newline at end of file +} diff --git a/MangoPay/ApiResponses.php b/MangoPay/ApiResponses.php index 108371ab..1c6440c6 100644 --- a/MangoPay/ApiResponses.php +++ b/MangoPay/ApiResponses.php @@ -17,8 +17,9 @@ public function Get($idempotencyKey) { $response = $this->GetObject('responses_get', 'MangoPay\Response', $idempotencyKey); $className = $this->GetObjectForIdempotencyUrl($response->RequestURL); - if (is_null($className) || empty($className) || is_null($response->Resource) || empty($response->Resource)) + if (is_null($className) || empty($className) || is_null($response->Resource) || empty($response->Resource)) { return $response; + } $response->Resource = $this->CastResponseToEntity($response->Resource, $className); return $response; diff --git a/MangoPay/ApiUboDeclarations.php b/MangoPay/ApiUboDeclarations.php index dfbf0e78..9ec6dbad 100644 --- a/MangoPay/ApiUboDeclarations.php +++ b/MangoPay/ApiUboDeclarations.php @@ -14,7 +14,6 @@ class ApiUboDeclarations extends Libraries\ApiBase */ public function Create($userId) { - return $this->CreateObject('ubo_declaration_create', null, '\MangoPay\UboDeclaration', $userId); } @@ -53,8 +52,8 @@ public function GetById($uboDeclarationId) */ public function CreateUbo($userId, $uboDeclarationId, $ubo) { - if(is_null($uboDeclarationId ) or empty($uboDeclarationId)){ - throw new \MangoPay\Libraries\ResponseException('Parameter uboDeclarationId is empty',400); + if (is_null($uboDeclarationId) or empty($uboDeclarationId)) { + throw new \MangoPay\Libraries\ResponseException('Parameter uboDeclarationId is empty', 400); } return $this->SaveObject('ubo_create', $ubo, '\MangoPay\Ubo', $userId, $uboDeclarationId); } diff --git a/MangoPay/ApiUsers.php b/MangoPay/ApiUsers.php index dba9841b..b423c265 100644 --- a/MangoPay/ApiUsers.php +++ b/MangoPay/ApiUsers.php @@ -38,7 +38,7 @@ public function GetAll(& $pagination = null, $sorting = null) { $usersList = $this->GetList('users_all', $pagination, null, null, null, $sorting); - $users = array(); + $users = []; if (is_array($usersList)) { foreach ($usersList as $user) { array_push($users, $this->GetUserResponse($user)); @@ -342,8 +342,7 @@ public function CreateKycPageFromFile($userId, $kycDocumentId, $filePath, $idemp */ public function GetEMoney($userId, $year = null, $month = null) { - if ($year == null) - { + if ($year == null) { $year = $this->GetCurrentYear(); } diff --git a/MangoPay/ApiWallets.php b/MangoPay/ApiWallets.php index d983feff..1967d69e 100644 --- a/MangoPay/ApiWallets.php +++ b/MangoPay/ApiWallets.php @@ -1,4 +1,5 @@ array( + return [ + 'Type' => [ '_property_name' => 'Details', 'IBAN' => '\MangoPay\BankAccountDetailsIBAN', 'GB' => '\MangoPay\BankAccountDetailsGB', 'US' => '\MangoPay\BankAccountDetailsUS', 'CA' => '\MangoPay\BankAccountDetailsCA', 'OTHER' => '\MangoPay\BankAccountDetailsOTHER', - ) - ); + ] + ]; } - + /** * Get array with read-only properties * @return array diff --git a/MangoPay/BankAccountDetails.php b/MangoPay/BankAccountDetails.php index 88752683..8cb379e3 100644 --- a/MangoPay/BankAccountDetails.php +++ b/MangoPay/BankAccountDetails.php @@ -1,4 +1,5 @@ '\MangoPay\Money', 'Billing' => '\MangoPay\Billing', 'SecurityInfo' => '\MangoPay\SecurityInfo', 'RemainingFunds' => '\MangoPay\Money', - ); + ]; } /** diff --git a/MangoPay/CardPreAuthorizationPaymentStatus.php b/MangoPay/CardPreAuthorizationPaymentStatus.php index a30c4d88..3f2ffa4b 100644 --- a/MangoPay/CardPreAuthorizationPaymentStatus.php +++ b/MangoPay/CardPreAuthorizationPaymentStatus.php @@ -1,4 +1,5 @@ '\MangoPay\DisputeReason', 'DisputedFunds' => '\MangoPay\Money', 'ContestedFunds' => '\MangoPay\Money' - ); + ]; } - + /** * Get array with read-only properties * @return array @@ -112,7 +112,7 @@ public function GetReadOnlyProperties() array_push($properties, 'StatusMessage'); array_push($properties, 'ResultCode'); array_push($properties, 'ResultMessage'); - + return $properties; } } diff --git a/MangoPay/DisputeDocument.php b/MangoPay/DisputeDocument.php index 6d683e6a..a84be3d5 100644 --- a/MangoPay/DisputeDocument.php +++ b/MangoPay/DisputeDocument.php @@ -1,4 +1,5 @@ array('/clients/', RequestType::POST), 'authentication_oauth' => array('/oauth/token/', RequestType::POST), - 'responses_get' => array('/responses/%s', RequestType::GET), + 'responses_get' => ['/responses/%s', RequestType::GET], - 'events_all' => array('/events', RequestType::GET), + 'events_all' => ['/events', RequestType::GET], - 'hooks_create' => array('/hooks', RequestType::POST), - 'hooks_all' => array('/hooks', RequestType::GET), - 'hooks_get' => array('/hooks/%s', RequestType::GET), - 'hooks_save' => array('/hooks/%s', RequestType::PUT), + 'hooks_create' => ['/hooks', RequestType::POST], + 'hooks_all' => ['/hooks', RequestType::GET], + 'hooks_get' => ['/hooks/%s', RequestType::GET], + 'hooks_save' => ['/hooks/%s', RequestType::PUT], - 'cardregistration_create' => array('/cardregistrations', RequestType::POST), - 'cardregistration_get' => array('/cardregistrations/%s', RequestType::GET), - 'cardregistration_save' => array('/cardregistrations/%s', RequestType::PUT), + 'cardregistration_create' => ['/cardregistrations', RequestType::POST], + 'cardregistration_get' => ['/cardregistrations/%s', RequestType::GET], + 'cardregistration_save' => ['/cardregistrations/%s', RequestType::PUT], - 'preauthorization_create' => array('/preauthorizations/card/direct', RequestType::POST), - 'preauthorization_get' => array('/preauthorizations/%s', RequestType::GET), - 'preauthorizations_get_for_card' => array('/cards/%s/preauthorizations', RequestType::GET), - 'preauthorizations_get_for_user' => array('/users/%s/preauthorizations', RequestType::GET), - 'preauthorization_save' => array('/preauthorizations/%s', RequestType::PUT), - 'preauthorization_transactions_get' => array('/preauthorizations/%s/transactions', RequestType::GET), + 'preauthorization_create' => ['/preauthorizations/card/direct', RequestType::POST], + 'preauthorization_get' => ['/preauthorizations/%s', RequestType::GET], + 'preauthorizations_get_for_card' => ['/cards/%s/preauthorizations', RequestType::GET], + 'preauthorizations_get_for_user' => ['/users/%s/preauthorizations', RequestType::GET], + 'preauthorization_save' => ['/preauthorizations/%s', RequestType::PUT], + 'preauthorization_transactions_get' => ['/preauthorizations/%s/transactions', RequestType::GET], - 'card_get' => array('/cards/%s', RequestType::GET), - 'cards_get_by_fingerprint' => array('/cards/fingerprints/%s', RequestType::GET), - 'card_save' => array('/cards/%s', RequestType::PUT), - 'card_validate' => array('/cards/%s/validate', RequestType::POST), + 'card_get' => ['/cards/%s', RequestType::GET], + 'cards_get_by_fingerprint' => ['/cards/fingerprints/%s', RequestType::GET], + 'card_save' => ['/cards/%s', RequestType::PUT], + 'card_validate' => ['/cards/%s/validate', RequestType::POST], // pay ins URLs - 'payins_card-web_create' => array( '/payins/card/web/', RequestType::POST ), - 'payins_card-direct_create' => array( '/payins/card/direct/', RequestType::POST ), - 'payins_preauthorized-direct_create' => array( '/payins/preauthorized/direct/', RequestType::POST ), - 'payins_bankwire-direct_create' => array( '/payins/bankwire/direct/', RequestType::POST ), - 'payins_directdebit-web_create' => array( '/payins/directdebit/web', RequestType::POST ), - 'payins_directdebit-direct_create' => array( '/payins/directdebit/direct', RequestType::POST ), - 'payins_directdebitdirect-direct_create' => array( '/payins/directdebit/direct', RequestType::POST ), - 'payins_paypal-web_create' => array( '/payins/paypal/web', RequestType::POST ), - 'payins_get' => array( '/payins/%s', RequestType::GET ), - 'payins_createrefunds' => array( '/payins/%s/refunds', RequestType::POST ), - 'payins_applepay-direct_create' => array('/payins/applepay/direct', RequestType::POST), - 'payins_googlepay-direct_create' => array('/payins/googlepay/direct', RequestType::POST), - - 'repudiation_get' => array('/repudiations/%s', RequestType::GET), - - 'get_extended_card_view' => array('/payins/card/web/%s/extended', RequestType::GET), - - 'payouts_bankwire_create' => array('/payouts/bankwire/', RequestType::POST), - 'payouts_get' => array('/payouts/%s', RequestType::GET), - - 'refunds_get' => array('/refunds/%s', RequestType::GET), - 'refunds_get_for_repudiation' => array('/repudiations/%s/refunds', RequestType::GET), - 'refunds_get_for_transfer' => array('/transfers/%s/refunds', RequestType::GET), - 'refunds_get_for_payin' => array('/payins/%s/refunds', RequestType::GET), - 'refunds_get_for_payout' => array('/payouts/%s/refunds', RequestType::GET), - - 'transfers_create' => array('/transfers', RequestType::POST), - 'transfers_get' => array('/transfers/%s', RequestType::GET), - 'transfers_createrefunds' => array('/transfers/%s/refunds', RequestType::POST), - - 'users_createnaturals' => array('/users/natural', RequestType::POST), - 'users_createlegals' => array('/users/legal', RequestType::POST), - - 'users_createbankaccounts_iban' => array('/users/%s/bankaccounts/iban', RequestType::POST), - 'users_createbankaccounts_gb' => array('/users/%s/bankaccounts/gb', RequestType::POST), - 'users_createbankaccounts_us' => array('/users/%s/bankaccounts/us', RequestType::POST), - 'users_createbankaccounts_ca' => array('/users/%s/bankaccounts/ca', RequestType::POST), - 'users_createbankaccounts_other' => array('/users/%s/bankaccounts/other', RequestType::POST), - - 'users_all' => array('/users', RequestType::GET), - 'users_allwallets' => array('/users/%s/wallets', RequestType::GET), - 'users_allbankaccount' => array('/users/%s/bankaccounts', RequestType::GET), - 'users_allcards' => array('/users/%s/cards', RequestType::GET), - 'users_alltransactions' => array('/users/%s/transactions', RequestType::GET), - 'users_allkycdocuments' => array('/users/%s/KYC/documents', RequestType::GET), - 'users_allmandates' => array('/users/%s/mandates', RequestType::GET), - 'users_allbankaccount_mandates' => array('/users/%s/bankaccounts/%s/mandates', RequestType::GET), - 'users_get' => array('/users/%s', RequestType::GET), - 'users_getnaturals' => array('/users/natural/%s', RequestType::GET), - 'users_getlegals' => array('/users/legal/%s', RequestType::GET), - 'users_getbankaccount' => array('/users/%s/bankaccounts/%s', RequestType::GET), - 'users_savenaturals' => array('/users/natural/%s', RequestType::PUT), - 'users_savelegals' => array('/users/legal/%s', RequestType::PUT), - 'users_getemoney_year' => array('/users/%s/emoney/%s', RequestType::GET), - 'users_getemoney_month' => array('/users/%s/emoney/%s/%s', RequestType::GET), - 'users_block_status' => array('/users/%s/blockStatus', RequestType::GET), - 'users_block_status_regulatory' => array('/users/%s/Regulatory', RequestType::GET), - - 'bankaccounts_save' => array('/users/%s/bankaccounts/%s', RequestType::PUT), - - 'wallets_create' => array('/wallets', RequestType::POST), - 'wallets_alltransactions' => array('/wallets/%s/transactions', RequestType::GET), - 'wallets_get' => array('/wallets/%s', RequestType::GET), - 'wallets_save' => array('/wallets/%s', RequestType::PUT), - - 'kyc_documents_create' => array('/users/%s/KYC/documents/', RequestType::POST), - 'kyc_documents_get' => array('/users/%s/KYC/documents/%s', RequestType::GET), - 'kyc_documents_save' => array('/users/%s/KYC/documents/%s', RequestType::PUT), - 'kyc_page_create' => array('/users/%s/KYC/documents/%s/pages', RequestType::POST), - 'kyc_documents_all' => array('/KYC/documents', RequestType::GET), - 'kyc_documents_get_alt' => array('/KYC/documents/%s', RequestType::GET), - 'kyc_documents_create_consult' => array('/KYC/documents/%s/consult', RequestType::POST), - - 'disputes_get' => array('/disputes/%s', RequestType::GET), - 'disputes_save_tag' => array('/disputes/%s', RequestType::PUT), - 'disputes_save_contest_funds' => array('/disputes/%s/submit', RequestType::PUT), - 'dispute_save_close' => array('/disputes/%s/close', RequestType::PUT), - - 'disputes_get_transactions' => array('/disputes/%s/transactions', RequestType::GET), - - 'disputes_all' => array('/disputes', RequestType::GET), - 'disputes_get_for_wallet' => array('/wallets/%s/disputes', RequestType::GET), - 'disputes_get_for_user' => array('/users/%s/disputes', RequestType::GET), - - 'disputes_document_create' => array('/disputes/%s/documents', RequestType::POST), - 'disputes_document_page_create' => array('/disputes/%s/documents/%s/pages', RequestType::POST), - 'disputes_document_save' => array('/disputes/%s/documents/%s', RequestType::PUT), - 'disputes_document_get' => array('/dispute-documents/%s', RequestType::GET), - 'disputes_document_get_for_dispute' => array('/disputes/%s/documents', RequestType::GET), - 'disputes_document_all' => array('/dispute-documents', RequestType::GET), - 'disputes_document_create_consult' => array('/dispute-documents/%s/consult', RequestType::POST), - - 'disputes_repudiation_get' => array('/repudiations/%s', RequestType::GET), - - 'disputes_repudiation_create_settlement' => array('/repudiations/%s/settlementtransfer', RequestType::POST), - 'disputes_repudiation_get_settlement' => array('/settlements/%s', RequestType::GET), - 'disputes_pendingsettlement' => array('/disputes/pendingsettlement', RequestType::GET), - - 'mandates_create' => array('/mandates/directdebit/web', RequestType::POST), - 'mandates_save' => array('/mandates/%s/cancel', RequestType::PUT), - 'mandates_get' => array('/mandates/%s', RequestType::GET), - 'mandates_all' => array('/mandates', RequestType::GET), - - 'client_get' => array('/clients', RequestType::GET), - 'client_save' => array('/clients', RequestType::PUT), - 'client_upload_logo' => array('/clients/logo', RequestType::PUT), - 'client_wallets' => array('/clients/wallets', RequestType::GET), - 'client_wallets_fees' => array('/clients/wallets/fees', RequestType::GET), - 'client_wallets_fees_currency' => array('/clients/wallets/fees/%s', RequestType::GET), - 'client_wallets_credit' => array('/clients/wallets/credit', RequestType::GET), - 'client_wallets_credit_currency' => array('/clients/wallets/credit/%s', RequestType::GET), - 'client_wallets_transactions' => array('/clients/transactions', RequestType::GET), - 'client_wallets_transactions_fees_currency' => array('/clients/wallets/fees/%s/transactions', RequestType::GET), - 'client_wallets_transactions_credit_currency' => array('/clients/wallets/credit/%s/transactions', RequestType::GET), - 'client_create_bank_account_iban' => array('/clients/bankaccounts/iban', RequestType::POST), - 'client_create_payout' => array('/clients/payouts', RequestType::POST), - - 'banking_aliases_iban_create' => array('/wallets/%s/bankingaliases/iban', RequestType::POST), - 'banking_aliases_get' => array('/bankingaliases/%s', RequestType::GET), - 'banking_aliases_update' => array('/bankingaliases/%s', RequestType::PUT), - 'banking_aliases_all' => array('/wallets/%s/bankingaliases', RequestType::GET), - - 'reports_transactions_create' => array('/reports/transactions', RequestType::POST), - 'reports_wallets_create' => array('/reports/wallets', RequestType::POST), - 'reports_all' => array('/reports', RequestType::GET), - 'reports_get' => array('/reports/%s', RequestType::GET), - - 'ubo_declaration_create' => array('/users/%s/kyc/ubodeclarations', RequestType::POST), - 'ubo_declaration_all' => array('/users/%s/kyc/ubodeclarations', RequestType::GET), - 'ubo_declaration_submit' => array('/users/%s/kyc/ubodeclarations/%s', RequestType::PUT), - 'ubo_declaration_get' => array('/users/%s/kyc/ubodeclarations/%s', RequestType::GET), - 'ubo_declaration_get_by_id' => array('/kyc/ubodeclarations/%s', RequestType::GET), - 'ubo_create' => array('/users/%s/kyc/ubodeclarations/%s/ubos', RequestType::POST), - 'ubo_update' => array('/users/%s/kyc/ubodeclarations/%s/ubos/%s', RequestType::PUT), - 'ubo_get' => array('/users/%s/kyc/ubodeclarations/%s/ubos/%s', RequestType::GET), - 'ubo_declaration_get_by_id' => array('/kyc/ubodeclarations/%s', RequestType::GET), - - 'transactions_get_for_mandate' => array('/mandates/%s/transactions', RequestType::GET), - 'transactions_get_for_card' => array('/cards/%s/transactions', RequestType::GET), - 'transactions_get_for_bank_account' => array('/bankaccounts/%s/transactions', RequestType::GET) - - ); + 'payins_card-web_create' => [ '/payins/card/web/', RequestType::POST ], + 'payins_card-direct_create' => [ '/payins/card/direct/', RequestType::POST ], + 'payins_preauthorized-direct_create' => [ '/payins/preauthorized/direct/', RequestType::POST ], + 'payins_bankwire-direct_create' => [ '/payins/bankwire/direct/', RequestType::POST ], + 'payins_directdebit-web_create' => [ '/payins/directdebit/web', RequestType::POST ], + 'payins_directdebit-direct_create' => [ '/payins/directdebit/direct', RequestType::POST ], + 'payins_directdebitdirect-direct_create' => [ '/payins/directdebit/direct', RequestType::POST ], + 'payins_paypal-web_create' => [ '/payins/paypal/web', RequestType::POST ], + 'payins_get' => [ '/payins/%s', RequestType::GET ], + 'payins_createrefunds' => [ '/payins/%s/refunds', RequestType::POST ], + 'payins_applepay-direct_create' => ['/payins/applepay/direct', RequestType::POST], + 'payins_googlepay-direct_create' => ['/payins/googlepay/direct', RequestType::POST], + + 'repudiation_get' => ['/repudiations/%s', RequestType::GET], + + 'get_extended_card_view' => ['/payins/card/web/%s/extended', RequestType::GET], + + 'payouts_bankwire_create' => ['/payouts/bankwire/', RequestType::POST], + 'payouts_get' => ['/payouts/%s', RequestType::GET], + + 'refunds_get' => ['/refunds/%s', RequestType::GET], + 'refunds_get_for_repudiation' => ['/repudiations/%s/refunds', RequestType::GET], + 'refunds_get_for_transfer' => ['/transfers/%s/refunds', RequestType::GET], + 'refunds_get_for_payin' => ['/payins/%s/refunds', RequestType::GET], + 'refunds_get_for_payout' => ['/payouts/%s/refunds', RequestType::GET], + + 'transfers_create' => ['/transfers', RequestType::POST], + 'transfers_get' => ['/transfers/%s', RequestType::GET], + 'transfers_createrefunds' => ['/transfers/%s/refunds', RequestType::POST], + + 'users_createnaturals' => ['/users/natural', RequestType::POST], + 'users_createlegals' => ['/users/legal', RequestType::POST], + + 'users_createbankaccounts_iban' => ['/users/%s/bankaccounts/iban', RequestType::POST], + 'users_createbankaccounts_gb' => ['/users/%s/bankaccounts/gb', RequestType::POST], + 'users_createbankaccounts_us' => ['/users/%s/bankaccounts/us', RequestType::POST], + 'users_createbankaccounts_ca' => ['/users/%s/bankaccounts/ca', RequestType::POST], + 'users_createbankaccounts_other' => ['/users/%s/bankaccounts/other', RequestType::POST], + + 'users_all' => ['/users', RequestType::GET], + 'users_allwallets' => ['/users/%s/wallets', RequestType::GET], + 'users_allbankaccount' => ['/users/%s/bankaccounts', RequestType::GET], + 'users_allcards' => ['/users/%s/cards', RequestType::GET], + 'users_alltransactions' => ['/users/%s/transactions', RequestType::GET], + 'users_allkycdocuments' => ['/users/%s/KYC/documents', RequestType::GET], + 'users_allmandates' => ['/users/%s/mandates', RequestType::GET], + 'users_allbankaccount_mandates' => ['/users/%s/bankaccounts/%s/mandates', RequestType::GET], + 'users_get' => ['/users/%s', RequestType::GET], + 'users_getnaturals' => ['/users/natural/%s', RequestType::GET], + 'users_getlegals' => ['/users/legal/%s', RequestType::GET], + 'users_getbankaccount' => ['/users/%s/bankaccounts/%s', RequestType::GET], + 'users_savenaturals' => ['/users/natural/%s', RequestType::PUT], + 'users_savelegals' => ['/users/legal/%s', RequestType::PUT], + 'users_getemoney_year' => ['/users/%s/emoney/%s', RequestType::GET], + 'users_getemoney_month' => ['/users/%s/emoney/%s/%s', RequestType::GET], + 'users_block_status' => ['/users/%s/blockStatus', RequestType::GET], + 'users_block_status_regulatory' => ['/users/%s/Regulatory', RequestType::GET], + + 'bankaccounts_save' => ['/users/%s/bankaccounts/%s', RequestType::PUT], + + 'wallets_create' => ['/wallets', RequestType::POST], + 'wallets_alltransactions' => ['/wallets/%s/transactions', RequestType::GET], + 'wallets_get' => ['/wallets/%s', RequestType::GET], + 'wallets_save' => ['/wallets/%s', RequestType::PUT], + + 'kyc_documents_create' => ['/users/%s/KYC/documents/', RequestType::POST], + 'kyc_documents_get' => ['/users/%s/KYC/documents/%s', RequestType::GET], + 'kyc_documents_save' => ['/users/%s/KYC/documents/%s', RequestType::PUT], + 'kyc_page_create' => ['/users/%s/KYC/documents/%s/pages', RequestType::POST], + 'kyc_documents_all' => ['/KYC/documents', RequestType::GET], + 'kyc_documents_get_alt' => ['/KYC/documents/%s', RequestType::GET], + 'kyc_documents_create_consult' => ['/KYC/documents/%s/consult', RequestType::POST], + + 'disputes_get' => ['/disputes/%s', RequestType::GET], + 'disputes_save_tag' => ['/disputes/%s', RequestType::PUT], + 'disputes_save_contest_funds' => ['/disputes/%s/submit', RequestType::PUT], + 'dispute_save_close' => ['/disputes/%s/close', RequestType::PUT], + + 'disputes_get_transactions' => ['/disputes/%s/transactions', RequestType::GET], + + 'disputes_all' => ['/disputes', RequestType::GET], + 'disputes_get_for_wallet' => ['/wallets/%s/disputes', RequestType::GET], + 'disputes_get_for_user' => ['/users/%s/disputes', RequestType::GET], + + 'disputes_document_create' => ['/disputes/%s/documents', RequestType::POST], + 'disputes_document_page_create' => ['/disputes/%s/documents/%s/pages', RequestType::POST], + 'disputes_document_save' => ['/disputes/%s/documents/%s', RequestType::PUT], + 'disputes_document_get' => ['/dispute-documents/%s', RequestType::GET], + 'disputes_document_get_for_dispute' => ['/disputes/%s/documents', RequestType::GET], + 'disputes_document_all' => ['/dispute-documents', RequestType::GET], + 'disputes_document_create_consult' => ['/dispute-documents/%s/consult', RequestType::POST], + + 'disputes_repudiation_get' => ['/repudiations/%s', RequestType::GET], + + 'disputes_repudiation_create_settlement' => ['/repudiations/%s/settlementtransfer', RequestType::POST], + 'disputes_repudiation_get_settlement' => ['/settlements/%s', RequestType::GET], + 'disputes_pendingsettlement' => ['/disputes/pendingsettlement', RequestType::GET], + + 'mandates_create' => ['/mandates/directdebit/web', RequestType::POST], + 'mandates_save' => ['/mandates/%s/cancel', RequestType::PUT], + 'mandates_get' => ['/mandates/%s', RequestType::GET], + 'mandates_all' => ['/mandates', RequestType::GET], + + 'client_get' => ['/clients', RequestType::GET], + 'client_save' => ['/clients', RequestType::PUT], + 'client_upload_logo' => ['/clients/logo', RequestType::PUT], + 'client_wallets' => ['/clients/wallets', RequestType::GET], + 'client_wallets_fees' => ['/clients/wallets/fees', RequestType::GET], + 'client_wallets_fees_currency' => ['/clients/wallets/fees/%s', RequestType::GET], + 'client_wallets_credit' => ['/clients/wallets/credit', RequestType::GET], + 'client_wallets_credit_currency' => ['/clients/wallets/credit/%s', RequestType::GET], + 'client_wallets_transactions' => ['/clients/transactions', RequestType::GET], + 'client_wallets_transactions_fees_currency' => ['/clients/wallets/fees/%s/transactions', RequestType::GET], + 'client_wallets_transactions_credit_currency' => ['/clients/wallets/credit/%s/transactions', RequestType::GET], + 'client_create_bank_account_iban' => ['/clients/bankaccounts/iban', RequestType::POST], + 'client_create_payout' => ['/clients/payouts', RequestType::POST], + + 'banking_aliases_iban_create' => ['/wallets/%s/bankingaliases/iban', RequestType::POST], + 'banking_aliases_get' => ['/bankingaliases/%s', RequestType::GET], + 'banking_aliases_update' => ['/bankingaliases/%s', RequestType::PUT], + 'banking_aliases_all' => ['/wallets/%s/bankingaliases', RequestType::GET], + + 'reports_transactions_create' => ['/reports/transactions', RequestType::POST], + 'reports_wallets_create' => ['/reports/wallets', RequestType::POST], + 'reports_all' => ['/reports', RequestType::GET], + 'reports_get' => ['/reports/%s', RequestType::GET], + + 'ubo_declaration_create' => ['/users/%s/kyc/ubodeclarations', RequestType::POST], + 'ubo_declaration_all' => ['/users/%s/kyc/ubodeclarations', RequestType::GET], + 'ubo_declaration_submit' => ['/users/%s/kyc/ubodeclarations/%s', RequestType::PUT], + 'ubo_declaration_get' => ['/users/%s/kyc/ubodeclarations/%s', RequestType::GET], + 'ubo_declaration_get_by_id' => ['/kyc/ubodeclarations/%s', RequestType::GET], + 'ubo_create' => ['/users/%s/kyc/ubodeclarations/%s/ubos', RequestType::POST], + 'ubo_update' => ['/users/%s/kyc/ubodeclarations/%s/ubos/%s', RequestType::PUT], + 'ubo_get' => ['/users/%s/kyc/ubodeclarations/%s/ubos/%s', RequestType::GET], + + 'transactions_get_for_mandate' => ['/mandates/%s/transactions', RequestType::GET], + 'transactions_get_for_card' => ['/cards/%s/transactions', RequestType::GET], + 'transactions_get_for_bank_account' => ['/bankaccounts/%s/transactions', RequestType::GET] + + ]; /** * Constructor @@ -275,9 +274,9 @@ protected function GetObject($methodKey, $responseClassName, $firstEntityId = nu { if (!is_null($thirdEntityId)) { $urlMethod = sprintf($this->GetRequestUrl($methodKey), $firstEntityId, $secondEntityId, $thirdEntityId); - } else if (!is_null($secondEntityId)) { + } elseif (!is_null($secondEntityId)) { $urlMethod = sprintf($this->GetRequestUrl($methodKey), $firstEntityId, $secondEntityId); - } else if (!is_null($firstEntityId)) { + } elseif (!is_null($firstEntityId)) { $urlMethod = sprintf($this->GetRequestUrl($methodKey), $firstEntityId); } else { $urlMethod = $this->GetRequestUrl($methodKey); @@ -310,7 +309,7 @@ protected function GetList($methodKey, & $pagination, $responseClassName = null, } $rest = new RestTool($this->_root, true); - $additionalUrlParams = array(); + $additionalUrlParams = []; if (!is_null($filter)) { $additionalUrlParams["filter"] = $filter; } @@ -347,7 +346,7 @@ protected function SaveObject($methodKey, $entity, $responseClassName = null, $s if (is_null($secondEntityId)) { $urlMethod = sprintf($this->GetRequestUrl($methodKey), $entityId); - } else if (is_null($thirdEntityId)) { + } elseif (is_null($thirdEntityId)) { $urlMethod = sprintf($this->GetRequestUrl($methodKey), $secondEntityId, $entityId); } else { $urlMethod = sprintf($this->GetRequestUrl($methodKey), $secondEntityId, $thirdEntityId, $entityId); @@ -374,7 +373,7 @@ protected function SaveObject($methodKey, $entity, $responseClassName = null, $s protected function CastResponseToEntity($response, $entityClassName, $asDependentObject = false) { if (is_array($response)) { - $list = array(); + $list = []; foreach ($response as $responseObject) { array_push($list, $this->CastResponseToEntity($responseObject, $entityClassName)); } @@ -473,7 +472,7 @@ protected function BuildRequestData($entity) }*/ $entityProperties = get_object_vars($entity); $blackList = $entity->GetReadOnlyProperties(); - $requestData = array(); + $requestData = []; foreach ($entityProperties as $propertyName => $propertyValue) { if (in_array($propertyName, $blackList)) { continue; @@ -517,10 +516,11 @@ private function CanReadSubRequestData($entity, $propertyName) protected function GetObjectForIdempotencyUrl($url) { - if (is_null($url) || empty($url)) + if (is_null($url) || empty($url)) { return null; + } - $map = array( + $map = [ 'preauthorization_create' => '\MangoPay\CardPreAuthorization', 'cardregistration_create' => '\MangoPay\CardRegistration', 'client_upload_logo' => '', @@ -552,7 +552,7 @@ protected function GetObjectForIdempotencyUrl($url) 'kyc_page_create' => '', 'wallets_create' => '\MangoPay\Wallet', 'users_getemoney' => '\MangoPay\EMoney', - ); + ]; foreach ($map as $key => $className) { $sourceUrl = $this->GetRequestUrl($key); diff --git a/MangoPay/Libraries/ApiOAuth.php b/MangoPay/Libraries/ApiOAuth.php index 081d7ccf..fa426362 100644 --- a/MangoPay/Libraries/ApiOAuth.php +++ b/MangoPay/Libraries/ApiOAuth.php @@ -1,4 +1,5 @@ GetRequestUrl('authentication_oauth'); $requestType = $this->GetRequestType('authentication_oauth'); - $requestData = array( + $requestData = [ 'grant_type' => 'client_credentials' - ); - + ]; + $rest = new RestTool($this->_root, false); $authHlp = new AuthenticationHelper($this->_root); - + $urlDetails = parse_url($this->_root->Config->BaseUrl); $rest->AddRequestHttpHeader('Host: ' . @$urlDetails['host']); $rest->AddRequestHttpHeader('Authorization: Basic ' . $authHlp->GetHttpHeaderBasicKey()); @@ -28,7 +29,7 @@ public function CreateToken() $response = $rest->Request($urlMethod, $requestType, $requestData); $token = $this->CastResponseToEntity($response, '\MangoPay\Libraries\OAuthToken'); $token->autentication_key = $authHlp->GetAutenticationKey(); - + return $token; } } diff --git a/MangoPay/Libraries/AuthenticationHelper.php b/MangoPay/Libraries/AuthenticationHelper.php index aa36c559..1c1d5098 100644 --- a/MangoPay/Libraries/AuthenticationHelper.php +++ b/MangoPay/Libraries/AuthenticationHelper.php @@ -1,4 +1,5 @@ _root = $root; } - + /** * Get HTTP header value with authorization string * @return string Authorization string @@ -26,7 +27,7 @@ public function GetHttpHeaderKey() { return $this->GetHttpHeaderStrong(); } - + /** * Get basic key for HTTP header * @return string @@ -37,30 +38,30 @@ public function GetHttpHeaderBasicKey() if (is_null($this->_root->Config->ClientId) || strlen($this->_root->Config->ClientId) == 0) { throw new Exception('MangoPayApi.Config.ClientId is not set.'); } - + if (is_null($this->_root->Config->ClientPassword) || strlen($this->_root->Config->ClientPassword) == 0) { throw new Exception('MangoPayApi.Config.ClientPassword is not set.'); } - + $signature = $this->_root->Config->ClientId . ':' . $this->_root->Config->ClientPassword; return base64_encode($signature); } - + public function GetAutenticationKey() { if (is_null($this->_root->Config->ClientId) || strlen($this->_root->Config->ClientId) == 0) { throw new Exception('MangoPayApi.Config.ClientId is not set.'); } - + if (is_null($this->_root->Config->BaseUrl) || strlen($this->_root->Config->BaseUrl) == 0) { throw new Exception('MangoPayApi.Config.BaseUrl is not set.'); } - + return md5($this->_root->Config->BaseUrl. $this->_root->Config->ClientId. $this->_root->Config->ClientPassword); } - + /** * Get HTTP header value with authorization string for basic authentication * @@ -71,7 +72,7 @@ private function GetHttpHeaderBasic() { return 'Authorization: Basic ' . $this->GetHttpHeaderBasicKey(); } - + /** * Get HTTP header value with authorization string for strong authentication * diff --git a/MangoPay/Libraries/AuthorizationTokenManager.php b/MangoPay/Libraries/AuthorizationTokenManager.php index 3b30ade5..58f10ade 100644 --- a/MangoPay/Libraries/AuthorizationTokenManager.php +++ b/MangoPay/Libraries/AuthorizationTokenManager.php @@ -1,4 +1,5 @@ _root = $root; $this->RegisterCustomStorageStrategy(new DefaultStorageStrategy($this->_root->Config)); } - + /** * Gets the current authorization token. * In the very first call, this method creates a new token before returning. @@ -28,14 +29,14 @@ public function __construct($root) public function GetToken($autenticationKey) { $token = $this->_storageStrategy->Get(); - + if (is_null($token) || false === $token || $token->IsExpired() || $token->GetAutenticationKey() != $autenticationKey) { $this->StoreToken($this->_root->AuthenticationManager->CreateToken()); } - + return $this->_storageStrategy->Get(); } - + /** * Stores authorization token passed as an argument in the underlying * storage strategy implementation. @@ -45,7 +46,7 @@ public function StoreToken($token) { $this->_storageStrategy->Store($token); } - + /** * Registers custom storage strategy implementation. * By default, the DefaultStorageStrategy instance is used. diff --git a/MangoPay/Libraries/DefaultStorageStrategy.php b/MangoPay/Libraries/DefaultStorageStrategy.php index df3d57ac..0222d7e9 100644 --- a/MangoPay/Libraries/DefaultStorageStrategy.php +++ b/MangoPay/Libraries/DefaultStorageStrategy.php @@ -1,4 +1,5 @@ '; private $_fileName = 'MangoPaySdkStorage.tmp.php'; private $_config; - + public function __construct($config) { $this->_config = $config; } - + /** * Gets the current authorization token. * @return \MangoPay\Libraries\OAuthToken Currently stored token instance or null. @@ -25,12 +26,12 @@ public function Get() if (!file_exists($filename)) { return null; } - + $data = file_get_contents($filename); if ($data === false) { return null; } - + $serialized = str_replace($this->_prefixContent, '', $data); return unserialize($serialized); } @@ -44,14 +45,14 @@ public function Store($token) if (!is_writable($this->GetPathToTemporaryFolder())) { throw new \MangoPay\Libraries\Exception('Cannot create or write to file ' . $this->GetPathToTemporaryFolder()); } - + $serialized = serialize($token); $result = file_put_contents($this->GetPathToFile(), $this->_prefixContent . $serialized, LOCK_EX); if ($result === false) { throw new \MangoPay\Libraries\Exception('Cannot put token to file'); } } - + /** * Get path to storage file * @return string @@ -60,7 +61,7 @@ private function GetPathToFile() { return $this->GetPathToTemporaryFolder() . DIRECTORY_SEPARATOR . $this->_fileName; } - + /** * Get path to temporary folder * @return string @@ -70,7 +71,7 @@ private function GetPathToTemporaryFolder() if (is_null($this->_config->TemporaryFolder)) { throw new \MangoPay\Libraries\Exception('Path to temporary folder is not defined'); } - + return $this->_config->TemporaryFolder; } } diff --git a/MangoPay/Libraries/Document.php b/MangoPay/Libraries/Document.php index d8529551..4deea3ef 100644 --- a/MangoPay/Libraries/Document.php +++ b/MangoPay/Libraries/Document.php @@ -7,13 +7,12 @@ */ abstract class Document extends EntityBase { - /** * Refused reason type * @var string */ public $RefusedReasonType; - + /** * Refused reason message * @var string @@ -25,7 +24,7 @@ abstract class Document extends EntityBase * @var int Unix timestamp */ public $ProcessedDate; - + /** * Get array with read-only properties * @return array @@ -36,7 +35,7 @@ public function GetReadOnlyProperties() array_push($properties, 'RefusedReasonType'); array_push($properties, 'RefusedReasonMessage'); array_push($properties, 'UserId'); - + return $properties; } } diff --git a/MangoPay/Libraries/Dto.php b/MangoPay/Libraries/Dto.php index ced1d258..08c84fdc 100644 --- a/MangoPay/Libraries/Dto.php +++ b/MangoPay/Libraries/Dto.php @@ -14,7 +14,7 @@ abstract class Dto */ public function GetSubObjects() { - return array(); + return []; } /** @@ -24,9 +24,9 @@ public function GetSubObjects() */ public function GetDependsObjects() { - return array(); + return []; } - + /** * Get array with read only properties - not used in response * To be overridden in child class if has any read-only properties. @@ -34,6 +34,6 @@ public function GetDependsObjects() */ public function GetReadOnlyProperties() { - return array(); + return []; } } diff --git a/MangoPay/Libraries/EntityBase.php b/MangoPay/Libraries/EntityBase.php index d9cba3c2..8a274064 100644 --- a/MangoPay/Libraries/EntityBase.php +++ b/MangoPay/Libraries/EntityBase.php @@ -13,17 +13,17 @@ abstract class EntityBase extends Dto * At this moment, identifier is a numeric string - in the future, will be GUID. */ public $Id; - + /** * @var string Custom data */ public $Tag; - + /** * @var int Unix timestamp, Date of creation */ public $CreationDate; - + /** * Construct * @param string $id Entity identifier @@ -32,13 +32,13 @@ public function __construct($id = null) { $this->Id = $id; } - + /** * Get array with read-only properties * @return array */ public function GetReadOnlyProperties() { - return array( 'Id', 'CreationDate' ); + return [ 'Id', 'CreationDate' ]; } } diff --git a/MangoPay/Libraries/Error.php b/MangoPay/Libraries/Error.php index 2f681b91..cfd188fd 100644 --- a/MangoPay/Libraries/Error.php +++ b/MangoPay/Libraries/Error.php @@ -13,38 +13,38 @@ class Error * @access public */ public $Message; - + /** * Array with errors information * @var object * @access public */ public $Errors; - - /** + + /** * An identifer for this API response * @var string * @access public */ public $Id; - - /** + + /** * The timestamp of this API response * @var int * @access public */ public $Date; - - /** + + /** * The type of error * @var string * @access public */ public $Type; - + /** * Return the stdClass error serialized as string - * @access public + * @access public */ public function __toString() { diff --git a/MangoPay/Libraries/Exception.php b/MangoPay/Libraries/Exception.php index cf8516ca..5fd76cf4 100644 --- a/MangoPay/Libraries/Exception.php +++ b/MangoPay/Libraries/Exception.php @@ -1,4 +1,5 @@ create_time = time() - 5; } - + /** * Check that current tokens are expire and return true if yes * @return bool @@ -52,7 +53,7 @@ public function IsExpired() { return (time() >= ($this->create_time + $this->expires_in)); } - + public function GetAutenticationKey() { return $this->autentication_key; diff --git a/MangoPay/Libraries/RequestType.php b/MangoPay/Libraries/RequestType.php index 45cd6134..02d1d41b 100644 --- a/MangoPay/Libraries/RequestType.php +++ b/MangoPay/Libraries/RequestType.php @@ -1,4 +1,5 @@ 'OK', 204 => 'No Content', 206 => 'PartialContent', @@ -24,7 +24,7 @@ class ResponseException extends Exception 422 => 'Unprocessable entity', 500 => 'Internal server error', 501 => 'Not implemented' - ); + ]; /** * Error details diff --git a/MangoPay/Libraries/RestTool.php b/MangoPay/Libraries/RestTool.php index 0f91a47b..b1884295 100644 --- a/MangoPay/Libraries/RestTool.php +++ b/MangoPay/Libraries/RestTool.php @@ -2,6 +2,7 @@ namespace MangoPay\Libraries; +use MangoPay\MangoPayApi; use MangoPay\RateLimit; use Psr\Log\LoggerInterface; @@ -14,7 +15,7 @@ class RestTool /** * Root/parent instance that holds the OAuthToken and Configuration instance - * @var \MangoPay\MangoPayApi + * @var MangoPayApi */ private $_root; /** @@ -94,7 +95,7 @@ public function GetRequestUrl() /** * Constructor - * @param \MangoPay\MangoPayApi $root Root/parent instance that holds the OAuthToken and Configuration instance + * @param MangoPayApi $root Root/parent instance that holds the OAuthToken and Configuration instance * @param bool $authRequired Variable to flag that in request the authentication data are required */ public function __construct($root, $authRequired = true) @@ -107,7 +108,7 @@ public function __construct($root, $authRequired = true) public function AddRequestHttpHeader($httpHeader) { if (is_null($this->_requestHttpHeaders)) { - $this->_requestHttpHeaders = array(); + $this->_requestHttpHeaders = []; } array_push($this->_requestHttpHeaders, $httpHeader); } @@ -194,7 +195,7 @@ private function BuildRequest($urlMethod, $pagination, $additionalUrlParams = nu } // encode to json if needed if (in_array(self::$_JSON_HEADER, $httpHeaders)) { - if(!is_null($this->_requestData)){ + if (!is_null($this->_requestData)) { $this->_requestData = json_encode($this->_requestData); $this->logger->debug('RequestData JSON :' . print_r($this->_requestData, true)); if ($this->_root->Config->DebugMode) { @@ -232,9 +233,9 @@ private function ReadResponseHeader($headers) $strLinks = trim(str_replace('Link:', '', $header)); $arrayLinks = explode(',', $strLinks); if ($arrayLinks !== false) { - $this->_pagination->Links = array(); + $this->_pagination->Links = []; foreach ($arrayLinks as $link) { - $tmp = str_replace(array('<"', '">', ' rel="', '"'), '', $link); + $tmp = str_replace(['<"', '">', ' rel="', '"'], '', $link); $oneLink = explode(';', $tmp); if (is_array($oneLink) && isset($oneLink[0]) && isset($oneLink[1])) { $this->_pagination->Links[$oneLink[1]] = $oneLink[0]; @@ -322,11 +323,11 @@ private function GetHttpHeaders($idempotencyKey = null) return $this->_requestHttpHeaders; } // ...or initialize with default headers - $this->_requestHttpHeaders = array(); + $this->_requestHttpHeaders = []; // content type array_push($this->_requestHttpHeaders, self::$_JSON_HEADER); // Add User-Agent Header - + array_push($this->_requestHttpHeaders, 'User-Agent: MangoPay V2 SDK PHP ' . self::VERSION); // Authentication http header if ($this->_authRequired) { diff --git a/MangoPay/Libraries/Upload.php b/MangoPay/Libraries/Upload.php index c2ba197f..43c8a0f7 100644 --- a/MangoPay/Libraries/Upload.php +++ b/MangoPay/Libraries/Upload.php @@ -7,7 +7,6 @@ */ abstract class Upload extends Dto { - /** * Image base64 * @var string diff --git a/MangoPay/Libraries/UrlTool.php b/MangoPay/Libraries/UrlTool.php index b1f429ff..42fa0cd1 100644 --- a/MangoPay/Libraries/UrlTool.php +++ b/MangoPay/Libraries/UrlTool.php @@ -1,4 +1,5 @@ _root = $root; } - + private function GetHost() { if (is_null($this->_root->Config->BaseUrl) || strlen($this->_root->Config->BaseUrl) == 0) { throw new Exception('Neither MangoPay_BaseUrl constant nor BaseUrl config setting is defined.'); } - + $baseUrl = $this->_root->Config->BaseUrl; if (strpos($baseUrl, '/', strlen($baseUrl) - 1)) { $baseUrl = substr($baseUrl, 0, strlen($baseUrl) - 1); } - + return $baseUrl; } - + public function GetRestUrl($urlKey, $addClientId = true, $pagination = null, $additionalUrlParams = null) { if (!$addClientId) { @@ -52,7 +53,7 @@ public function GetRestUrl($urlKey, $addClientId = true, $pagination = null, $ad $url .= http_build_query($additionalUrlParams["sort"]); $paramsAdded = true; } - + if (array_key_exists("filter", $additionalUrlParams)) { $url .= $paramsAdded ? '&' : '?'; $url .= http_build_query($additionalUrlParams["filter"]); @@ -62,7 +63,7 @@ public function GetRestUrl($urlKey, $addClientId = true, $pagination = null, $ad return $url; } - + public function GetFullUrl($restUrl) { return $this->GetHost() . $restUrl; diff --git a/MangoPay/MangoPayApi.php b/MangoPay/MangoPayApi.php index 006a16e2..d26a4d59 100644 --- a/MangoPay/MangoPayApi.php +++ b/MangoPay/MangoPayApi.php @@ -1,4 +1,5 @@ logger; } - + /** * @return Libraries\Configuration */ @@ -259,7 +260,7 @@ public function setConfig($Config) /** * @param \MangoPay\Libraries\HttpBase $httpClient */ - public function setHttpClient(\MangoPay\Libraries\HttpBase $httpClient) + public function setHttpClient(Libraries\HttpBase $httpClient) { $this->httpClient = $httpClient; } diff --git a/MangoPay/Money.php b/MangoPay/Money.php index 9fe9d69f..dd195ae3 100644 --- a/MangoPay/Money.php +++ b/MangoPay/Money.php @@ -12,7 +12,7 @@ class Money extends Libraries\Dto * @var string */ public $Currency; - + /** * The currency amount of money * @var int diff --git a/MangoPay/NaturalUserCapacity.php b/MangoPay/NaturalUserCapacity.php index 8d90c448..6b26bb7c 100644 --- a/MangoPay/NaturalUserCapacity.php +++ b/MangoPay/NaturalUserCapacity.php @@ -16,4 +16,4 @@ class NaturalUserCapacity * User used only for declaration purpose. */ const Declarative = 'DECLARATIVE'; -} \ No newline at end of file +} diff --git a/MangoPay/Pagination.php b/MangoPay/Pagination.php index a9046b2d..a08d19d7 100644 --- a/MangoPay/Pagination.php +++ b/MangoPay/Pagination.php @@ -12,25 +12,25 @@ class Pagination extends Libraries\Dto * @var int */ public $Page; - + /** * Number of items per page * @var int */ public $ItemsPerPage; - + /** * Number of total pages * @var int */ public $TotalPages; - + /** * Number of total items * @var int */ public $TotalItems; - + /** * Array with links to navigation. * All values optional. Format: @@ -42,8 +42,8 @@ class Pagination extends Libraries\Dto * ) * @var array */ - public $Links = array(); - + public $Links = []; + /** * Construct * @param int $page Number of page diff --git a/MangoPay/PayIn.php b/MangoPay/PayIn.php index 22678522..a5f6b410 100644 --- a/MangoPay/PayIn.php +++ b/MangoPay/PayIn.php @@ -1,4 +1,5 @@ array( + return [ + 'PaymentType' => [ '_property_name' => 'PaymentDetails', PayInPaymentType::Card => '\MangoPay\PayInPaymentDetailsCard', PayInPaymentType::Preauthorized => '\MangoPay\PayInPaymentDetailsPreAuthorized', @@ -54,15 +55,15 @@ public function GetDependsObjects() PayInPaymentType::ApplePay => 'MangoPay\PayInPaymentDetailsApplePay', PayInPaymentType::GooglePay => 'MangoPay\PayInPaymentDetailsGooglePay', // ...and more in future... - ), - 'ExecutionType' => array( + ], + 'ExecutionType' => [ '_property_name' => 'ExecutionDetails', PayInExecutionType::Web => '\MangoPay\PayInExecutionDetailsWeb', PayInExecutionType::Direct => '\MangoPay\PayInExecutionDetailsDirect', - PayInExecutionType::ExternalInstruction => '\MangoPay\PayInExecutionDetailsExternalInstruction', + PayInExecutionType::ExternalInstruction => '\MangoPay\PayInExecutionDetailsExternalInstruction', // ...and more in future... - ) - ); + ] + ]; } /** diff --git a/MangoPay/PayInCardTemplateURLOptions.php b/MangoPay/PayInCardTemplateURLOptions.php index 9b093aaa..85681e7b 100644 --- a/MangoPay/PayInCardTemplateURLOptions.php +++ b/MangoPay/PayInCardTemplateURLOptions.php @@ -1,4 +1,5 @@ '\MangoPay\Billing', 'TemplateURLOptions' => '\MangoPay\PayInTemplateURLOptions' - ); + ]; } } diff --git a/MangoPay/PayInExecutionType.php b/MangoPay/PayInExecutionType.php index 440812ea..32b38765 100644 --- a/MangoPay/PayInExecutionType.php +++ b/MangoPay/PayInExecutionType.php @@ -1,4 +1,5 @@ '\MangoPay\Money' , 'DeclaredFees' => '\MangoPay\Money' , 'BankAccount' => '\MangoPay\BankAccount' - ); + ]; } } diff --git a/MangoPay/PayInPaymentDetailsCard.php b/MangoPay/PayInPaymentDetailsCard.php index 6ab438ab..853c0134 100644 --- a/MangoPay/PayInPaymentDetailsCard.php +++ b/MangoPay/PayInPaymentDetailsCard.php @@ -1,4 +1,5 @@ array( + return [ + 'PaymentType' => [ '_property_name' => 'MeanOfPaymentDetails', PayOutPaymentType::BankWire => '\MangoPay\PayOutPaymentDetailsBankWire', // ...and more in future... - ) - ); + ] + ]; } - + /** * Get array with read-only properties * @return array @@ -48,7 +49,7 @@ public function GetReadOnlyProperties() { $properties = parent::GetReadOnlyProperties(); array_push($properties, 'PaymentType'); - + return $properties; } } diff --git a/MangoPay/PayOutPaymentDetails.php b/MangoPay/PayOutPaymentDetails.php index 4f14f7d5..f7882054 100644 --- a/MangoPay/PayOutPaymentDetails.php +++ b/MangoPay/PayOutPaymentDetails.php @@ -1,4 +1,5 @@ IntervalMinutes = $IntervalMinutes; } -} \ No newline at end of file +} diff --git a/MangoPay/Refund.php b/MangoPay/Refund.php index db7aff7d..e6fb5c73 100644 --- a/MangoPay/Refund.php +++ b/MangoPay/Refund.php @@ -1,4 +1,5 @@ '\MangoPay\Money', 'Fees' => '\MangoPay\Money', 'CreditedFunds' => '\MangoPay\Money', - ); + ]; } } diff --git a/MangoPay/Response.php b/MangoPay/Response.php index 1927ae6c..9e783cd3 100644 --- a/MangoPay/Response.php +++ b/MangoPay/Response.php @@ -1,4 +1,5 @@ '\MangoPay\Money' , 'Fees' => '\MangoPay\Money' - ); + ]; } } diff --git a/MangoPay/Shipping.php b/MangoPay/Shipping.php index 87da66f3..e05f2fd9 100644 --- a/MangoPay/Shipping.php +++ b/MangoPay/Shipping.php @@ -1,9 +1,7 @@ $this->_getFields()); + return [self::SortUrlParameterName => $this->_getFields()]; } - + private function _getFields() { $sortValues = ""; @@ -56,10 +57,10 @@ private function _getFields() if (!empty($sortValues)) { $sortValues .= self::SortFieldSeparator; } - + $sortValues .= $key . ":" . $value; } - + return $sortValues; } } diff --git a/MangoPay/Transaction.php b/MangoPay/Transaction.php index 7932e8dd..fce8058b 100644 --- a/MangoPay/Transaction.php +++ b/MangoPay/Transaction.php @@ -1,4 +1,5 @@ '\MangoPay\Money' , 'CreditedFunds' => '\MangoPay\Money' , 'Fees' => '\MangoPay\Money' - ); + ]; } - + /** * Get array with read-only properties * @return array @@ -108,7 +109,7 @@ public function GetReadOnlyProperties() array_push($properties, 'Status'); array_push($properties, 'ResultCode'); array_push($properties, 'ExecutionDate'); - + return $properties; } } diff --git a/MangoPay/TransactionNature.php b/MangoPay/TransactionNature.php index fe226ce6..8a0c4e39 100644 --- a/MangoPay/TransactionNature.php +++ b/MangoPay/TransactionNature.php @@ -1,4 +1,5 @@ PersonType = $personType; } - + /** * Get array with read-only properties * @return array @@ -42,7 +42,7 @@ public function GetReadOnlyProperties() { $properties = parent::GetReadOnlyProperties(); array_push($properties, 'PersonType'); - + return $properties; } } diff --git a/MangoPay/UserBlockStatus.php b/MangoPay/UserBlockStatus.php index f0b5370d..dedb2cc3 100644 --- a/MangoPay/UserBlockStatus.php +++ b/MangoPay/UserBlockStatus.php @@ -1,9 +1,7 @@ SetPersonType(PersonType::Legal); } - + /** - * Get array with mapping which property is object and what type of object + * Get array with mapping which property is object and what type of object * @return array */ public function GetSubObjects() { $subObjects = parent::GetSubObjects(); - + $subObjects['HeadquartersAddress'] = '\MangoPay\Address'; $subObjects['LegalRepresentativeAddress'] = '\MangoPay\Address'; - + return $subObjects; } - + /** * Get array with read-only properties * @return array @@ -128,7 +129,7 @@ public function GetReadOnlyProperties() array_push($properties, 'Statute'); array_push($properties, 'ProofOfRegistration'); array_push($properties, 'ShareholderDeclaration'); - + return $properties; } } diff --git a/MangoPay/UserNatural.php b/MangoPay/UserNatural.php index 9e39b797..c109a8ab 100644 --- a/MangoPay/UserNatural.php +++ b/MangoPay/UserNatural.php @@ -1,4 +1,5 @@ SetPersonType(PersonType::Natural); } - + /** - * Get array with mapping which property is object and what type of object + * Get array with mapping which property is object and what type of object * @return array */ public function GetSubObjects() { $subObjects = parent::GetSubObjects(); - + $subObjects['Address'] = '\MangoPay\Address'; - + return $subObjects; } - + /** * Get array with read-only properties * @return array @@ -104,7 +105,7 @@ public function GetReadOnlyProperties() $properties = parent::GetReadOnlyProperties(); array_push($properties, 'ProofOfIdentity'); array_push($properties, 'ProofOfAddress'); - + return $properties; } } diff --git a/MangoPay/Wallet.php b/MangoPay/Wallet.php index 8a1a1b78..a84491fb 100644 --- a/MangoPay/Wallet.php +++ b/MangoPay/Wallet.php @@ -1,4 +1,5 @@ '\MangoPay\Money' ); + return [ 'Balance' => '\MangoPay\Money' ]; } - + /** * Get array with read-only properties * @return array @@ -47,7 +48,7 @@ public function GetReadOnlyProperties() { $properties = parent::GetReadOnlyProperties(); array_push($properties, 'Balance'); - + return $properties; } } diff --git a/composer.json b/composer.json index 882b007d..d14889d4 100644 --- a/composer.json +++ b/composer.json @@ -12,15 +12,16 @@ }, "autoload": { "psr-4": { - "MangoPay\\": "MangoPay/" + "MangoPay\\": "MangoPay" } }, "autoload-dev": { "psr-4": { - "MangoPay\\Tests\\": "tests/" + "MangoPay\\Tests\\": "tests" } }, "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^5.7.27 || 7.3" + "phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^7.3", + "friendsofphp/php-cs-fixer": "^2.18" } } diff --git a/php_env/PHP_5.6/Dockerfile b/php_env/PHP_5.6/Dockerfile new file mode 100644 index 00000000..f16f41aa --- /dev/null +++ b/php_env/PHP_5.6/Dockerfile @@ -0,0 +1,27 @@ +FROM php:5.6-cli + +# Update and import specific required librairies + +RUN apt-get update && apt-get install -y apt-utils +RUN apt-get install -y \ + unzip \ + libicu-dev \ + gcc \ + wget \ + zlib1g-dev \ + libzip-dev + +# Parametrize PHP + +RUN docker-php-ext-install mbstring +RUN docker-php-ext-install intl +RUN docker-php-ext-install zip +RUN docker-php-ext-install pcntl +RUN docker-php-source delete + +# Install composer +COPY composer.sh / +RUN chmod +x composer.sh +RUN /composer.sh +RUN mv composer.phar /usr/local/bin/composer +RUN mkdir /.composer && chmod o+rwx /.composer diff --git a/php_env/PHP_5.6/composer.sh b/php_env/PHP_5.6/composer.sh new file mode 100644 index 00000000..a61aff80 --- /dev/null +++ b/php_env/PHP_5.6/composer.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')" +php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" + +if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ] +then + >&2 echo 'ERROR: Invalid installer checksum' + rm composer-setup.php + exit 1 +fi + +php composer-setup.php --quiet +RESULT=$? +rm composer-setup.php +exit $RESULT diff --git a/php_env/PHP_7.0/Dockerfile b/php_env/PHP_7.0/Dockerfile new file mode 100644 index 00000000..6968e868 --- /dev/null +++ b/php_env/PHP_7.0/Dockerfile @@ -0,0 +1,27 @@ +FROM php:7.0-cli + +# Update and import specific required librairies + +RUN apt-get update && apt-get install -y apt-utils +RUN apt-get install -y \ + unzip \ + libicu-dev \ + gcc \ + wget \ + zlib1g-dev \ + libzip-dev + +# Parametrize PHP + +RUN docker-php-ext-install mbstring +RUN docker-php-ext-install intl +RUN docker-php-ext-install zip +RUN docker-php-ext-install pcntl +RUN docker-php-source delete + +# Install composer +COPY composer.sh / +RUN chmod +x composer.sh +RUN /composer.sh +RUN mv composer.phar /usr/local/bin/composer +RUN mkdir /.composer && chmod o+rwx /.composer diff --git a/php_env/PHP_7.0/composer.sh b/php_env/PHP_7.0/composer.sh new file mode 100644 index 00000000..a61aff80 --- /dev/null +++ b/php_env/PHP_7.0/composer.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')" +php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" + +if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ] +then + >&2 echo 'ERROR: Invalid installer checksum' + rm composer-setup.php + exit 1 +fi + +php composer-setup.php --quiet +RESULT=$? +rm composer-setup.php +exit $RESULT diff --git a/php_env/PHP_8.0/Dockerfile b/php_env/PHP_8.0/Dockerfile new file mode 100644 index 00000000..84547f9d --- /dev/null +++ b/php_env/PHP_8.0/Dockerfile @@ -0,0 +1,28 @@ +FROM php:8.0.3-cli + +# Update and import specific required librairies + +RUN apt-get update && apt-get install -y apt-utils +RUN apt-get install -y \ + unzip \ + libicu-dev \ + libonig-dev \ + gcc \ + wget \ + zlib1g-dev \ + libzip-dev + +# Parametrize PHP + +RUN docker-php-ext-install mbstring +RUN docker-php-ext-install intl +RUN docker-php-ext-install zip +RUN docker-php-ext-install pcntl +RUN docker-php-source delete + +# Install composer +COPY composer.sh / +RUN chmod +x composer.sh +RUN /composer.sh +RUN mv composer.phar /usr/local/bin/composer +RUN mkdir /.composer && chmod o+rwx /.composer diff --git a/php_env/PHP_8.0/composer.sh b/php_env/PHP_8.0/composer.sh new file mode 100644 index 00000000..a61aff80 --- /dev/null +++ b/php_env/PHP_8.0/composer.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')" +php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" + +if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ] +then + >&2 echo 'ERROR: Invalid installer checksum' + rm composer-setup.php + exit 1 +fi + +php composer-setup.php --quiet +RESULT=$? +rm composer-setup.php +exit $RESULT diff --git a/tests/cases/BankAccountsTest.php b/tests/Cases/BankAccountsTest.php similarity index 91% rename from tests/cases/BankAccountsTest.php rename to tests/Cases/BankAccountsTest.php index ad647adc..87b2f000 100644 --- a/tests/cases/BankAccountsTest.php +++ b/tests/Cases/BankAccountsTest.php @@ -2,7 +2,6 @@ namespace MangoPay\Tests\Cases; - use MangoPay\BankAccount; use MangoPay\BankAccountDetailsOTHER; @@ -11,8 +10,7 @@ */ class BankAccountsTest extends Base { - - function test_BankAccount_GetTransactions() + public function test_BankAccount_GetTransactions() { $bankAccount = $this->getJohnsAccount(); $pagination = new \MangoPay\Pagination(); @@ -24,7 +22,8 @@ function test_BankAccount_GetTransactions() $this->assertInternalType('array', $transactions); } - function test_create_bank_account_other(){ + public function test_create_bank_account_other() + { $john = $this->getJohn(); $account = new BankAccount(); $account->OwnerName = "ANTHONY TEST"; @@ -40,7 +39,8 @@ function test_create_bank_account_other(){ $this->assertNotNull($bankAccount); } - function test_update_bank_account() { + public function test_update_bank_account() + { $john = $this->getJohn(); //creates an account to John $account = $this->getJohnsAccount(); @@ -57,14 +57,15 @@ function test_update_bank_account() { $this->assertNotTrue($updated->Active); } - function test_issue_420() { + public function test_issue_420() + { $john = $this->getJohn(); $userId = $john->Id; //creates an account to John, as it does not have any $account = $this->getJohnsAccount(); $this->_api->Users->GetBankAccounts($userId); $bankAccount = $this->_api->Users->GetBankAccounts($userId)[0]; - $bankAccount = $this->_api->Users->GetBankAccount($userId,$bankAccount->Id); + $bankAccount = $this->_api->Users->GetBankAccount($userId, $bankAccount->Id); $bankAccountToDeactivate = clone $bankAccount; $bankAccountToDeactivate->Active = false; /*$bk = $this->api->Users->UpdateBankAccount($userId, $bankAccount);*/ diff --git a/tests/cases/BankingAliasTest.php b/tests/Cases/BankingAliasTest.php similarity index 87% rename from tests/cases/BankingAliasTest.php rename to tests/Cases/BankingAliasTest.php index cdfd7a81..df510554 100644 --- a/tests/cases/BankingAliasTest.php +++ b/tests/Cases/BankingAliasTest.php @@ -7,15 +7,14 @@ */ class BankingAliasTest extends Base { - - function test_BankingAlias_Create() + public function test_BankingAlias_Create() { $bankingAliasIBAN = $this->getJohnsBankingAliasIBAN(); $this->assertTrue($bankingAliasIBAN->Id > 0); } - function test_BankingAlias_Get() + public function test_BankingAlias_Get() { $bankingAliasIBAN = $this->getJohnsBankingAliasIBAN(); @@ -24,7 +23,7 @@ function test_BankingAlias_Get() $this->assertSame($bankingAliasIBAN->Id, $getBankingAliasIBAN->Id); } - function test_BankingAlias_Update() + public function test_BankingAlias_Update() { $bankingAliasIBAN = $this->getJohnsBankingAliasIBAN(); $bankingAliasIBAN->Active = false; @@ -35,7 +34,7 @@ function test_BankingAlias_Update() $this->assertSame(false, $saveBankingAliasIBAN->Active); } - function test_BankingAlias_All() + public function test_BankingAlias_All() { $bankingAliasIBAN = $this->getJohnsBankingAliasIBAN(); $pagination = new \MangoPay\Pagination(1, 1); diff --git a/tests/cases/base.php b/tests/Cases/Base.php similarity index 98% rename from tests/cases/base.php rename to tests/Cases/Base.php index 8d851b3f..ee721d7d 100644 --- a/tests/cases/base.php +++ b/tests/Cases/Base.php @@ -2,13 +2,14 @@ namespace MangoPay\Tests\Cases; - use MangoPay\BankAccount; use MangoPay\BankAccountDetailsIBAN; use MangoPay\Birthplace; +use MangoPay\Libraries\Logs; use MangoPay\Tests\Mocks\MockStorageStrategy; use MangoPay\Ubo; use PHPUnit\Framework\TestCase; +use Psr\Log\NullLogger; set_time_limit(0); @@ -17,7 +18,6 @@ */ abstract class Base extends TestCase { - /** * Test user (natural) - access by getJohn() * @var \MangoPay\UserNatural @@ -92,7 +92,7 @@ abstract class Base extends TestCase /** @var \MangoPay\MangoPayApi */ protected $_api; - function __construct() + public function __construct() { parent::__construct(); $this->_api = $this->buildNewMangoPayApi(); @@ -100,7 +100,6 @@ function __construct() protected function buildNewMangoPayApi() { - $api = new \MangoPay\MangoPayApi(); // use test client credentails @@ -226,7 +225,7 @@ protected function getJohnsWallet() $john = $this->getJohn(); $wallet = new \MangoPay\Wallet(); - $wallet->Owners = array($john->Id); + $wallet->Owners = [$john->Id]; $wallet->Currency = 'EUR'; $wallet->Description = 'WALLET IN EUR'; @@ -258,7 +257,7 @@ protected function getJohnsPayInCardWeb() $payIn->CreditedWalletId = $wallet->Id; $payIn->PaymentDetails = $this->getPayInPaymentDetailsCard(); $payIn->ExecutionDetails = $this->getPayInExecutionDetailsWeb(); - + //Add for PAYLINEV2 parameter support. You must now use this object for Payin Card only $payIn->ExecutionDetails->TemplateURLOptions = new \MangoPay\PayInCardTemplateURLOptions(); $payIn->ExecutionDetails->TemplateURLOptions->PAYLINE = "https://www.maysite.com/payline_template/"; @@ -337,13 +336,11 @@ protected function getNewPayInDirectDebitDirect($userId = null) */ protected function getJohnsWalletWithMoney($amount = 1000) { - if (self::$JohnsWalletWithMoney === null) { - $john = $this->getJohn(); // create wallet with money $wallet = new \MangoPay\Wallet(); - $wallet->Owners = array($john->Id); + $wallet->Owners = [$john->Id]; $wallet->Currency = 'EUR'; $wallet->Description = 'WALLET IN EUR WITH MONEY'; @@ -407,8 +404,9 @@ protected function getPaylineCorrectRegistartionData($cardRegistration) curl_setopt($curlHandle, CURLOPT_POST, true); curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $data); $response = curl_exec($curlHandle); - if ($response === false && curl_errno($curlHandle) != 0) + if ($response === false && curl_errno($curlHandle) != 0) { throw new \Exception('cURL error: ' . curl_error($curlHandle)); + } curl_close($curlHandle); @@ -583,7 +581,7 @@ protected function getNewTransfer() $user = $this->getJohn(); $walletWithMoney = $this->getJohnsWalletWithMoney(); $wallet = new \MangoPay\Wallet(); - $wallet->Owners = array($user->Id); + $wallet->Owners = [$user->Id]; $wallet->Currency = 'EUR'; $wallet->Description = 'WALLET IN EUR FOR TRANSFER'; $wallet = $this->_api->Wallets->Create($wallet); @@ -755,7 +753,6 @@ protected function getJohnsPayInPaypalWeb() protected function getJohnHook() { if (self::$JohnsHook === null) { - $pagination = new \MangoPay\Pagination(1, 1); $list = $this->_api->Hooks->GetAll($pagination); @@ -801,14 +798,16 @@ protected function getMatrix() /** * @return \MangoPay\UboDeclaration|object */ - public function getMatrixUboDeclaration() { + public function getMatrixUboDeclaration() + { if (self::$MatrixUboDeclaration === null) { self::$MatrixUboDeclaration = $this->_api->UboDeclarations->Create($this->getMatrix()->Id); } return self::$MatrixUboDeclaration; } - public function createNewUboForMatrix() { + public function createNewUboForMatrix() + { $matrix = $this->getMatrix(); $declaration = $this->getMatrixUboDeclaration(); @@ -828,7 +827,8 @@ public function createNewUboForMatrix() { /** * @return Ubo|object */ - public function getMatrixUbo() { + public function getMatrixUbo() + { if (self::$MatrixUbo === null) { $matrix = $this->getMatrix(); $declaration = $this->getMatrixUboDeclaration(); @@ -861,7 +861,6 @@ protected function getDeclarativeJohn() */ protected function assertIdenticalInputProps($entity1, $entity2) { - if (is_a($entity1, '\MangoPay\Address')) { $this->assertEquals($entity1->AddressLine1, $entity2->AddressLine1); $this->assertEquals($entity1->AddressLine2, $entity2->AddressLine2); @@ -1002,14 +1001,15 @@ protected function assertIdenticalInputProps($entity1, $entity2) protected function getEntityFromList($entityId, $list) { - foreach ($list as $entity) { - if ($entityId == $entity->Id) + if ($entityId == $entity->Id) { return $entity; + } } } - protected function getClientBankAccount(){ + protected function getClientBankAccount() + { $account = new BankAccount(); $account->OwnerName = "Joe Blogs"; $account->OwnerAddress = $this->getNewAddress(); diff --git a/tests/cases/CardPreAuthorizationsTest.php b/tests/Cases/CardPreAuthorizationsTest.php similarity index 94% rename from tests/cases/CardPreAuthorizationsTest.php rename to tests/Cases/CardPreAuthorizationsTest.php index 5a399c00..76150eba 100644 --- a/tests/cases/CardPreAuthorizationsTest.php +++ b/tests/Cases/CardPreAuthorizationsTest.php @@ -9,8 +9,7 @@ */ class CardPreAuthorizationsTest extends Base { - - function test_CardPreAuthorization_Create() + public function test_CardPreAuthorization_Create() { $cardPreAuthorization = $this->getJohnsCardPreAuthorization(); @@ -25,7 +24,7 @@ function test_CardPreAuthorization_Create() //$this->assertSame(AVSResult::NO_CHECK, $cardPreAuthorization->SecurityInfo->AVSResult); } - function test_CardPreAuthorization_Get() + public function test_CardPreAuthorization_Get() { $cardPreAuthorization = $this->getJohnsCardPreAuthorization(); @@ -50,6 +49,4 @@ function test_CardPreAuthorization_Get() */ // } - } - diff --git a/tests/cases/CardRegistrationsTest.php b/tests/Cases/CardRegistrationsTest.php similarity index 91% rename from tests/cases/CardRegistrationsTest.php rename to tests/Cases/CardRegistrationsTest.php index c218a70a..656b6441 100644 --- a/tests/cases/CardRegistrationsTest.php +++ b/tests/Cases/CardRegistrationsTest.php @@ -2,14 +2,12 @@ namespace MangoPay\Tests\Cases; - /** * Tests methods for card registrations */ class CardRegistrationsTest extends Base { - - function test_CardRegistrations_Create() + public function test_CardRegistrations_Create() { $cardRegistration = $this->getJohnsCardRegistration(); $user = $this->getJohn(); @@ -23,7 +21,7 @@ function test_CardRegistrations_Create() $this->assertEquals(\MangoPay\CardRegistrationStatus::Created, $cardRegistration->Status); } - function test_CardRegistrations_Get() + public function test_CardRegistrations_Get() { $cardRegistration = $this->getJohnsCardRegistration(); @@ -33,7 +31,7 @@ function test_CardRegistrations_Get() $this->assertEquals($cardRegistration->Id, $getCardRegistration->Id); } - function test_CardRegistrations_Update() + public function test_CardRegistrations_Update() { $cardRegistration = $this->getJohnsCardRegistration(); $registrationData = $this->getPaylineCorrectRegistartionData($cardRegistration); @@ -47,7 +45,7 @@ function test_CardRegistrations_Update() $this->assertSame('000000', $getCardRegistration->ResultCode); } - function test_CardRegistrations_UpdateError() + public function test_CardRegistrations_UpdateError() { $user = $this->getJohn(); $cardRegistrationNew = new \MangoPay\CardRegistration(); @@ -63,7 +61,7 @@ function test_CardRegistrations_UpdateError() $this->assertNotNull($getCardRegistration->ResultMessage); } - function test_Cards_CheckCardExisting() + public function test_Cards_CheckCardExisting() { $cardRegistration = $this->getJohnsCardRegistration(); $cardRegistration = $this->_api->CardRegistrations->Get($cardRegistration->Id); @@ -74,7 +72,7 @@ function test_Cards_CheckCardExisting() $this->assertEquals($card->Validity, \MangoPay\CardValidity::Unknown); } - function test_Cards_Update() + public function test_Cards_Update() { $cardPreAuthorization = $this->getJohnsCardPreAuthorization(); $card = $this->_api->Cards->Get($cardPreAuthorization->CardId); @@ -88,5 +86,4 @@ function test_Cards_Update() $this->assertEquals($updatedCard->Validity, \MangoPay\CardValidity::Valid); $this->assertFalse($updatedCard->Active); } - } diff --git a/tests/cases/CardsTest.php b/tests/Cases/CardsTest.php similarity index 91% rename from tests/cases/CardsTest.php rename to tests/Cases/CardsTest.php index e397ef12..50b168e9 100644 --- a/tests/cases/CardsTest.php +++ b/tests/Cases/CardsTest.php @@ -6,14 +6,12 @@ use MangoPay\SortDirection; use MangoPay\Sorting; - /** * Tests methods for card registrations */ class CardsTest extends Base { - - function test_CardsByFingerprint_Get() + public function test_CardsByFingerprint_Get() { $john = $this->getNewJohn(); $payIn = $this->getNewPayInCardDirect($john->Id); @@ -29,7 +27,7 @@ function test_CardsByFingerprint_Get() } } - function test_Card_GetPreAuthorizations() + public function test_Card_GetPreAuthorizations() { $john = $this->getNewJohn(); $payIn = $this->getNewPayInCardDirect($john->Id); @@ -41,7 +39,7 @@ function test_Card_GetPreAuthorizations() $this->assertInternalType('array', $preauthorizations); } - function test_Card_GetTransactions() + public function test_Card_GetTransactions() { $john = $this->getNewJohn(); $payIn = $this->getNewPayInCardDirect($john->Id); @@ -55,7 +53,7 @@ function test_Card_GetTransactions() $this->assertInternalType('array', $transactions); } - function test_Card_Validate() + public function test_Card_Validate() { $new_api = $this->buildNewMangoPayApi(); @@ -72,4 +70,4 @@ function test_Card_Validate() print_r("can't test due to client issues"); } } -} \ No newline at end of file +} diff --git a/tests/cases/ClientTest.php b/tests/Cases/ClientTest.php similarity index 92% rename from tests/cases/ClientTest.php rename to tests/Cases/ClientTest.php index 4bb77146..b703115e 100644 --- a/tests/cases/ClientTest.php +++ b/tests/Cases/ClientTest.php @@ -9,21 +9,19 @@ use MangoPay\Sector; use MangoPay\Sorting; - /** * Test class for Client API */ class ClientTest extends Base { - - function test_Clients_Get() + public function test_Clients_Get() { $getClients = $this->_api->Clients->Get(); $this->assertEquals($this->_api->Config->ClientId, $getClients->ClientId); } - function test_Clients_Save() + public function test_Clients_Save() { $phoneNumber = (string)rand(0, 99999999); @@ -44,10 +42,10 @@ function test_Clients_Save() $clients->HeadquartersAddress->Country = "FR"; $clients->HeadquartersPhoneNumber = $phoneNumber; $clients->TaxNumber = "12345"; - $clients->TechEmails = array("technical@mangopay.com", "support@mangopay.com"); - $clients->AdminEmails = array("technical@mangopay.com", "support@mangopay.com"); - $clients->FraudEmails = array("technical@mangopay.com", "support@mangopay.com"); - $clients->BillingEmails = array("technical@mangopay.com", "support@mangopay.com"); + $clients->TechEmails = ["technical@mangopay.com", "support@mangopay.com"]; + $clients->AdminEmails = ["technical@mangopay.com", "support@mangopay.com"]; + $clients->FraudEmails = ["technical@mangopay.com", "support@mangopay.com"]; + $clients->BillingEmails = ["technical@mangopay.com", "support@mangopay.com"]; $saveClients = $this->_api->Clients->Update($clients); @@ -55,7 +53,7 @@ function test_Clients_Save() $this->assertSame($clients->HeadquartersPhoneNumber, $saveClients->HeadquartersPhoneNumber); } - function test_Clients_UploadLogo_EmptyFileString() + public function test_Clients_UploadLogo_EmptyFileString() { $logo = new \MangoPay\ClientLogoUpload(); $logo->File = ""; @@ -68,7 +66,7 @@ function test_Clients_UploadLogo_EmptyFileString() } } - function test_Clients_UploadLogo_WrongFileString() + public function test_Clients_UploadLogo_WrongFileString() { $logo = new \MangoPay\ClientLogoUpload(); $logo->File = "qqqq"; @@ -78,12 +76,11 @@ function test_Clients_UploadLogo_WrongFileString() $this->fail('Expected ResponseException when wrong value for file string'); } catch (\MangoPay\Libraries\ResponseException $exc) { - $this->assertFalse($exc->getCode() == 204); } } - function test_Clients_UploadLogo_CorrectFileString() + public function test_Clients_UploadLogo_CorrectFileString() { $logo = new \MangoPay\ClientLogoUpload(); $logo->File = "iVBORw0KGgoAAAANSUhEUgAAAYUAAABdCAYAAABKOXq+AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAIuhJREFUeNrsXQmYHUW1PtV3mS1ksk4WWcOSBJBFCEQDWQEBBeVD4ImgIALi+p64PPftKQrCUwlbRBREnwqB4MIqiwTCpsgSw44QMUESJtusd+l+de6tntzp6a6lu/rOneT831dfJvf27a7urqr//OecqmKe5wGBQCAQCAiHHgGBQCAQiBQIBAKBQKRAIBAIBCIFAoFAIGggG/bhqqfmGp8IA9Y5rwmm9E8DVuEazQA2P9Ttc6H7iS6AIv8/M7rszKaJGw9iufL1YBAvz+QZvHZHATa/WgYno/87xuvWX3Kh4LpG1fRcBq1jS9A83uV/U6MjEBAtvO/fs8GBP2zcAZoZJbwMJ266/W45KYwQ7MLLzZwMpvN/23i5il4tgUAgpKAURggh3MbLdPH/K4XGuHIkv4wDlzxGLZKwXWEGLx+jx9BQGIkxhV15uZWXmYHPr+DlXHqlBAKBsP2Qgk8Ie0d8j0rho/RaCQQCYdsnhSiFACGKgYiBQ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S7uPHkeKrOeCxjzrNda9dAqbcXfft3BiSjUiEgT3X1eKY7sVXmVbSOLUHzeHmQ+cAlNtdZIxAIBHMMVxoU5mQPijG4fiyhpE8IMRTDjIhMJGtZRgQCgUCkEA/oSqqs9+IxlsuWi8WpXRsxlnC5ZUIYIAbPc2/NtbZNF5lIrEYhJJ6YRiAQCEQKdhTDuS5zyhO7OzOtpeIlXCWcl+L1UDHclm8fvTvjRMT//iMpBAKBQNiK7HBXwANYkimXOid1b1rCbfcjUr+e5+6WbWlZnsnnryoXChcRIRAIBELjKAXwmAPN5cKNzaXiMrdOi8Qx5jzi5LIXep7XQ02AQCAQGogUaoDB5Y9A+lsMYDrlyfwqvfT6CQQCoXFJAYExhrNTJAYMKqczD4FAIBCIFEYUMaBCoKAygUAgjDBS8InBpiuJCIFAIBBGMCkgrrGkGJAQ0GVUotdNIBAII5cUbCgGUggEAoGwDZGCrxjiEMOvSSEQCASCGbIjpJ7XiH9xaQydyQzkMiIQCIRtVCmYKgZSCAQCgbAdkIJPDGdJiMEnBIohEAgEwnZACoifCcXghhDCB0khEAgEQnxkR2i9rxFqAbOTGJDLiEAgELZrUvAVQwsvc3g5gwiBQCAQkiN0O04CgUAgbJ9w6BEQCAQCgUiBQCAQCEPw/wIMAPlarS0ONmynAAAAAElFTkSuQmCC"; @@ -92,40 +89,35 @@ function test_Clients_UploadLogo_CorrectFileString() $this->assertTrue(true); } - function test_Clients_UploadLogoFromFile_EmptyFilePath() + public function test_Clients_UploadLogoFromFile_EmptyFilePath() { - try { $this->_api->Clients->UploadLogoFromFile(''); $this->fail('Expected ResponseException when wrong value for path of file'); } catch (\MangoPay\Libraries\Exception $exc) { - $this->assertSame('Path of file cannot be empty', $exc->getMessage()); } } - function test_Clients_UploadLogoFromFile_WrongFilePath() + public function test_Clients_UploadLogoFromFile_WrongFilePath() { - try { $this->_api->Clients->UploadLogoFromFile('notExistFileName.tmp'); $this->fail('Expected ResponseException when wrong value for path of file'); } catch (\MangoPay\Libraries\Exception $exc) { - $this->assertSame('File not exist', $exc->getMessage()); } } - function test_Clients_UploadLogoFromFile_CorrectFilePath() + public function test_Clients_UploadLogoFromFile_CorrectFilePath() { - $this->_api->Clients->UploadLogoFromFile(__DIR__ . "/../TestKycPageFile.png"); $this->assertTrue(true); } - function test_GetWallets_WrongFundsTypeValue() + public function test_GetWallets_WrongFundsTypeValue() { try { $this->_api->Clients->GetWallets("WrongValue"); @@ -136,7 +128,7 @@ function test_GetWallets_WrongFundsTypeValue() } } - function test_GetWallets_FundsTypeAll() + public function test_GetWallets_FundsTypeAll() { $sorting = new Sorting(); $sorting->AddField("CreationDate", \MangoPay\SortDirection::ASC); @@ -146,7 +138,7 @@ function test_GetWallets_FundsTypeAll() $this->assertInstanceOf('\MangoPay\Wallet', $wallets[0]); } - function test_GetWallets_FundsTypeFees() + public function test_GetWallets_FundsTypeFees() { $wallets = $this->_api->Clients->GetWallets(\MangoPay\FundsType::FEES); @@ -154,7 +146,7 @@ function test_GetWallets_FundsTypeFees() $this->assertInstanceOf('\MangoPay\Wallet', $wallets[0]); } - function test_GetWallets_FundsTypeCredit() + public function test_GetWallets_FundsTypeCredit() { $wallets = $this->_api->Clients->GetWallets(\MangoPay\FundsType::CREDIT); @@ -162,46 +154,40 @@ function test_GetWallets_FundsTypeCredit() $this->assertInstanceOf('\MangoPay\Wallet', $wallets[0]); } - function test_GetWallet_FirstParameterNull() + public function test_GetWallet_FirstParameterNull() { - try { $this->_api->Clients->GetWallet(null, null); $this->fail('Expected ResponseException when wrong value for FundsType'); } catch (\MangoPay\Libraries\Exception $exc) { - $this->assertSame('First parameter in function GetWallet in class ApiClients is required.', $exc->getMessage()); } } - function test_GetWallet_FirstParameterWrongValue() + public function test_GetWallet_FirstParameterWrongValue() { - try { $this->_api->Clients->GetWallet("WrongValue", \MangoPay\CurrencyIso::EUR); $this->fail('Expected ResponseException when wrong value for FundsType'); } catch (\MangoPay\Libraries\Exception $exc) { - $this->assertInstanceOf('\MangoPay\Libraries\Exception', $exc); } } - function test_GetWallet_SecondParameterNull() + public function test_GetWallet_SecondParameterNull() { - try { $this->_api->Clients->GetWallet(\MangoPay\FundsType::FEES, null); $this->fail('Expected ResponseException when wrong value for FundsType'); } catch (\MangoPay\Libraries\Exception $exc) { - $this->assertSame('Second parameter in function GetWallet in class ApiClients is required.', $exc->getMessage()); } } - function test_GetWallet_FundsTypeFees() + public function test_GetWallet_FundsTypeFees() { $wallet = $this->_api->Clients->GetWallet(\MangoPay\FundsType::FEES, \MangoPay\CurrencyIso::EUR); @@ -209,7 +195,7 @@ function test_GetWallet_FundsTypeFees() $this->assertEquals(\MangoPay\CurrencyIso::EUR, $wallet->Currency); } - function test_GetWallet_FundsTypeCredit() + public function test_GetWallet_FundsTypeCredit() { $wallet = $this->_api->Clients->GetWallet(\MangoPay\FundsType::CREDIT, \MangoPay\CurrencyIso::EUR); @@ -217,33 +203,29 @@ function test_GetWallet_FundsTypeCredit() $this->assertEquals(\MangoPay\CurrencyIso::EUR, $wallet->Currency); } - function test_GetWalletTransactions_WrongFundsTypeValue() + public function test_GetWalletTransactions_WrongFundsTypeValue() { - try { $this->_api->Clients->GetWalletTransactions("WrongValue", null); $this->fail('Expected ResponseException when wrong value for FundsType'); } catch (\MangoPay\Libraries\Exception $exc) { - $this->assertSame('\MangoPay\FundsType object has wrong value.', $exc->getMessage()); } } - function test_GetWalletTransactions_SecondParameterNull() + public function test_GetWalletTransactions_SecondParameterNull() { - try { $this->_api->Clients->GetWalletTransactions(\MangoPay\FundsType::FEES, null); $this->fail('Expected ResponseException when wrong value for FundsType'); } catch (\MangoPay\Libraries\Exception $exc) { - $this->assertSame('If FundsType is defined the second parameter (currency) is required.', $exc->getMessage()); } } - function test_GetWalletTransactions_All() + public function test_GetWalletTransactions_All() { $transactions = $this->_api->Clients->GetWalletTransactions(); @@ -251,7 +233,7 @@ function test_GetWalletTransactions_All() $this->assertInstanceOf('\MangoPay\Transaction', $transactions[0]); } - function test_GetWalletTransactions_Fees() + public function test_GetWalletTransactions_Fees() { $transactions = $this->_api->Clients->GetWalletTransactions(\MangoPay\FundsType::FEES, \MangoPay\CurrencyIso::EUR); @@ -259,7 +241,7 @@ function test_GetWalletTransactions_Fees() $this->assertInstanceOf('\MangoPay\Transaction', $transactions[0]); } - function test_CreateBankAccount() + public function test_CreateBankAccount() { $account = $this->getClientBankAccount(); @@ -269,7 +251,7 @@ function test_CreateBankAccount() $this->assertNotNull($createdAccount->Id); } - function test_CreatePayOut() + public function test_CreatePayOut() { $account = $this->getClientBankAccount(); $createdAccount = $this->_api->Clients->CreateBankAccount($account); diff --git a/tests/cases/ConfigurationTest.php b/tests/Cases/ConfigurationTest.php similarity index 92% rename from tests/cases/ConfigurationTest.php rename to tests/Cases/ConfigurationTest.php index a2b6ee01..a554bbe3 100644 --- a/tests/cases/ConfigurationTest.php +++ b/tests/Cases/ConfigurationTest.php @@ -1,8 +1,8 @@ _api->Config->ClientId = "test_asd"; $this->_api->Config->ClientPassword = "00000"; diff --git a/tests/cases/DisputesTest.php b/tests/Cases/DisputesTest.php similarity index 99% rename from tests/cases/DisputesTest.php rename to tests/Cases/DisputesTest.php index 08628c34..5b04ceca 100644 --- a/tests/cases/DisputesTest.php +++ b/tests/Cases/DisputesTest.php @@ -7,21 +7,19 @@ use MangoPay\SortDirection; use MangoPay\Sorting; - /** * Tests basic methods for disputes */ class DisputesTest extends Base { - /* IMPORTANT NOTE! - * + * * Due to the fact the disputes CANNOT be created on user's side, - * a special approach in testing is needed. + * a special approach in testing is needed. * In order to get the tests below pass, a bunch of disputes have * to be prepared on the API's side - if they're not, you can * just skip these tests, as they won't pass. - * + * */ private $_clientDisputes = null; @@ -39,13 +37,13 @@ public function skip() } } - + /* - * TO BE FIXED - DISPUTES TESTS KO - DATA ON ACCOUNT HAVE TO BE FIXED + * TO BE FIXED - DISPUTES TESTS KO - DATA ON ACCOUNT HAVE TO BE FIXED */ - function test_Disputes_Get() + public function test_Disputes_Get() { - $this->assertEquals("0","0"); + $this->assertEquals("0", "0"); // $dispute = $this->_api->Disputes->Get($this->_clientDisputes[0]->Id); // $this->assertNotNull($dispute); diff --git a/tests/cases/EventsTest.php b/tests/Cases/EventsTest.php similarity index 92% rename from tests/cases/EventsTest.php rename to tests/Cases/EventsTest.php index 4cae28c4..999a2a23 100644 --- a/tests/cases/EventsTest.php +++ b/tests/Cases/EventsTest.php @@ -2,14 +2,12 @@ namespace MangoPay\Tests\Cases; - /** * Tests methods for events */ class EventsTest extends Base { - - function test_GetEventList_PayinNormalCreated() + public function test_GetEventList_PayinNormalCreated() { $payIn = $this->getJohnsPayInCardWeb(); $filter = new \MangoPay\FilterEvents(); @@ -26,7 +24,6 @@ function test_GetEventList_PayinNormalCreated() private function ExistEventById($eventList, $eventId) { - foreach ($eventList as $event) { if ($event->ResourceId == $eventId) { return true; @@ -36,7 +33,7 @@ private function ExistEventById($eventList, $eventId) return false; } - function test_GetEventList_PayinNormalSucceeded() + public function test_GetEventList_PayinNormalSucceeded() { $payIn = $this->getNewPayInCardDirect(); $filter = new \MangoPay\FilterEvents(); @@ -51,7 +48,7 @@ function test_GetEventList_PayinNormalSucceeded() $this->assertTrue($this->ExistEventById($result, $payIn->Id)); } - function test_GetEventList_PayoutNormalCreated() + public function test_GetEventList_PayoutNormalCreated() { $payOut = $this->getJohnsPayOutBankWire(); $filter = new \MangoPay\FilterEvents(); @@ -66,7 +63,7 @@ function test_GetEventList_PayoutNormalCreated() $this->assertTrue($this->ExistEventById($result, $payOut->Id)); } - function test_GetKycDocumentsList_KycCreated() + public function test_GetKycDocumentsList_KycCreated() { $user = $this->getJohn(); $kycDocumentInit = new \MangoPay\KycDocument(); @@ -85,7 +82,7 @@ function test_GetKycDocumentsList_KycCreated() $this->assertTrue($this->ExistEventById($result, $kycDocument->Id)); } - function test_Events_GetAll_SortByCreationDate() + public function test_Events_GetAll_SortByCreationDate() { self::$JohnsPayInCardWeb = null; $payIn1 = $this->getJohnsPayInCardWeb(); @@ -104,4 +101,4 @@ function test_Events_GetAll_SortByCreationDate() $this->assertTrue($result[0]->Date >= $result[1]->Date); } -} \ No newline at end of file +} diff --git a/tests/cases/HooksTest.php b/tests/Cases/HooksTest.php similarity index 88% rename from tests/cases/HooksTest.php rename to tests/Cases/HooksTest.php index fb532545..c869dc51 100644 --- a/tests/cases/HooksTest.php +++ b/tests/Cases/HooksTest.php @@ -5,21 +5,19 @@ use MangoPay\SortDirection; use MangoPay\Sorting; - /** * Tests basic methods for wallets */ class HooksTest extends Base { - - function test_Hooks_Create() + public function test_Hooks_Create() { $hook = $this->getJohnHook(); $this->assertTrue($hook->Id > 0); } - function test_Hooks_Get() + public function test_Hooks_Get() { $hook = $this->getJohnHook(); @@ -28,7 +26,7 @@ function test_Hooks_Get() $this->assertSame($hook->Id, $getHook->Id); } - function test_Hooks_Update() + public function test_Hooks_Update() { $hook = $this->getJohnHook(); $hook->Url = "http://test123.com"; @@ -39,7 +37,7 @@ function test_Hooks_Update() $this->assertSame("http://test123.com", $saveHook->Url); } - function test_Hooks_All() + public function test_Hooks_All() { $hook = $this->getJohnHook(); $pagination = new \MangoPay\Pagination(1, 1); @@ -53,4 +51,4 @@ function test_Hooks_All() $this->assertSame(1, $pagination->Page); $this->assertSame(1, $pagination->ItemsPerPage); } -} \ No newline at end of file +} diff --git a/tests/cases/IdempotencyTest.php b/tests/Cases/IdempotencyTest.php similarity index 91% rename from tests/cases/IdempotencyTest.php rename to tests/Cases/IdempotencyTest.php index b8a5ef1c..b57d57b3 100644 --- a/tests/cases/IdempotencyTest.php +++ b/tests/Cases/IdempotencyTest.php @@ -2,16 +2,14 @@ namespace MangoPay\Tests\Cases; - /** * Tests methods for idempotency support * See https://docs.mangopay.com/guide/idempotency-support/ */ class IdempotencyTest extends Base { - // if post request called twice with no idempotency key, act independently - function test_NoIdempotencyKey_ActIndependently() + public function test_NoIdempotencyKey_ActIndependently() { $user = $this->buildJohn(); $user1 = $this->_api->Users->Create($user); @@ -25,19 +23,18 @@ function test_NoIdempotencyKey_ActIndependently() * @expectedException MangoPay\Libraries\ResponseException * @throws \MangoPay\Libraries\Exception */ - function test_SameIdempotencyKey_Blocks2ndCall() + public function test_SameIdempotencyKey_Blocks2ndCall() { $idempotencyKey = md5(uniqid()); $user = $this->buildJohn(); $user1 = $this->_api->Users->Create($user); $user1 = $this->_api->Users->Create($user, $idempotencyKey); -// $this->expectException('MangoPay\Libraries\ResponseException'); $user2 = $this->_api->Users->Create($user, $idempotencyKey); $this->assertTrue($user2 = null); } // if post request called twice with different idempotency key, act independently and responses may be retreived later - function test_DifferentIdempotencyKey_ActIndependentlyAndRetreivable() + public function test_DifferentIdempotencyKey_ActIndependentlyAndRetreivable() { $idempotencyKey1 = md5(uniqid()); $idempotencyKey2 = md5(uniqid()); @@ -53,7 +50,7 @@ function test_DifferentIdempotencyKey_ActIndependentlyAndRetreivable() $this->assertTrue($resp2->Resource->Id == $user2->Id); } - function test_GetIdempotencyKey_PreauthorizationCreate() + public function test_GetIdempotencyKey_PreauthorizationCreate() { $key = md5(uniqid()); $this->getJohnsCardPreAuthorization($key); @@ -63,12 +60,12 @@ function test_GetIdempotencyKey_PreauthorizationCreate() $this->assertInstanceOf('\MangoPay\CardPreAuthorization', $resp->Resource); } - function test_GetIdempotencyKey_CardregistrationCreate() + public function test_GetIdempotencyKey_CardregistrationCreate() { $key = md5(uniqid()); $john = $this->getJohn(); $wallet = new \MangoPay\Wallet(); - $wallet->Owners = array($john->Id); + $wallet->Owners = [$john->Id]; $wallet->Currency = 'EUR'; $wallet->Description = 'WALLET IN EUR WITH MONEY'; $wallet1 = $this->_api->Wallets->Create($wallet); @@ -94,7 +91,7 @@ function test_GetIdempotencyKey_CardregistrationCreate() $this->assertInstanceOf($resp->Resource, '\MangoPay\Hook'); }*/ - function test_GetIdempotencyKey_MandatesCreate() + public function test_GetIdempotencyKey_MandatesCreate() { $key = md5(uniqid()); $account = $this->getJohnsAccount(); @@ -110,7 +107,7 @@ function test_GetIdempotencyKey_MandatesCreate() $this->assertInstanceOf('\MangoPay\Mandate', $resp->Resource); } - function test_GetIdempotencyKey_PayinsCardWebCreate() + public function test_GetIdempotencyKey_PayinsCardWebCreate() { $key = md5(uniqid()); $wallet = $this->getJohnsWallet(); @@ -139,7 +136,7 @@ function test_GetIdempotencyKey_PayinsCardWebCreate() $this->assertInstanceOf('\MangoPay\PayIn', $resp->Resource); } - function test_GetIdempotencyKey_PayinsCardDirectCreate() + public function test_GetIdempotencyKey_PayinsCardDirectCreate() { $key = md5(uniqid()); $johnWallet = $this->getJohnsWalletWithMoney(); @@ -174,7 +171,7 @@ function test_GetIdempotencyKey_PayinsCardDirectCreate() $this->assertInstanceOf('\MangoPay\PayIn', $resp->Resource); } - function test_GetIdempotencyKey_PayinsPreauthorizedDirectCreate() + public function test_GetIdempotencyKey_PayinsPreauthorizedDirectCreate() { $key = md5(uniqid()); $cardPreAuthorization = $this->getJohnsCardPreAuthorization(); @@ -200,7 +197,7 @@ function test_GetIdempotencyKey_PayinsPreauthorizedDirectCreate() $this->assertInstanceOf('\MangoPay\PayIn', $resp->Resource); } - function test_GetIdempotencyKey_PayinsBankWireDirectCreate() + public function test_GetIdempotencyKey_PayinsBankWireDirectCreate() { $key = md5(uniqid()); $wallet = $this->getJohnsWallet(); @@ -223,7 +220,7 @@ function test_GetIdempotencyKey_PayinsBankWireDirectCreate() $this->assertInstanceOf('\MangoPay\PayIn', $resp->Resource); } - function test_GetIdempotencyKey_PayinsDirectdebitWebCreate() + public function test_GetIdempotencyKey_PayinsDirectdebitWebCreate() { $key = md5(uniqid()); $wallet = $this->getJohnsWallet(); @@ -251,7 +248,7 @@ function test_GetIdempotencyKey_PayinsDirectdebitWebCreate() $this->assertInstanceOf('\MangoPay\PayIn', $resp->Resource); } - function test_GetIdempotencyKey_PayinsDirectdebitDirectCreate() + public function test_GetIdempotencyKey_PayinsDirectdebitDirectCreate() { $key = md5(uniqid()); $wallet = $this->getJohnsWalletWithMoney(); @@ -277,7 +274,7 @@ function test_GetIdempotencyKey_PayinsDirectdebitDirectCreate() $this->assertInstanceOf('\MangoPay\PayIn', $resp->Resource); } - function test_GetIdempotencyKey_PayinsCreateRefunds() + public function test_GetIdempotencyKey_PayinsCreateRefunds() { $key = md5(uniqid()); $payIn = $this->getNewPayInCardDirect(); @@ -298,7 +295,7 @@ function test_GetIdempotencyKey_PayinsCreateRefunds() $this->assertInstanceOf('\MangoPay\Refund', $resp->Resource); } - function test_GetIdempotencyKey_PayoutsBankwireCreate() + public function test_GetIdempotencyKey_PayoutsBankwireCreate() { $key = md5(uniqid()); $payIn = $this->getNewPayInCardDirect(); @@ -325,7 +322,7 @@ function test_GetIdempotencyKey_PayoutsBankwireCreate() $this->assertInstanceOf('\MangoPay\PayOut', $resp->Resource); } - function test_GetIdempotencyKey_ReportsCreate() + public function test_GetIdempotencyKey_ReportsCreate() { $key = md5(uniqid()); $reportRequest = new \MangoPay\ReportRequest(); @@ -337,7 +334,7 @@ function test_GetIdempotencyKey_ReportsCreate() $this->assertInstanceOf('\MangoPay\ReportRequest', $resp->Resource); } - function test_GetIdempotencyKey_TransfersCreateRefunds() + public function test_GetIdempotencyKey_TransfersCreateRefunds() { $key = md5(uniqid()); $transfer = $this->getNewTransfer(); @@ -359,13 +356,13 @@ function test_GetIdempotencyKey_TransfersCreateRefunds() $this->assertInstanceOf('\MangoPay\Refund', $resp->Resource); } - function test_GetIdempotencyKey_TransfersCreate() + public function test_GetIdempotencyKey_TransfersCreate() { $key = md5(uniqid()); $user = $this->getJohn(); $walletWithMoney = $this->getJohnsWalletWithMoney(); $wallet1 = new \MangoPay\Wallet(); - $wallet1->Owners = array($user->Id); + $wallet1->Owners = [$user->Id]; $wallet1->Currency = 'EUR'; $wallet1->Description = 'WALLET IN EUR FOR TRANSFER'; $wallet = $this->_api->Wallets->Create($wallet1); @@ -388,7 +385,7 @@ function test_GetIdempotencyKey_TransfersCreate() $this->assertInstanceOf('\MangoPay\Transfer', $resp->Resource); } - function test_GetIdempotencyKey_UsersCreateNaturals() + public function test_GetIdempotencyKey_UsersCreateNaturals() { $key = md5(uniqid()); $user = $this->buildJohn(); @@ -399,7 +396,7 @@ function test_GetIdempotencyKey_UsersCreateNaturals() $this->assertInstanceOf('\MangoPay\UserNatural', $resp->Resource); } - function test_GetIdempotencyKey_UsersCreateLegals() + public function test_GetIdempotencyKey_UsersCreateLegals() { $key = md5(uniqid()); $john = $this->getJohn(); @@ -422,7 +419,7 @@ function test_GetIdempotencyKey_UsersCreateLegals() $this->assertInstanceOf('\MangoPay\UserLegal', $resp->Resource); } - function test_GetIdempotencyKey_UsersCreateBankAccountsIban() + public function test_GetIdempotencyKey_UsersCreateBankAccountsIban() { $key = md5(uniqid()); $john = $this->getJohn(); @@ -439,7 +436,7 @@ function test_GetIdempotencyKey_UsersCreateBankAccountsIban() $this->assertInstanceOf('\MangoPay\BankAccount', $resp->Resource); } - function test_GetIdempotencyKey_UsersCreateBankAccountsGb() + public function test_GetIdempotencyKey_UsersCreateBankAccountsGb() { $key = md5(uniqid()); $john = $this->getJohn(); @@ -456,7 +453,7 @@ function test_GetIdempotencyKey_UsersCreateBankAccountsGb() $this->assertInstanceOf('\MangoPay\BankAccount', $resp->Resource); } - function test_GetIdempotencyKey_UsersCreateBankAccountsUs() + public function test_GetIdempotencyKey_UsersCreateBankAccountsUs() { $key = md5(uniqid()); $john = $this->getJohn(); @@ -473,7 +470,7 @@ function test_GetIdempotencyKey_UsersCreateBankAccountsUs() $this->assertInstanceOf('\MangoPay\BankAccount', $resp->Resource); } - function test_GetIdempotencyKey_UsersCreateBankAccountsCa() + public function test_GetIdempotencyKey_UsersCreateBankAccountsCa() { $key = md5(uniqid()); $john = $this->getJohn(); @@ -492,7 +489,7 @@ function test_GetIdempotencyKey_UsersCreateBankAccountsCa() $this->assertInstanceOf('\MangoPay\BankAccount', $resp->Resource); } - function test_GetIdempotencyKey_UsersCreateBankAccountsOther() + public function test_GetIdempotencyKey_UsersCreateBankAccountsOther() { $key = md5(uniqid()); $john = $this->getJohn(); @@ -511,7 +508,7 @@ function test_GetIdempotencyKey_UsersCreateBankAccountsOther() $this->assertInstanceOf('\MangoPay\BankAccount', $resp->Resource); } - function test_GetIdempotencyKey_KycDocumentsCreate() + public function test_GetIdempotencyKey_KycDocumentsCreate() { $key = md5(uniqid()); $user = $this->getJohn(); @@ -525,12 +522,12 @@ function test_GetIdempotencyKey_KycDocumentsCreate() $this->assertInstanceOf('\MangoPay\KycDocument', $resp->Resource); } - function test_GetIdempotencyKey_WalletsCreate() + public function test_GetIdempotencyKey_WalletsCreate() { $key = md5(uniqid()); $john = $this->getJohn(); $wallet = new \MangoPay\Wallet(); - $wallet->Owners = array($john->Id); + $wallet->Owners = [$john->Id]; $wallet->Currency = 'EUR'; $wallet->Description = 'WALLET IN EUR'; $this->_api->Wallets->Create($wallet, $key); diff --git a/tests/cases/KycDocumentsTest.php b/tests/Cases/KycDocumentsTest.php similarity index 90% rename from tests/cases/KycDocumentsTest.php rename to tests/Cases/KycDocumentsTest.php index eae3d7fd..814f5799 100644 --- a/tests/cases/KycDocumentsTest.php +++ b/tests/Cases/KycDocumentsTest.php @@ -2,14 +2,12 @@ namespace MangoPay\Tests\Cases; - /** * Tests basic methods for KYC documents */ class KycDocumentsTest extends Base { - - function test_KycDocuments_GetAll() + public function test_KycDocuments_GetAll() { $this->getJohnsKycDocument(); $pagination = new \MangoPay\Pagination(1, 20); @@ -27,7 +25,7 @@ function test_KycDocuments_GetAll() $this->assertTrue(isset($pagination->TotalItems)); } - function test_KycDocuments_GetAll_SortByCreationDate() + public function test_KycDocuments_GetAll_SortByCreationDate() { $this->getJohnsKycDocument(); $pagination = new \MangoPay\Pagination(1, 20); @@ -39,7 +37,7 @@ function test_KycDocuments_GetAll_SortByCreationDate() $this->assertTrue($list[0]->Id > $list[1]->Id); } - function test_KycDocuments_Get() + public function test_KycDocuments_Get() { $kycDocument = $this->getJohnsKycDocument(); $user = $this->getJohn(); @@ -52,7 +50,7 @@ function test_KycDocuments_Get() $this->assertSame($kycDocument->UserId, $user->Id); } - function test_KycDocuments_CreateConsult() + public function test_KycDocuments_CreateConsult() { $kycDocument = $this->getJohnsKycDocument(); @@ -61,4 +59,4 @@ function test_KycDocuments_CreateConsult() $this->assertNotNull($consults); $this->assertInternalType('array', $consults); } -} \ No newline at end of file +} diff --git a/tests/cases/MandatesTest.php b/tests/Cases/MandatesTest.php similarity index 88% rename from tests/cases/MandatesTest.php rename to tests/Cases/MandatesTest.php index 64c31cfd..ee529cc8 100644 --- a/tests/cases/MandatesTest.php +++ b/tests/Cases/MandatesTest.php @@ -2,7 +2,6 @@ namespace MangoPay\Tests\Cases; - use MangoPay\MandateStatus; /** @@ -10,8 +9,7 @@ */ class MandatesTest extends Base { - - function test_Mandates_Create() + public function test_Mandates_Create() { $john = $this->getJohn(); @@ -22,7 +20,7 @@ function test_Mandates_Create() $this->assertSame(MandateStatus::Created, $mandate->Status); } - function test_Mandates_Get() + public function test_Mandates_Get() { $john = $this->getJohn(); $mandate = $this->getJohnsMandate(); @@ -33,7 +31,7 @@ function test_Mandates_Get() $this->assertEquals($john->Id, $getMandate->UserId); } - function test_Mandates_Cancel() + public function test_Mandates_Cancel() { $mandate = $this->getJohnsMandate(); @@ -46,7 +44,7 @@ function test_Mandates_Cancel() } } - function test_Mandates_GetAll() + public function test_Mandates_GetAll() { $this->getJohnsMandate(); @@ -56,7 +54,7 @@ function test_Mandates_GetAll() $this->assertTrue(count($mandates) > 0); } - function test_Mandate_GetTransactions() + public function test_Mandate_GetTransactions() { $mandate = $this->getJohnsMandate(); $pagination = new \MangoPay\Pagination(); diff --git a/tests/cases/PayInsTest.php b/tests/Cases/PayInsTest.php similarity index 96% rename from tests/cases/PayInsTest.php rename to tests/Cases/PayInsTest.php index 12780ba9..ca2ecab7 100644 --- a/tests/cases/PayInsTest.php +++ b/tests/Cases/PayInsTest.php @@ -15,14 +15,12 @@ use MangoPay\PayInStatus; use MangoPay\TransactionStatus; - /** * Tests methods for pay-ins */ class PayInsTest extends Base { - - function test_PayIns_Create_CardWeb() + public function test_PayIns_Create_CardWeb() { $payIn = $this->getJohnsPayInCardWeb(); @@ -34,7 +32,7 @@ function test_PayIns_Create_CardWeb() $this->assertNotNull($payIn->ExecutionDetails->Billing); } - function test_PayIns_Get_CardWeb() + public function test_PayIns_Get_CardWeb() { $payIn = $this->getJohnsPayInCardWeb(); @@ -52,7 +50,7 @@ function test_PayIns_Get_CardWeb() $this->assertNotNull($getPayIn->ExecutionDetails->ReturnURL); } - function test_PayIns_Create_CardDirect() + public function test_PayIns_Create_CardDirect() { $johnWallet = $this->getJohnsWalletWithMoney(); $beforeWallet = $this->_api->Wallets->Get($johnWallet->Id); @@ -76,7 +74,7 @@ function test_PayIns_Create_CardDirect() $this->assertEquals('PAYIN', $payIn->Type); } - function test_PayIns_Get_CardDirect() + public function test_PayIns_Get_CardDirect() { $payIn = $this->getNewPayInCardDirect(); @@ -93,7 +91,7 @@ function test_PayIns_Get_CardDirect() //$this->assertEquals(AVSResult::NO_CHECK, $getPayIn->ExecutionDetails->SecurityInfo->AVSResult); } - function test_PayIns_CreateRefund_CardDirect() + public function test_PayIns_CreateRefund_CardDirect() { $payIn = $this->getNewPayInCardDirect(); $wallet = $this->getJohnsWalletWithMoney(); @@ -110,7 +108,7 @@ function test_PayIns_CreateRefund_CardDirect() $this->assertInstanceOf('\MangoPay\RefundReasonDetails', $refund->RefundReason); } - function test_PayIns_PreAuthorizedDirect() + public function test_PayIns_PreAuthorizedDirect() { $cardPreAuthorization = $this->getJohnsCardPreAuthorization(); $wallet = $this->getJohnsWalletWithMoney(); @@ -152,7 +150,7 @@ function test_PayIns_PreAuthorizedDirect() $this->assertEquals($transactions[0]->Status, TransactionStatus::Succeeded); } - function test_PayIns_BankWireDirect_Create() + public function test_PayIns_BankWireDirect_Create() { $wallet = $this->getJohnsWallet(); $user = $this->getJohn(); @@ -191,7 +189,7 @@ function test_PayIns_BankWireDirect_Create() $this->assertNotNull($createPayIn->PaymentDetails->BankAccount->Details->BIC); } - function test_PayIns_BankWireDirect_Get() + public function test_PayIns_BankWireDirect_Get() { $wallet = $this->getJohnsWallet(); $user = $this->getJohn(); @@ -228,7 +226,7 @@ function test_PayIns_BankWireDirect_Get() $this->assertNotNull($getPayIn->PaymentDetails->BankAccount->Details->BIC); } - function test_PayIns_DirectDeDirectDebitWeb_Create() + public function test_PayIns_DirectDeDirectDebitWeb_Create() { $wallet = $this->getJohnsWallet(); $user = $this->getJohn(); @@ -278,7 +276,7 @@ function test_PayIns_DirectDeDirectDebitWeb_Create() $this->assertNotNull($createPayIn->ExecutionDetails->TemplateURL); } - function test_PayIns_Create_DirectDebitDirect() + public function test_PayIns_Create_DirectDebitDirect() { $johnWallet = $this->getJohnsWalletWithMoney(); @@ -300,7 +298,7 @@ function test_PayIns_Create_DirectDebitDirect() $this->assertEquals('PAYIN', $payIn->Type); } - function test_PayIns_Create_PaypalWeb() + public function test_PayIns_Create_PaypalWeb() { $payIn = $this->getJohnsPayInPaypalWeb(); @@ -312,7 +310,7 @@ function test_PayIns_Create_PaypalWeb() $this->assertSame('FR', $payIn->ExecutionDetails->Culture); } - function test_PayIns_Get_PaypalWeb() + public function test_PayIns_Get_PaypalWeb() { $payIn = $this->getJohnsPayInPaypalWeb(); @@ -330,7 +328,7 @@ function test_PayIns_Get_PaypalWeb() $this->assertSame('FR', $getPayIn->ExecutionDetails->Culture); } - function test_PayPal_BuyerAccountEmail() + public function test_PayPal_BuyerAccountEmail() { $payInId = "54088959"; $buyerEmail = "paypal-buyer-user@mangopay.com"; @@ -346,7 +344,7 @@ function test_PayPal_BuyerAccountEmail() $this->assertSame($paymentDetails->PaypalBuyerAccountEmail, $buyerEmail); } - function test_PayIns_Get_ExtendedCardView() + public function test_PayIns_Get_ExtendedCardView() { $payIn = $this->getJohnsPayInCardWeb(); @@ -363,7 +361,7 @@ function test_PayIns_Get_ExtendedCardView() $this->assertTrue(strpos($message, 'Not found') !== false); } - function test_PayIn_GetRefunds() + public function test_PayIn_GetRefunds() { $payIn = $this->getJohnsPayInCardWeb(); $pagination = new \MangoPay\Pagination(); @@ -375,7 +373,7 @@ function test_PayIn_GetRefunds() $this->assertInternalType('array', $refunds); } - function test_PayIns_Culture_Code() + public function test_PayIns_Culture_Code() { $payin = $this->getNewPayInCardDirect(); @@ -384,7 +382,8 @@ function test_PayIns_Culture_Code() $this->assertNotNull($payin->ExecutionDetails->Culture); } - function test_get_bank_wire_external_instructions_iban(){ + public function test_get_bank_wire_external_instructions_iban() + { $payIn = $this->_api->PayIns->Get("74980101"); $this->assertTrue($payIn->PaymentType == PayInPaymentType::BankWire); @@ -397,7 +396,7 @@ function test_get_bank_wire_external_instructions_iban(){ $this->assertNull($payIn->ExecutionDetails->DebitedBankAccount->AccountNumber); } - function test_get_bank_wire_external_instructions_account_number() + public function test_get_bank_wire_external_instructions_account_number() { $payIn = $this->_api->PayIns->Get("74981216"); @@ -411,7 +410,7 @@ function test_get_bank_wire_external_instructions_account_number() $this->assertNotNull($payIn->ExecutionDetails->DebitedBankAccount->AccountNumber); } - function test_PayIns_Apple_Pay_Create() + public function test_PayIns_Apple_Pay_Create() { $wallet = $this->getJohnsWallet(); $user = $this->getJohn(); @@ -451,7 +450,7 @@ function test_PayIns_Apple_Pay_Create() } - function test_PayIns_Google_Pay_Create() + public function test_PayIns_Google_Pay_Create() { $this->markTestIncomplete( "Cannot test Google Pay" @@ -494,4 +493,3 @@ function test_PayIns_Google_Pay_Create() $this->assertEquals("EUR", $createPayIn->Fees->Currency); } } - diff --git a/tests/cases/PayOutsTest.php b/tests/Cases/PayOutsTest.php similarity index 88% rename from tests/cases/PayOutsTest.php rename to tests/Cases/PayOutsTest.php index 5ae3aaf8..68e7709f 100644 --- a/tests/cases/PayOutsTest.php +++ b/tests/Cases/PayOutsTest.php @@ -2,14 +2,12 @@ namespace MangoPay\Tests\Cases; - /** * Tests methods for pay-outs */ class PayOutsTest extends Base { - - function test_PayOut_Create() + public function test_PayOut_Create() { $payOut = $this->getJohnsPayOutForCardDirect(); @@ -18,7 +16,7 @@ function test_PayOut_Create() $this->assertInstanceOf('\MangoPay\PayOutPaymentDetailsBankWire', $payOut->MeanOfPaymentDetails); } - function test_PayOut_Get() + public function test_PayOut_Get() { $payOut = $this->getJohnsPayOutForCardDirect(); @@ -33,14 +31,14 @@ function test_PayOut_Get() } // Cannot test anything else here: have no pay-ins with sufficient status? - function test_PayOuts_Create_BankWire_FailsCauseNotEnoughMoney() + public function test_PayOuts_Create_BankWire_FailsCauseNotEnoughMoney() { $payOut = $this->getJohnsPayOutBankWire(); $this->assertSame(\MangoPay\PayOutStatus::Failed, $payOut->Status); } - function test_PayOut_GetRefunds() + public function test_PayOut_GetRefunds() { $payOut = $this->getJohnsPayOutForCardDirect(); $pagination = new \MangoPay\Pagination(); @@ -52,4 +50,3 @@ function test_PayOut_GetRefunds() $this->assertInternalType('array', $refunds); } } - diff --git a/tests/cases/RateLimitTest.php b/tests/Cases/RateLimitTest.php similarity index 79% rename from tests/cases/RateLimitTest.php rename to tests/Cases/RateLimitTest.php index 7d32f0c3..a40ff950 100644 --- a/tests/cases/RateLimitTest.php +++ b/tests/Cases/RateLimitTest.php @@ -1,12 +1,10 @@ assertNull($this->_api->RateLimits); $this->getJohnsCardPreAuthorization(); @@ -16,4 +14,4 @@ function test_RateLimitsUpdate() $this->assertNotNull($rateLimits); $this->assertTrue(sizeof($rateLimits) == 4); } -} \ No newline at end of file +} diff --git a/tests/cases/RefundsTest.php b/tests/Cases/RefundsTest.php similarity index 99% rename from tests/cases/RefundsTest.php rename to tests/Cases/RefundsTest.php index 565bcfe5..56a46d20 100644 --- a/tests/cases/RefundsTest.php +++ b/tests/Cases/RefundsTest.php @@ -2,13 +2,11 @@ namespace MangoPay\Tests\Cases; - /** * Tests basic methods for refunds */ class RefundsTest extends Base { - public function test_Refund_GetForTransfer() { $transfer = $this->getNewTransfer(); diff --git a/tests/cases/ReportsTest.php b/tests/Cases/ReportsTest.php similarity index 89% rename from tests/cases/ReportsTest.php rename to tests/Cases/ReportsTest.php index 674e0e1d..5b71fce3 100644 --- a/tests/cases/ReportsTest.php +++ b/tests/Cases/ReportsTest.php @@ -2,14 +2,12 @@ namespace MangoPay\Tests\Cases; - /** * Tests basic methods for report requests */ class ReportsTest extends Base { - - function test_ReportRequestTransactions_Create() + public function test_ReportRequestTransactions_Create() { $reportRequest = new \MangoPay\ReportRequest(); $reportRequest->ReportType = \MangoPay\ReportType::Transactions; @@ -21,7 +19,7 @@ function test_ReportRequestTransactions_Create() $this->assertSame($createReportRequest->ReportType, \MangoPay\ReportType::Transactions); } - function test_ReportRequestWallets_Create() + public function test_ReportRequestWallets_Create() { $reportRequest = new \MangoPay\ReportRequest(); $reportRequest->ReportType = \MangoPay\ReportType::Wallets; @@ -33,7 +31,7 @@ function test_ReportRequestWallets_Create() $this->assertSame($createReportRequest->ReportType, \MangoPay\ReportType::Wallets); } - function test_ReportRequest_Get() + public function test_ReportRequest_Get() { $reportRequest = new \MangoPay\ReportRequest(); $reportRequest->ReportType = \MangoPay\ReportType::Transactions; @@ -46,7 +44,7 @@ function test_ReportRequest_Get() $this->assertSame($getReportRequest->ReportType, $createReportRequest->ReportType); } - function test_ReportRequest_All() + public function test_ReportRequest_All() { $pagination = new \MangoPay\Pagination(1, 1); @@ -56,7 +54,7 @@ function test_ReportRequest_All() $this->assertInstanceOf('\MangoPay\ReportRequest', $getAllReportRequests[0]); } - function test_ReportRequest_All_SortByCreationDate() + public function test_ReportRequest_All_SortByCreationDate() { $pagination = new \MangoPay\Pagination(1, 1); $sorting = new \MangoPay\Sorting(); diff --git a/tests/cases/TokensTest.php b/tests/Cases/TokensTest.php similarity index 92% rename from tests/cases/TokensTest.php rename to tests/Cases/TokensTest.php index 591e2fc5..6de1f086 100644 --- a/tests/cases/TokensTest.php +++ b/tests/Cases/TokensTest.php @@ -2,14 +2,12 @@ namespace MangoPay\Tests\Cases; - /** * Tests for holding authentication token in instance */ class TokensTest extends Base { - - function test_forceToken() + public function test_forceToken() { $authHlp = new \MangoPay\Libraries\AuthenticationHelper($this->_api); @@ -19,7 +17,7 @@ function test_forceToken() $this->assertNotEquals($oldToken->access_token, $newToken->access_token); } - function test_storeToken() + public function test_storeToken() { $authHlp = new \MangoPay\Libraries\AuthenticationHelper($this->_api); $token = new \MangoPay\Libraries\OAuthToken(); @@ -38,7 +36,7 @@ function test_storeToken() $this->_api->OAuthTokenManager->StoreToken($token); } - function test_storeToken_differentAutenticationKey() + public function test_storeToken_differentAutenticationKey() { $authHlp = new \MangoPay\Libraries\AuthenticationHelper($this->_api); $token = new \MangoPay\Libraries\OAuthToken(); @@ -58,7 +56,7 @@ function test_storeToken_differentAutenticationKey() $this->_api->OAuthTokenManager->StoreToken($token); } - function test_stadnardUseToken() + public function test_stadnardUseToken() { $authHlp = new \MangoPay\Libraries\AuthenticationHelper($this->_api); $token = $this->_api->OAuthTokenManager->GetToken($authHlp->GetAutenticationKey()); @@ -70,7 +68,7 @@ function test_stadnardUseToken() $this->assertEquals($token->token_type, $tokenAfterCall->token_type); } - function test_isTokenLeaking() + public function test_isTokenLeaking() { $authHlp = new \MangoPay\Libraries\AuthenticationHelper($this->_api); $api = $this->buildNewMangoPayApi(); diff --git a/tests/cases/TransfersTest.php b/tests/Cases/TransfersTest.php similarity index 95% rename from tests/cases/TransfersTest.php rename to tests/Cases/TransfersTest.php index 3b9002ee..e8073ada 100644 --- a/tests/cases/TransfersTest.php +++ b/tests/Cases/TransfersTest.php @@ -2,7 +2,6 @@ namespace MangoPay\Tests\Cases; - use MangoPay\Money; use MangoPay\Transfer; @@ -11,8 +10,7 @@ */ class TransfersTest extends Base { - - function test_Transfers_Create() + public function test_Transfers_Create() { $john = $this->getJohn(); @@ -25,7 +23,7 @@ function test_Transfers_Create() $this->assertEquals(100, $creditedWallet->Balance->Amount); } - function test_Transfers_Get() + public function test_Transfers_Get() { $john = $this->getJohn(); $transfer = $this->getNewTransfer(); @@ -67,7 +65,8 @@ public function test_Transfer_GetRefunds() $this->assertInternalType('array', $refunds); } - public function test_Transfer_Create(){ + public function test_Transfer_Create() + { $john = $this->getJohn(); $debitedWallet = $this->getJohnsWalletWithMoney(); $creditedWallet = $this->getJohnsWallet(); @@ -88,6 +87,5 @@ public function test_Transfer_Create(){ $this->assertNotNull($result); $this->assertEquals($transfer->DebitedFunds->Currency, $creditedWallet->Currency); $this->assertEquals($transfer->Fees->Currency, $creditedWallet->Currency); - } -} \ No newline at end of file +} diff --git a/tests/cases/UboDeclarationsTest.php b/tests/Cases/UboDeclarationsTest.php similarity index 92% rename from tests/cases/UboDeclarationsTest.php rename to tests/Cases/UboDeclarationsTest.php index b42045fa..69566ea1 100644 --- a/tests/cases/UboDeclarationsTest.php +++ b/tests/Cases/UboDeclarationsTest.php @@ -2,7 +2,6 @@ namespace MangoPay\Tests\Cases; - use MangoPay\Libraries\Exception; use MangoPay\Libraries\ResponseException; use MangoPay\UboDeclarationStatus; @@ -12,7 +11,8 @@ */ class UboDeclarationsTest extends Base { - function setUp() { + public function setUp() + { $this->_api->Config->DebugMode = true; } @@ -22,7 +22,7 @@ protected function tearDown() } - function test_CreateUboDeclaration() + public function test_CreateUboDeclaration() { $declaration = $this->getMatrixUboDeclaration(); $this->assertNotNull($declaration); @@ -30,7 +30,7 @@ function test_CreateUboDeclaration() $this->assertNotNull($declaration->Id); } - function test_ListUboDeclarations() + public function test_ListUboDeclarations() { $declaration = $this->getMatrixUboDeclaration(); $matrix = $this->getMatrix(); @@ -43,7 +43,7 @@ function test_ListUboDeclarations() $this->assertEquals($declaration->Id, $declarations[0]->Id); } - function test_GetUboDeclaration() + public function test_GetUboDeclaration() { $declaration = $this->getMatrixUboDeclaration(); $matrix = $this->getMatrix(); @@ -52,10 +52,9 @@ function test_GetUboDeclaration() $this->assertNotNull($declarationFromApi); $this->assertEquals($declaration->Id, $declarationFromApi->Id); - } - function test_getUboDeclarationById() + public function test_getUboDeclarationById() { $declaration = $this->getMatrixUboDeclaration(); $declarationFromApi = $this->_api->UboDeclarations->GetUboDeclarationById($declaration->Id); @@ -64,7 +63,7 @@ function test_getUboDeclarationById() $this->assertNotNull($declarationFromApi->UserId); } - function test_CreateUbo() + public function test_CreateUbo() { $ubo = $this->createNewUboForMatrix(); $newUbo = $this->getMatrixUbo(); @@ -82,18 +81,17 @@ function test_CreateUbo() $this->assertEquals($ubo->Birthplace, $newUbo->Birthplace); } - function test_throw_CreateUbo() + public function test_throw_CreateUbo() { $matrix = $this->getMatrix(); $ubo = $this->createNewUboForMatrix(); $this->assertNotNull($ubo); $this->assertNotNull($matrix->Id); - try{ - $this->_api->UboDeclarations->CreateUbo($matrix->Id,null, $ubo); - } catch (ResponseException $e){ + try { + $this->_api->UboDeclarations->CreateUbo($matrix->Id, null, $ubo); + } catch (ResponseException $e) { log($e->_code); } - } public function test_UpdateUbo() @@ -148,7 +146,7 @@ public function test_GetUbo() $this->assertEquals($existingUbo->Birthplace, $fetchedUbo->Birthplace); } - function test_SubmitForValidation() + public function test_SubmitForValidation() { $declaration = $this->getMatrixUboDeclaration(); $matrix = $this->getMatrix(); @@ -157,4 +155,4 @@ function test_SubmitForValidation() $this->assertEquals($declaration->Id, $newDeclaration->Id); } -} \ No newline at end of file +} diff --git a/tests/cases/UsersTest.php b/tests/Cases/UsersTest.php similarity index 90% rename from tests/cases/UsersTest.php rename to tests/Cases/UsersTest.php index d498cabf..c4e02a66 100644 --- a/tests/cases/UsersTest.php +++ b/tests/Cases/UsersTest.php @@ -3,29 +3,29 @@ namespace MangoPay\Tests\Cases; use MangoPay\Libraries\Exception; - +use MangoPay\Libraries\Logs; +use MangoPay\Libraries\ResponseException; /** * Tests basic CRUD methods for users */ class UsersTest extends Base { - - function test_Users_CreateNatural() + public function test_Users_CreateNatural() { $john = $this->getJohn(); $this->assertTrue($john->Id > 0); $this->assertSame(\MangoPay\PersonType::Natural, $john->PersonType); } - function test_Users_CreateLegal() + public function test_Users_CreateLegal() { $matrix = $this->getMatrix(); $this->assertTrue($matrix->Id > 0); $this->assertSame(\MangoPay\PersonType::Legal, $matrix->PersonType); } - function test_Users_GetEMoney() + public function test_Users_GetEMoney() { $john = $this->getJohn(); $year = 2019; @@ -37,14 +37,14 @@ function test_Users_GetEMoney() $this->assertSame($john->Id, $ret->UserId); } - function test_Users_GetEMoneyFunctionWithOneParam() + public function test_Users_GetEMoneyFunctionWithOneParam() { $john = $this->getJohn(); $ret = $this->_api->Users->GetEMoney($john->Id); $this->assertSame($john->Id, $ret->UserId); } - function test_Users_GetEMoneyWithNullValues() + public function test_Users_GetEMoneyWithNullValues() { $john = $this->getJohn(); $ret = $this->_api->Users->GetEMoney($john->Id, null, null); @@ -55,7 +55,7 @@ function test_Users_GetEMoneyWithNullValues() * @expectedException MangoPay\Libraries\ResponseException * @throws Exception */ - function test_Users_CreateLegal_FailsIfRequiredPropsNotProvided() + public function test_Users_CreateLegal_FailsIfRequiredPropsNotProvided() { $user = new \MangoPay\UserLegal(); // $this->expectException(Exception::class); @@ -65,7 +65,7 @@ function test_Users_CreateLegal_FailsIfRequiredPropsNotProvided() $this->fail("Creation should fail because required props are not set"); } - function test_Users_CreateLegal_PassesIfRequiredPropsProvided() + public function test_Users_CreateLegal_PassesIfRequiredPropsProvided() { $user = new \MangoPay\UserLegal(); $user->HeadquartersAddress = new \MangoPay\Address(); @@ -98,7 +98,7 @@ function test_Users_CreateLegal_PassesIfRequiredPropsProvided() $this->assertIdenticalInputProps($user, $ret); } - function test_Users_GetNatural() + public function test_Users_GetNatural() { $john = $this->getJohn(); @@ -110,34 +110,27 @@ function test_Users_GetNatural() $this->assertIdenticalInputProps($user1, $john); } - /** - * - * @expectedException MangoPay\Libraries\ResponseException - */ - function test_Users_GetNatural_FailsForLegalUser() + public function test_Users_GetNatural_FailsForLegalUser() { $matrix = $this->getMatrix(); -// $this->expectException(Exception::class); + $this->expectException(ResponseException::class); $user = $this->_api->Users->GetNatural($matrix->Id); $this->fail("GetNatural should fail when called with legal user id"); } - /** - * @expectedException MangoPay\Libraries\ResponseException - */ - function test_Users_GetLegal_FailsForNaturalUser() + public function test_Users_GetLegal_FailsForNaturalUser() { $john = $this->getJohn(); -// $this->expectException(Exception::class); + $this->expectException(ResponseException::class); $user = $this->_api->Users->GetLegal($john->Id); $this->fail("GetLegal should fail when called with natural user id"); } - function test_Users_GetLegal() + public function test_Users_GetLegal() { $matrix = $this->getMatrix(); @@ -149,7 +142,7 @@ function test_Users_GetLegal() $this->assertIdenticalInputProps($user1, $matrix); } - function test_Users_Save_Natural() + public function test_Users_Save_Natural() { $john = $this->getJohn(); $john->LastName .= " - CHANGED"; @@ -161,7 +154,7 @@ function test_Users_Save_Natural() $this->assertIdenticalInputProps($userFetched, $john); } - function test_Users_Save_NaturalAndClearAddresIfNeeded() + public function test_Users_Save_NaturalAndClearAddresIfNeeded() { $user = new \MangoPay\UserNatural(); $user->FirstName = "John"; @@ -177,7 +170,7 @@ function test_Users_Save_NaturalAndClearAddresIfNeeded() $this->assertTrue($userSaved->Id > 0); } - function test_Users_Save_Legal() + public function test_Users_Save_Legal() { $matrix = $this->getMatrix(); $matrix->LegalRepresentativeLastName .= " - CHANGED"; @@ -189,7 +182,7 @@ function test_Users_Save_Legal() $this->assertIdenticalInputProps($userFetched, $matrix); } - function test_Users_Save_LegalAndClearAddresIfNeeded() + public function test_Users_Save_LegalAndClearAddresIfNeeded() { $user = new \MangoPay\UserLegal(); $user->Name = "MartixSampleOrg"; @@ -207,7 +200,7 @@ function test_Users_Save_LegalAndClearAddresIfNeeded() $this->assertTrue($userSaved->Id > 0); } - function test_Users_CreateBankAccount_IBAN() + public function test_Users_CreateBankAccount_IBAN() { $john = $this->getJohn(); $account = $this->getJohnsAccount(); @@ -216,7 +209,7 @@ function test_Users_CreateBankAccount_IBAN() $this->assertSame($john->Id, $account->UserId); } - function test_Users_CreateBankAccount_GB() + public function test_Users_CreateBankAccount_GB() { $john = $this->getJohn(); $account = new \MangoPay\BankAccount(); @@ -235,7 +228,7 @@ function test_Users_CreateBankAccount_GB() $this->assertSame('200000', $createAccount->Details->SortCode); } - function test_Users_CreateBankAccount_US() + public function test_Users_CreateBankAccount_US() { $john = $this->getJohn(); $account = new \MangoPay\BankAccount(); @@ -254,7 +247,7 @@ function test_Users_CreateBankAccount_US() $this->assertSame('234334789', $createAccount->Details->ABA); } - function test_Users_CreateBankAccount_CA() + public function test_Users_CreateBankAccount_CA() { $john = $this->getJohn(); $account = new \MangoPay\BankAccount(); @@ -277,7 +270,7 @@ function test_Users_CreateBankAccount_CA() $this->assertSame('123', $createAccount->Details->InstitutionNumber); } - function test_Users_CreateBankAccount_OTHER() + public function test_Users_CreateBankAccount_OTHER() { $john = $this->getJohn(); $account = new \MangoPay\BankAccount(); @@ -300,7 +293,7 @@ function test_Users_CreateBankAccount_OTHER() $this->assertSame('BINAADADXXX', $createAccount->Details->BIC); } - function test_Users_DeactivateBankAccount() + public function test_Users_DeactivateBankAccount() { $john = $this->getJohn(); $account = $this->getJohnsAccount(); @@ -311,7 +304,7 @@ function test_Users_DeactivateBankAccount() $this->assertFalse($account->Active); } - function test_Users_BankAccount() + public function test_Users_BankAccount() { $john = $this->getJohn(); $account = $this->getJohnsAccount(); @@ -320,7 +313,7 @@ function test_Users_BankAccount() $this->assertIdenticalInputProps($account, $accountFetched); } - function test_Users_BankAccounts() + public function test_Users_BankAccounts() { $john = $this->getJohn(); $account = $this->getJohnsAccount(); @@ -337,7 +330,7 @@ function test_Users_BankAccounts() $this->assertTrue(isset($pagination->TotalItems)); } - function test_Users_BankAccounts_SortByCreationDate() + public function test_Users_BankAccounts_SortByCreationDate() { $john = $this->getJohn(); $this->getJohnsAccount(); @@ -352,7 +345,7 @@ function test_Users_BankAccounts_SortByCreationDate() $this->assertTrue($list[0]->CreationDate >= $list[1]->CreationDate); } - function test_Users_BankAccounts_Filtering() + public function test_Users_BankAccounts_Filtering() { $john = $this->getJohn(); $this->getJohnsAccount(); @@ -372,7 +365,7 @@ function test_Users_BankAccounts_Filtering() $this->assertCount(12, $activeList); } - function test_Users_UpdateBankAccount() + public function test_Users_UpdateBankAccount() { $john = $this->getJohn(); $account = $this->getJohnsAccount(); @@ -384,7 +377,7 @@ function test_Users_UpdateBankAccount() $this->assertFalse($accountResult->Active); } - function test_Users_CreateKycDocument() + public function test_Users_CreateKycDocument() { $kycDocument = $this->getJohnsKycDocument(); @@ -395,7 +388,7 @@ function test_Users_CreateKycDocument() $this->assertSame($kycDocument->UserId, $user->Id); } - function test_Users_GetKycDocument() + public function test_Users_GetKycDocument() { $kycDocument = $this->getJohnsKycDocument(); $user = $this->getJohn(); @@ -408,7 +401,7 @@ function test_Users_GetKycDocument() $this->assertSame($kycDocument->UserId, $user->Id); } - function test_Users_GetKycDocuments() + public function test_Users_GetKycDocuments() { $kycDocument = $this->getJohnsKycDocument(); $user = $this->getJohn(); @@ -426,7 +419,7 @@ function test_Users_GetKycDocuments() $this->assertTrue(isset($pagination->TotalItems)); } - function test_Users_GetKycDocuments_SortByCreationDate() + public function test_Users_GetKycDocuments_SortByCreationDate() { $this->getJohnsKycDocument(); self::$JohnsKycDocument = null; @@ -441,36 +434,33 @@ function test_Users_GetKycDocuments_SortByCreationDate() $this->assertTrue($getKycDocuments[0]->CreationDate >= $getKycDocuments[1]->CreationDate); } - function test_Users_CreateKycDocument_TestAll() + public function test_Users_CreateKycDocument_TestAll() { $john = $this->getJohn(); $legalJohn = $this->getMatrix(); - $aKycDocTypes = array( - array(\MangoPay\KycDocumentType::AddressProof, $john->Id), - array(\MangoPay\KycDocumentType::ArticlesOfAssociation, $legalJohn->Id), - array(\MangoPay\KycDocumentType::IdentityProof, $john->Id), - array(\MangoPay\KycDocumentType::RegistrationProof, $legalJohn->Id), - array(\MangoPay\KycDocumentType::ShareholderDeclaration, $legalJohn->Id) - ); + $aKycDocTypes = [ + [\MangoPay\KycDocumentType::AddressProof, $john->Id], + [\MangoPay\KycDocumentType::ArticlesOfAssociation, $legalJohn->Id], + [\MangoPay\KycDocumentType::IdentityProof, $john->Id], + [\MangoPay\KycDocumentType::RegistrationProof, $legalJohn->Id], + [\MangoPay\KycDocumentType::ShareholderDeclaration, $legalJohn->Id] + ]; foreach ($aKycDocTypes as $kycDoc) { try { $this->CreateKycDocument_TestOne($kycDoc[0], $kycDoc[1]); } catch (\MangoPay\Libraries\Exception $exc) { - $message = 'Error (Code: ' . $exc->getCode() . ', ' . $exc->getMessage() . ') ' . 'during create/get KYC Document with type: ' . $kycDoc[0]; $this->fail($message); - } } } - function CreateKycDocument_TestOne($kycDocType, $userId) + public function CreateKycDocument_TestOne($kycDocType, $userId) { - $kycDocument = new \MangoPay\KycDocument(); $kycDocument->Status = \MangoPay\KycDocumentStatus::Created; $kycDocument->Type = $kycDocType; @@ -486,7 +476,7 @@ function CreateKycDocument_TestOne($kycDocType, $userId) $this->assertSame($getKycDocument->Type, $createdKycDocument->Type); } - function test_Users_UpdateKycDocument() + public function test_Users_UpdateKycDocument() { $kycDocument = $this->getJohnsKycDocument(); $user = $this->getJohn(); @@ -501,7 +491,7 @@ function test_Users_UpdateKycDocument() $this->assertTrue($success); } - function test_Users_CreateKycPage_EmptyFileString() + public function test_Users_CreateKycPage_EmptyFileString() { $kycDocument = $this->getJohnsKycDocument(); $user = $this->getJohn(); @@ -512,12 +502,12 @@ function test_Users_CreateKycPage_EmptyFileString() $this->_api->Users->CreateKycPage($user->Id, $kycDocument->Id, $kycPage); $this->fail('Expected ResponseException when empty file string'); - } catch (\MangoPay\Libraries\ResponseException $exc) { + } catch (ResponseException $exc) { $this->assertSame(400, $exc->getCode()); } } - function test_Users_CreateKycPage_WrongFileString() + public function test_Users_CreateKycPage_WrongFileString() { $kycDocument = $this->getJohnsKycDocument(); $user = $this->getJohn(); @@ -528,13 +518,12 @@ function test_Users_CreateKycPage_WrongFileString() $this->_api->Users->CreateKycPage($user->Id, $kycDocument->Id, $kycPage); $this->fail('Expected ResponseException when wrong value for file string'); - } catch (\MangoPay\Libraries\ResponseException $exc) { - + } catch (ResponseException $exc) { $this->assertSame(400, $exc->getCode()); } } - function test_Users_CreateKycPage_CorrectFileString() + public function test_Users_CreateKycPage_CorrectFileString() { $user = $this->getJohn(); $kycDocumentInit = new \MangoPay\KycDocument(); @@ -628,7 +617,7 @@ function test_Users_CreateKycPage_CorrectFileString() $this->assertTrue($uploaded); } - function test_Users_CreateKycPage_EmptyFilePath() + public function test_Users_CreateKycPage_EmptyFilePath() { $user = $this->getJohn(); $kycDocumentInit = new \MangoPay\KycDocument(); @@ -640,12 +629,11 @@ function test_Users_CreateKycPage_EmptyFilePath() $this->_api->Users->CreateKycPageFromFile($user->Id, $kycDocument->Id, ''); $this->fail("This should have failed because path to file is empty"); } catch (\MangoPay\Libraries\Exception $exc) { - $this->assertSame('Path of file cannot be empty', $exc->getMessage()); } } - function test_Users_CreateKycPage_WrongFilePath() + public function test_Users_CreateKycPage_WrongFilePath() { $user = $this->getJohn(); $kycDocumentInit = new \MangoPay\KycDocument(); @@ -657,12 +645,11 @@ function test_Users_CreateKycPage_WrongFilePath() $this->_api->Users->CreateKycPageFromFile($user->Id, $kycDocument->Id, 'notExistFileName.tmp'); $this->fail("This should have failed because file is non existent"); } catch (\MangoPay\Libraries\Exception $exc) { - $this->assertSame('File not exist', $exc->getMessage()); } } - function test_Users_CreateKycPage_CorrectFilePath() + public function test_Users_CreateKycPage_CorrectFilePath() { $user = $this->getJohn(); $kycDocumentInit = new \MangoPay\KycDocument(); @@ -674,7 +661,7 @@ function test_Users_CreateKycPage_CorrectFilePath() $this->assertTrue(true); } - function test_Users_AllTransactions() + public function test_Users_AllTransactions() { $john = $this->getJohn(); $payIn = $this->getNewPayInCardDirect(); @@ -692,7 +679,7 @@ function test_Users_AllTransactions() $this->assertIdenticalInputProps($transactions[0], $payIn); } - function test_Users_AllTransactions_SortByCreationDate() + public function test_Users_AllTransactions_SortByCreationDate() { $john = $this->getJohn(); $this->getNewPayInCardDirect(); @@ -708,7 +695,7 @@ function test_Users_AllTransactions_SortByCreationDate() $this->assertTrue($transactions[0]->CreationDate >= $transactions[1]->CreationDate); } - function test_Users_AllCards() + public function test_Users_AllCards() { $john = $this->getNewJohn(); $payIn = $this->getNewPayInCardDirect($john->Id); @@ -722,7 +709,7 @@ function test_Users_AllCards() $this->assertIdenticalInputProps($cards[0], $card); } - function test_Users_AllCards_SortByCreationDate() + public function test_Users_AllCards_SortByCreationDate() { $john = $this->getNewJohn(); $this->getNewPayInCardDirect($john->Id); @@ -736,7 +723,7 @@ function test_Users_AllCards_SortByCreationDate() $this->assertTrue($cards[0]->CreationDate < $cards[1]->CreationDate); } - function test_Users_AllWallets() + public function test_Users_AllWallets() { $john = $this->getJohn(); $this->getJohnsWallet(); @@ -748,7 +735,7 @@ function test_Users_AllWallets() $this->assertInstanceOf('\MangoPay\Wallet', $wallets[0]); } - function test_Users_AllWallets_SortByCreationDate() + public function test_Users_AllWallets_SortByCreationDate() { $john = $this->getJohn(); $this->getJohnsWallet(); @@ -763,7 +750,7 @@ function test_Users_AllWallets_SortByCreationDate() $this->assertTrue($wallets[0]->CreationDate >= $wallets[1]->CreationDate); } - function test_Users_AllMandates() + public function test_Users_AllMandates() { $john = $this->getJohn(); $this->getJohnsMandate(); @@ -775,7 +762,7 @@ function test_Users_AllMandates() $this->assertInstanceOf('\MangoPay\Mandate', $mandates[0]); } - function test_Users_AllMandatesForBankAccount() + public function test_Users_AllMandatesForBankAccount() { $john = $this->getJohn(); $account = $this->getJohnsAccount(); @@ -788,7 +775,7 @@ function test_Users_AllMandatesForBankAccount() $this->assertInstanceOf('\MangoPay\Mandate', $mandates[0]); } - function test_Users_GetPreAuthorizations() + public function test_Users_GetPreAuthorizations() { $john = $this->getJohn(); @@ -798,10 +785,9 @@ function test_Users_GetPreAuthorizations() $this->assertInternalType('array', $preauthorizations); } - function test_395() + public function test_395() { - try - { + try { /* $this->_api->Config->ClientId = 'wd786'; $this->_api->Config->ClientPassword = 'my_api_key'; @@ -816,7 +802,7 @@ function test_395() $naturalUser->Nationality = "FR"; $naturalUser->CountryOfResidence = "ZA"; $naturalUserResult = $this->_api->Users->Create($naturalUser); // display result - \MangoPay\Libraries\Logs::Debug('CREATED NATURAL USER', $naturalUserResult); + Logs::Debug('CREATED NATURAL USER', $naturalUserResult); // CREATE LEGAL USER $legalUser = new \MangoPay\UserLegal(); $legalUser->Name = 'Name Legal Test'; @@ -829,19 +815,15 @@ function test_395() $legalUser->LegalRepresentativeCountryOfResidence = "ZA"; $legalUserResult = $this->_api->Users->Create($legalUser); // display result - \MangoPay\Libraries\Logs::Debug('CREATED LEGAL USER', $legalUserResult); + Logs::Debug('CREATED LEGAL USER', $legalUserResult); $this->assertEquals($naturalUserResult->Email, $naturalUser->Email); - } - catch (\MangoPay\Libraries\ResponseException $e) - { - \MangoPay\Libraries\Logs::Debug('MangoPay\ResponseException Code', $e->GetCode()); - \MangoPay\Libraries\Logs::Debug('Message', $e->GetMessage()); - \MangoPay\Libraries\Logs::Debug('Details', $e->GetErrorDetails()); - } - catch (\MangoPay\Libraries\Exception $e) - { - \MangoPay\Libraries\Logs::Debug('MangoPay\Exception Message', $e->GetMessage()); + } catch (ResponseException $e) { + Logs::Debug('MangoPay\ResponseException Code', $e->GetCode()); + Logs::Debug('Message', $e->GetMessage()); + Logs::Debug('Details', $e->GetErrorDetails()); + } catch (\MangoPay\Libraries\Exception $e) { + Logs::Debug('MangoPay\Exception Message', $e->GetMessage()); } } @@ -856,7 +838,7 @@ function test_get_user_block_status() }*/ - function test_get_user_block_regulatory() + public function test_get_user_block_regulatory() { $user = $this->getJohn(); $regulatory = $this->_api->Users->GetRegulatory($user->Id); diff --git a/tests/cases/WalletsTest.php b/tests/Cases/WalletsTest.php similarity index 91% rename from tests/cases/WalletsTest.php rename to tests/Cases/WalletsTest.php index a3f70523..4cdb097f 100644 --- a/tests/cases/WalletsTest.php +++ b/tests/Cases/WalletsTest.php @@ -2,14 +2,12 @@ namespace MangoPay\Tests\Cases; - /** * Tests basic methods for wallets */ class WalletsTest extends Base { - - function test_Wallets_Create() + public function test_Wallets_Create() { $john = $this->getJohn(); $wallet = $this->getJohnsWallet(); @@ -18,7 +16,7 @@ function test_Wallets_Create() $this->assertTrue(in_array($john->Id, $wallet->Owners)); } - function test_Wallets_Get() + public function test_Wallets_Get() { $john = $this->getJohn(); $wallet = $this->getJohnsWallet(); @@ -29,7 +27,7 @@ function test_Wallets_Get() $this->assertTrue(in_array($john->Id, $getWallet->Owners)); } - function test_Wallets_Save() + public function test_Wallets_Save() { $wallet = $this->getJohnsWallet(); $wallet->Description = 'New description to test'; @@ -40,7 +38,7 @@ function test_Wallets_Save() $this->assertSame('New description to test', $saveWallet->Description); } - function test_Wallets_Transactions() + public function test_Wallets_Transactions() { $john = $this->getJohn(); $wallet = $this->getJohnsWallet(); @@ -64,7 +62,7 @@ function test_Wallets_Transactions() // $this->assertIdenticalInputProps($transactions[0], $payIn); } - function test_Wallets_Transactions_SortByCreationDate() + public function test_Wallets_Transactions_SortByCreationDate() { $wallet = $this->getJohnsWallet(); // create 2 pay-in objects @@ -82,4 +80,4 @@ function test_Wallets_Transactions_SortByCreationDate() $this->assertTrue($transactions[0]->CreationDate >= $transactions[1]->CreationDate); } -} \ No newline at end of file +} diff --git a/tests/Mocks/MockStorageStrategy.php b/tests/Mocks/MockStorageStrategy.php new file mode 100644 index 00000000..2a6b7f2e --- /dev/null +++ b/tests/Mocks/MockStorageStrategy.php @@ -0,0 +1,33 @@ +[ALL] -$entry"; - } - closedir($handle); -} diff --git a/tests/mocks/mockStorageStrategy.php b/tests/mocks/mockStorageStrategy.php deleted file mode 100644 index 558d91e2..00000000 --- a/tests/mocks/mockStorageStrategy.php +++ /dev/null @@ -1,26 +0,0 @@ -collect('../cases', new TestCasesCollector()); - } -} - -class TestCasesCollector extends \SimpleCollector { - - protected function isHidden($filename) { - - // ignore base.php: with abstract test case class (throws Bad TestSuite [No runnable test cases] otherwise) - if ($filename == "base.php" || $filename == "index.php") - return true; - - return parent::isHidden($filename); - } -} -