From f6ef939beabacfb3453242dba48f300d2b847cab Mon Sep 17 00:00:00 2001 From: "Jan Hryniuk (PGS Software)" Date: Mon, 11 Feb 2019 14:37:19 +0100 Subject: [PATCH 1/3] Improved namespace structure. --- AmazonPay/Client.php | 11 ----------- AmazonPay/HttpCurl.php | 2 -- AmazonPay/IpnHandler.php | 9 +-------- AmazonPay/Regions.php | 1 + AmazonPay/ResponseParser.php | 3 +-- composer.json | 8 +++++++- phpunit.xml | 11 +++++++++++ tst/unit/ClientTest.php | 7 +++---- tst/unit/IpnHandlerTest.php | 4 ++-- tst/unit/Signature.php | 3 ++- 10 files changed, 28 insertions(+), 31 deletions(-) create mode 100644 phpunit.xml diff --git a/AmazonPay/Client.php b/AmazonPay/Client.php index 3fe372c..9a8910e 100644 --- a/AmazonPay/Client.php +++ b/AmazonPay/Client.php @@ -7,17 +7,6 @@ * returns Response Object */ -require_once 'ResponseParser.php'; -require_once 'HttpCurl.php'; -require_once 'ClientInterface.php'; -require_once 'Regions.php'; -if (!interface_exists('\Psr\Log\LoggerAwareInterface')) { - require_once(__DIR__.'/../Psr/Log/LoggerAwareInterface.php'); -} - -if (!interface_exists('\Psr\Log\LoggerInterface')) { - require_once(__DIR__.'/../Psr/Log/LoggerInterface.php'); -} use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; diff --git a/AmazonPay/HttpCurl.php b/AmazonPay/HttpCurl.php index df281b2..ed8a76b 100644 --- a/AmazonPay/HttpCurl.php +++ b/AmazonPay/HttpCurl.php @@ -5,8 +5,6 @@ * Handles Curl POST function for all requests */ -require_once 'HttpCurlInterface.php'; - class HttpCurl implements HttpCurlInterface { private $config = array(); diff --git a/AmazonPay/IpnHandler.php b/AmazonPay/IpnHandler.php index 3b4df8a..86f763d 100644 --- a/AmazonPay/IpnHandler.php +++ b/AmazonPay/IpnHandler.php @@ -1,4 +1,5 @@ + + + tst/unit + + + \ No newline at end of file diff --git a/tst/unit/ClientTest.php b/tst/unit/ClientTest.php index 9345b23..05f4600 100644 --- a/tst/unit/ClientTest.php +++ b/tst/unit/ClientTest.php @@ -1,9 +1,8 @@ Date: Tue, 12 Feb 2019 08:16:39 +0100 Subject: [PATCH 2/3] Changing name of test folder and adapt namespaces. --- composer.json | 2 +- phpunit.xml | 2 +- {tst/unit => test/Unit}/ClientTest.php | 13 +++++++------ {tst/unit => test/Unit}/IpnHandlerTest.php | 3 ++- {tst/unit => test/Unit}/Signature.php | 2 +- .../Unit}/config/sandbox_false_bool.json | 0 .../Unit}/config/sandbox_false_string.json | 0 {tst/unit => test/Unit}/config/sandbox_none.json | 0 .../Unit}/config/sandbox_true_bool.json | 0 .../Unit}/config/sandbox_true_string.json | 0 10 files changed, 12 insertions(+), 10 deletions(-) rename {tst/unit => test/Unit}/ClientTest.php (99%) rename {tst/unit => test/Unit}/IpnHandlerTest.php (99%) rename {tst/unit => test/Unit}/Signature.php (99%) rename {tst/unit => test/Unit}/config/sandbox_false_bool.json (100%) rename {tst/unit => test/Unit}/config/sandbox_false_string.json (100%) rename {tst/unit => test/Unit}/config/sandbox_none.json (100%) rename {tst/unit => test/Unit}/config/sandbox_true_bool.json (100%) rename {tst/unit => test/Unit}/config/sandbox_true_string.json (100%) diff --git a/composer.json b/composer.json index f893d3f..770693b 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ }, "autoload-dev": { "psr-4": { - "AmazonPayTst\\":"tst/unit" + "AmazonPayTest\\":"test/" } }, "require": { diff --git a/phpunit.xml b/phpunit.xml index c39c8c3..47aced5 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -5,7 +5,7 @@ checkForUnintentionallyCoveredCode="true"> - tst/unit + Test/Unit \ No newline at end of file diff --git a/tst/unit/ClientTest.php b/test/Unit/ClientTest.php similarity index 99% rename from tst/unit/ClientTest.php rename to test/Unit/ClientTest.php index 05f4600..7f24321 100644 --- a/tst/unit/ClientTest.php +++ b/test/Unit/ClientTest.php @@ -1,5 +1,6 @@ assertTrue((bool)$client->__get('sandbox')); @@ -107,22 +108,22 @@ public function testJsonFile() $this->assertEquals('1.0', $client->__get('application_version')); try { - $configParams = "tst/unit/config/sandbox_true_string.json"; + $configParams = "Test/Unit/config/sandbox_true_string.json"; $client = new Client($configParams); } catch (\Exception $expected) { $this->assertRegExp('/should be a boolean value/i', strval($expected)); } - $configParams = "tst/unit/config/sandbox_false_bool.json"; + $configParams = "Test/Unit/config/sandbox_false_bool.json"; $client = new Client($configParams); $this->assertFalse((bool)$client->__get('sandbox')); - $configParams = "tst/unit/config/sandbox_none.json"; + $configParams = "Test/Unit/config/sandbox_none.json"; $client = new Client($configParams); $this->assertFalse((bool)$client->__get('sandbox')); try { - $configParams = "tst/unit/config/sandbox_false_string.json"; + $configParams = "Test/unit/config/sandbox_false_string.json"; $client = new Client($configParams); } catch (\Exception $expected) { $this->assertRegExp('/should be a boolean value/i', strval($expected)); diff --git a/tst/unit/IpnHandlerTest.php b/test/Unit/IpnHandlerTest.php similarity index 99% rename from tst/unit/IpnHandlerTest.php rename to test/Unit/IpnHandlerTest.php index b4cd5d3..875ffe0 100644 --- a/tst/unit/IpnHandlerTest.php +++ b/test/Unit/IpnHandlerTest.php @@ -1,5 +1,6 @@ Date: Tue, 12 Feb 2019 13:39:04 +0100 Subject: [PATCH 3/3] Fixed typo --- test/Unit/ClientTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Unit/ClientTest.php b/test/Unit/ClientTest.php index 7f24321..14d3a71 100644 --- a/test/Unit/ClientTest.php +++ b/test/Unit/ClientTest.php @@ -108,22 +108,22 @@ public function testJsonFile() $this->assertEquals('1.0', $client->__get('application_version')); try { - $configParams = "Test/Unit/config/sandbox_true_string.json"; + $configParams = "test/Unit/config/sandbox_true_string.json"; $client = new Client($configParams); } catch (\Exception $expected) { $this->assertRegExp('/should be a boolean value/i', strval($expected)); } - $configParams = "Test/Unit/config/sandbox_false_bool.json"; + $configParams = "test/Unit/config/sandbox_false_bool.json"; $client = new Client($configParams); $this->assertFalse((bool)$client->__get('sandbox')); - $configParams = "Test/Unit/config/sandbox_none.json"; + $configParams = "test/Unit/config/sandbox_none.json"; $client = new Client($configParams); $this->assertFalse((bool)$client->__get('sandbox')); try { - $configParams = "Test/unit/config/sandbox_false_string.json"; + $configParams = "test/unit/config/sandbox_false_string.json"; $client = new Client($configParams); } catch (\Exception $expected) { $this->assertRegExp('/should be a boolean value/i', strval($expected));