Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved namespace structure. #73

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions AmazonPay/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions AmazonPay/HttpCurl.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* Handles Curl POST function for all requests
*/

require_once 'HttpCurlInterface.php';

class HttpCurl implements HttpCurlInterface
{
private $config = array();
Expand Down
9 changes: 1 addition & 8 deletions AmazonPay/IpnHandler.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
<?php

namespace AmazonPay;

/* Class IPN_Handler
* Takes headers and body of the IPN message as input in the constructor
* verifies that the IPN is from the right resource and has the valid data
*/

require_once 'HttpCurl.php';
require_once 'IpnHandlerInterface.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;

Expand Down
1 change: 1 addition & 0 deletions AmazonPay/Regions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace AmazonPay;

/* Class Regions
Expand Down
3 changes: 1 addition & 2 deletions AmazonPay/ResponseParser.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php

namespace AmazonPay;

/* ResponseParser
* Methods provided to convert the Response from the POST to XML, Array or JSON
*/

require_once 'ResponseInterface.php';

class ResponseParser implements ResponseInterface
{
public $response = null;
Expand Down
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@
],
"autoload": {
"psr-4": {
"AmazonPay\\": "AmazonPay/"
"AmazonPay\\": "AmazonPay/",
"Psr\\": "Psr/"
}
},
"autoload-dev": {
"psr-4": {
"AmazonPayTest\\":"test/"
}
},
"require": {
Expand Down
11 changes: 11 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/3.7/phpunit.xsd"
verbose="true"
checkForUnintentionallyCoveredCode="true">
<testsuites>
<testsuite name="Test Amazon Pay Sdk PHP">
<directory>Test/Unit</directory>
</testsuite>
</testsuites>
</phpunit>
18 changes: 9 additions & 9 deletions tst/unit/ClientTest.php → test/Unit/ClientTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
namespace AmazonPay;

require_once 'AmazonPay/Client.php';
require_once 'AmazonPay/ResponseParser.php';
require_once 'Signature.php';
namespace AmazonPayTest\Unit;

use AmazonPay\Client;
use AmazonPay\ResponseParser;

class ClientTest extends \PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -94,7 +94,7 @@ public function testConfigArray()

public function testJsonFile()
{
$configParams = "tst/unit/config/sandbox_true_bool.json";
$configParams = "test/Unit/config/sandbox_true_bool.json";
$client = new Client($configParams);

$this->assertTrue((bool)$client->__get('sandbox'));
Expand All @@ -108,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));
Expand Down
5 changes: 3 additions & 2 deletions tst/unit/IpnHandlerTest.php → test/Unit/IpnHandlerTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
namespace AmazonPay;

require_once 'AmazonPay/IpnHandler.php';
namespace AmazonPayTest\Unit;

use AmazonPay\IpnHandler;

class IpnHandlertest extends \PHPUnit_Framework_TestCase
{
Expand Down
3 changes: 2 additions & 1 deletion tst/unit/Signature.php → test/Unit/Signature.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace AmazonPay;

namespace AmazonPayTest\Unit;

class Signature
{
Expand Down
File renamed without changes.