From ec6ecd56bcc5bbd079ee205e3ca754a874643c79 Mon Sep 17 00:00:00 2001 From: attilak Date: Thu, 11 Oct 2018 11:28:53 +0200 Subject: [PATCH 1/4] Add new setting to the config/tests.ini where it can be set if you are working on the api library standalone on local When this setting is set true then the missing defaults that can cause issues are being set --- tests/TestCase.php | 56 ++++++++++++++++++++++++++++++++++--------- tests/config/test.ini | 2 ++ 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index ccfc194d6..84a2ab19b 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -9,15 +9,33 @@ class TestCase extends \PHPUnit_Framework_TestCase protected $_skinCode; protected $_hmacSignature; + /** + * Settings parsed from the config/tests.ini file + * + * @var array + */ + protected $settings; + public function __construct() { - $this->_merchantAccount = $this->getMerchantAccount(); $this->_skinCode = $this->getSkinCode(); $this->_hmacSignature = $this->getHmacSignature(); + $this->settings = $this->_loadConfigIni(); + $this->setDefaultsDuringDevelopment(); } + /** + * During development of the standalone php api library this function sets the necessary defaults which would + * otherwise set by the merchant + */ + private function setDefaultsDuringDevelopment() + { + if ($this->isStandaloneLibraryDevelopmentInProgress()) { + date_default_timezone_set('Europe/Amsterdam'); + } + } /** * Mock client @@ -27,7 +45,7 @@ public function __construct() protected function createClient() { // load settings from .ini file - $settings = $this->_loadConfigIni(); + $settings = $this->settings; // validate username, password and MERCHANTAccount @@ -64,7 +82,7 @@ protected function createClient() protected function createPayoutClient() { // load settings from .ini file - $settings = $this->_loadConfigIni(); + $settings = $this->settings; // validate username, password and MERCHANTAccount @@ -101,7 +119,7 @@ protected function createPayoutClient() protected function createReviewPayoutClient() { // load settings from .ini file - $settings = $this->_loadConfigIni(); + $settings = $this->settings; // validate username, password and MERCHANTAccount @@ -133,7 +151,7 @@ protected function createReviewPayoutClient() protected function createTerminalCloudAPIClient() { // load settings from .ini file - $settings = $this->_loadConfigIni(); + $settings = $this->settings; if(!isset($settings['x-api-key']) || !isset($settings['POIID']) || $settings['x-api-key'] == 'YOUR X-API KEY' || $settings['POIID'] == 'UNIQUETERMINALID'){ $this->_skipTest("Skipped the test. Configure your x-api-key and POIID in the config"); @@ -153,7 +171,7 @@ protected function createClientWithMerchantAccount() $client = $this->createClient(); // load settings from .ini file - $settings = $this->_loadConfigIni(); + $settings = $this->settings; if(!isset($settings['merchantAccount']) || $settings['merchantAccount'] == 'YOUR MERCHANTACCOUNT') { $this->_skipTest("Skipped the test. Configure your MerchantAccount in the config"); @@ -166,7 +184,7 @@ protected function createClientWithMerchantAccount() protected function getMerchantAccount() { - $settings = $this->_loadConfigIni(); + $settings = $this->settings; if(!isset($settings['merchantAccount']) || $settings['merchantAccount'] == 'YOUR MERCHANTACCOUNT') { return null; @@ -177,7 +195,7 @@ protected function getMerchantAccount() protected function getSkinCode() { - $settings = $this->_loadConfigIni(); + $settings = $this->settings; if(!isset($settings['skinCode']) || $settings['skinCode'] == 'YOUR SKIN CODE') { return null; @@ -188,7 +206,7 @@ protected function getSkinCode() protected function getHmacSignature() { - $settings = $this->_loadConfigIni(); + $settings = $this->settings; if(!isset($settings['hmacSignature'])|| $settings['hmacSignature'] == 'YOUR HMAC SIGNATURE') { return null; @@ -199,7 +217,7 @@ protected function getHmacSignature() protected function getPOIID() { - $settings = $this->_loadConfigIni(); + $settings = $this->settings; if(!isset($settings['POIID']) || $settings['POIID'] == 'MODEL-SERIALNUMBER') { return null; @@ -225,6 +243,23 @@ protected function _needSkinCode() { } } + /** + * In case of developing the api library alone zou can set the standalone_library_development_in_progress property + * true to set up the default missing values for local development which otherwise would set by the merchant + * + * @return bool + */ + protected function isStandaloneLibraryDevelopmentInProgress() + { + $settings = $this->settings; + + if(!isset($settings['standalone_library_development_in_progress'])) { + return false; + } + + return $settings['standalone_library_development_in_progress']; + } + public function validateApiPermission($e) { // it is possible you do not have permission to use full API then switch over to CSE @@ -240,5 +275,4 @@ public function validateApiPermission($e) $this->markTestSkipped("Skipped the test. You do not have the permission to do a recurring transaction."); } } - } diff --git a/tests/config/test.ini b/tests/config/test.ini index 2c550e032..65cbbf057 100644 --- a/tests/config/test.ini +++ b/tests/config/test.ini @@ -11,3 +11,5 @@ storePayoutUsername = YOUR STORE PAYOUT USERNAME storePayoutPassword = "YOUR STORE PAYOUT PASSWORD" reviewPayoutUsername = YOUR REVIEW PAYOUT USERNAME reviewPayoutPassword = "YOUR REVIEW PAYOUT PASSWORD" + +standalone_library_development_in_progress = false \ No newline at end of file From 464c98f438c62e6ed3339d13fa40054286df5f36 Mon Sep 17 00:00:00 2001 From: attilak Date: Fri, 12 Oct 2018 16:13:32 +0200 Subject: [PATCH 2/4] some typo and php doc --- src/Adyen/Client.php | 2 +- tests/TestCase.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Adyen/Client.php b/src/Adyen/Client.php index 4075af53a..caebf21e3 100644 --- a/src/Adyen/Client.php +++ b/src/Adyen/Client.php @@ -93,7 +93,7 @@ public function setXApiKey($xApiKey) * Set environment to connect to test or live platform of Adyen * For live please specify the unique identifier. * - * @param $environment test + * @param $environment * @param null $liveEndpointUrlPrefix Provide the unique live url prefix from the "API URLs and Response" menu in the Adyen Customer Area * @throws AdyenException */ diff --git a/tests/TestCase.php b/tests/TestCase.php index 84a2ab19b..7929b705d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -10,7 +10,7 @@ class TestCase extends \PHPUnit_Framework_TestCase protected $_hmacSignature; /** - * Settings parsed from the config/tests.ini file + * Settings parsed from the config/test.ini file * * @var array */ @@ -226,6 +226,11 @@ protected function getPOIID() return $settings['POIID']; } + /** + * Loads the settings into and array from the config/test.ini file + * + * @return array|bool + */ protected function _loadConfigIni() { return parse_ini_file(__DIR__ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'test.ini', true); @@ -244,7 +249,7 @@ protected function _needSkinCode() { } /** - * In case of developing the api library alone zou can set the standalone_library_development_in_progress property + * In case of developing the api library alone you can set the standalone_library_development_in_progress property * true to set up the default missing values for local development which otherwise would set by the merchant * * @return bool From 8a2f71118fb3a73580f7ceb46922230db3c5f68c Mon Sep 17 00:00:00 2001 From: attilak Date: Tue, 16 Oct 2018 08:13:33 +0200 Subject: [PATCH 3/4] rename variables and check date.timezone before set to the default value --- tests/TestCase.php | 15 +++++++++------ tests/config/test.ini | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 7929b705d..67dc516c7 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -32,8 +32,11 @@ public function __construct() */ private function setDefaultsDuringDevelopment() { - if ($this->isStandaloneLibraryDevelopmentInProgress()) { - date_default_timezone_set('Europe/Amsterdam'); + if ($this->isDev()) { + // Check default timezone if not set use a default value for that + if (!ini_get('date.timezone')) { + ini_set('date.timezone', 'Europe/Amsterdam'); + } } } @@ -249,20 +252,20 @@ protected function _needSkinCode() { } /** - * In case of developing the api library alone you can set the standalone_library_development_in_progress property + * In case of developing the api library alone you can set the dev property * true to set up the default missing values for local development which otherwise would set by the merchant * * @return bool */ - protected function isStandaloneLibraryDevelopmentInProgress() + protected function isDev() { $settings = $this->settings; - if(!isset($settings['standalone_library_development_in_progress'])) { + if(!isset($settings['dev'])) { return false; } - return $settings['standalone_library_development_in_progress']; + return $settings['dev']; } public function validateApiPermission($e) diff --git a/tests/config/test.ini b/tests/config/test.ini index 65cbbf057..ca5280099 100644 --- a/tests/config/test.ini +++ b/tests/config/test.ini @@ -12,4 +12,4 @@ storePayoutPassword = "YOUR STORE PAYOUT PASSWORD" reviewPayoutUsername = YOUR REVIEW PAYOUT USERNAME reviewPayoutPassword = "YOUR REVIEW PAYOUT PASSWORD" -standalone_library_development_in_progress = false \ No newline at end of file +dev = false \ No newline at end of file From 1687bf101942c69fa987c091d451bd21aab3c5a6 Mon Sep 17 00:00:00 2001 From: attilak Date: Thu, 18 Oct 2018 14:51:23 +0200 Subject: [PATCH 4/4] Remove isDev flag to follow a more simple approach --- tests/TestCase.php | 25 +++---------------------- tests/config/test.ini | 4 +--- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 67dc516c7..8f03db7ba 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -32,11 +32,9 @@ public function __construct() */ private function setDefaultsDuringDevelopment() { - if ($this->isDev()) { - // Check default timezone if not set use a default value for that - if (!ini_get('date.timezone')) { - ini_set('date.timezone', 'Europe/Amsterdam'); - } + // Check default timezone if not set use a default value for that + if (!ini_get('date.timezone')) { + ini_set('date.timezone', 'Europe/Amsterdam'); } } @@ -250,23 +248,6 @@ protected function _needSkinCode() { $this->_skipTest("Skipped the test. Configure your SkinCode in the config"); } } - - /** - * In case of developing the api library alone you can set the dev property - * true to set up the default missing values for local development which otherwise would set by the merchant - * - * @return bool - */ - protected function isDev() - { - $settings = $this->settings; - - if(!isset($settings['dev'])) { - return false; - } - - return $settings['dev']; - } public function validateApiPermission($e) { diff --git a/tests/config/test.ini b/tests/config/test.ini index ca5280099..b79a75dbe 100644 --- a/tests/config/test.ini +++ b/tests/config/test.ini @@ -10,6 +10,4 @@ POIID = UNIQUETERMINALID storePayoutUsername = YOUR STORE PAYOUT USERNAME storePayoutPassword = "YOUR STORE PAYOUT PASSWORD" reviewPayoutUsername = YOUR REVIEW PAYOUT USERNAME -reviewPayoutPassword = "YOUR REVIEW PAYOUT PASSWORD" - -dev = false \ No newline at end of file +reviewPayoutPassword = "YOUR REVIEW PAYOUT PASSWORD" \ No newline at end of file