-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
390 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
checks: | ||
php: | ||
code_rating: true | ||
duplication: true | ||
tools: | ||
php_code_coverage: | ||
enabled: true | ||
external_code_coverage: | ||
timeout: 600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" syntaxCheck="false" bootstrap="tests/_bootstrap.php"> | ||
<testsuites> | ||
<testsuite name="Unit Test Suite"> | ||
<directory>./tests/unit/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist addUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">./src/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
/* | ||
* PayPal driver for Omnipay PHP payment library | ||
* | ||
* @link https://github.com/hiqdev/omnipay-paypal | ||
* @package omnipay-paypal | ||
* @license MIT | ||
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) | ||
*/ | ||
|
||
error_reporting(E_ALL & ~E_NOTICE); | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
/* | ||
* OKPAY driver for Omnipay PHP payment library | ||
* | ||
* @link https://github.com/hiqdev/omnipay-okpay | ||
* @package omnipay-okpay | ||
* @license MIT | ||
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) | ||
*/ | ||
|
||
namespace Omnipay\OKPAY; | ||
|
||
use Omnipay\Tests\GatewayTestCase; | ||
|
||
class GatewayTest extends GatewayTestCase | ||
{ | ||
public $gateway; | ||
|
||
private $purse = '[email protected]'; | ||
// private $secret = 'sDf#$Sdf#$%'; | ||
private $testMode = true; | ||
private $transactionId = 'sadf2345asf'; | ||
private $description = 'Test completePurchase description'; | ||
private $currency = 'USD'; | ||
private $amount = '12.46'; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest()); | ||
$this->gateway->setPurse($this->purse); | ||
$this->gateway->setTestMode($this->testMode); | ||
} | ||
|
||
public function testGateway() | ||
{ | ||
$this->assertSame($this->purse, $this->gateway->getPurse()); | ||
$this->assertSame($this->testMode, $this->gateway->getTestMode()); | ||
} | ||
|
||
public function testCompletePurchase() | ||
{ | ||
$request = $this->gateway->completePurchase([ | ||
'transactionId' => $this->transactionId, | ||
]); | ||
|
||
$this->assertSame($this->purse, $request->getPurse()); | ||
$this->assertSame($this->testMode, $request->getTestMode()); | ||
$this->assertSame($this->transactionId, $request->getTransactionId()); | ||
} | ||
|
||
public function testPurchase() | ||
{ | ||
$request = $this->gateway->purchase([ | ||
'transactionId' => $this->transactionId, | ||
'description' => $this->description, | ||
'currency' => $this->currency, | ||
'amount' => $this->amount, | ||
]); | ||
|
||
$this->assertSame($this->transactionId, $request->getTransactionId()); | ||
$this->assertSame($this->description, $request->getDescription()); | ||
$this->assertSame($this->currency, $request->getCurrency()); | ||
$this->assertSame($this->amount, $request->getAmount()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
|
||
/* | ||
* OKPAY driver for Omnipay PHP payment library | ||
* | ||
* @link https://github.com/hiqdev/omnipay-okpay | ||
* @package omnipay-okpay | ||
* @license MIT | ||
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) | ||
*/ | ||
|
||
namespace Omnipay\OKPAY\Message; | ||
|
||
use Omnipay\Tests\TestCase; | ||
use Symfony\Component\HttpFoundation\Request as HttpRequest; | ||
|
||
class CompletePurchaseRequestTest extends TestCase | ||
{ | ||
private $request; | ||
|
||
private $purse = 'OK426375940'; | ||
private $description = 'evo.ru-tld.ru: deposit valenp'; | ||
private $transactionId = 2705801; | ||
private $amount = 68.71; | ||
private $currency = 'USD'; | ||
private $timestamp = '2014-03-22 19:54:58'; | ||
private $testMode = true; | ||
|
||
private $data = [ | ||
'ok_charset' => 'utf-8', | ||
'ok_receiver' => 'OK426375940', | ||
'ok_receiver_id' => '532844008', | ||
'ok_receiver_wallet' => 'OK426375940', | ||
'ok_receiver_email' => '[email protected]', | ||
'ok_txn_id' => 2705801, | ||
'ok_txn_kind' => 'payment_link', | ||
'ok_txn_payment_type' => 'instant', | ||
'ok_txn_payment_method' => 'OKB', | ||
'ok_txn_gross' => '68.71', | ||
'ok_txn_amount' => 68.71, | ||
'ok_txn_net' => '68.71', | ||
'ok_txn_fee' => '0.00', | ||
'ok_txn_currency' => 'USD', | ||
'ok_txn_datetime' => '2014-03-22 19:54:58', | ||
'ok_txn_status' => 'completed', | ||
'ok_invoice' => '', | ||
'ok_payer_status' => 'verified', | ||
'ok_payer_id' => '914126735', | ||
'ok_payer_reputation' => '0', | ||
'ok_payer_first_name' => 'Valentin', | ||
'ok_payer_last_name' => 'Perevalov', | ||
'ok_payer_email' => '[email protected]', | ||
'ok_payer_phone' => '7-9080858303', | ||
'ok_payer_country' => 'Russia', | ||
'ok_payer_city' => 'Chelyabinsk', | ||
'ok_payer_country_code' => 'RU', | ||
'ok_payer_state' => 'Chelyabinskaya obl.', | ||
'ok_payer_address_status' => 'confirmed', | ||
'ok_payer_street' => 'Truda 24-136', | ||
'ok_payer_zip' => '454006', | ||
'ok_payer_address_name' => 'Postal', | ||
'ok_items_count' => '1', | ||
'ok_item_1_name' => 'evo.ru-tld.ru: deposit valenp', | ||
'ok_item_1_type' => 'digital', | ||
'ok_item_1_quantity' => '1', | ||
'ok_item_1_gross' => '68.71', | ||
'ok_item_1_price' => '68.71', | ||
'ok_ipn_id' => '2011795', | ||
]; | ||
|
||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$httpRequest = new HttpRequest([], $this->data); | ||
|
||
$this->request = new CompletePurchaseRequest($this->getHttpClient(), $httpRequest); | ||
$this->request->initialize([ | ||
'purse' => $this->purse, | ||
'secret' => $this->secret, | ||
'testMode' => $this->testMode, | ||
]); | ||
} | ||
|
||
public function testGetData() | ||
{ | ||
$data = $this->request->getData(); | ||
|
||
$this->assertSame($this->description, $data['ok_item_1_name']); | ||
$this->assertSame($this->transactionId, $data['ok_txn_id']); | ||
$this->assertSame($this->amount, $data['ok_txn_amount']); | ||
$this->assertSame($this->timestamp, $data['ok_txn_datetime']); | ||
$this->assertSame($this->purse, $data['ok_receiver']); | ||
} | ||
|
||
public function testSendData() | ||
{ | ||
// $data = $this->request->getData(); | ||
$response = $this->request->sendData($this->data); | ||
$this->assertInstanceOf('Omnipay\OKPAY\Message\CompletePurchaseResponse', $response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/* | ||
* OKPAY driver for Omnipay PHP payment library | ||
* | ||
* @link https://github.com/hiqdev/omnipay-okpay | ||
* @package omnipay-okpay | ||
* @license MIT | ||
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) | ||
*/ | ||
|
||
namespace Omnipay\OKPAY\Message; | ||
|
||
use Omnipay\Tests\TestCase; | ||
|
||
class CompletePurchaseResponseTest extends TestCase | ||
{ | ||
private $request; | ||
|
||
private $purse = '[email protected]'; | ||
private $description = 'sDf#$Sdf#$%'; | ||
private $transactionId = 1234567890; | ||
private $amount = 8.69; | ||
private $currency = 'USD'; | ||
private $testMode = true; | ||
private $status = 'completed'; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->request = new CompletePurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); | ||
$this->request->initialize([ | ||
'purse' => $this->purse, | ||
'secret' => $this->secret, | ||
'testMode' => $this->testMode, | ||
]); | ||
} | ||
|
||
public function testSuccess() | ||
{ | ||
$response = new CompletePurchaseResponse($this->request, [ | ||
'ok_item_1_name' => $this->description, | ||
'ok_receiver' => $this->purse, | ||
'ok_txn_amount' => $this->amount, | ||
'ok_txn_datetime' => $this->timestamp, | ||
'ok_txn_id' => $this->transactionId, | ||
'ok_txn_status' => $this->status, | ||
'ok_txn_currency' => $this->currency, | ||
]); | ||
|
||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertNull($response->getMessage()); | ||
$this->assertNull($response->getCode()); | ||
$this->assertSame($this->amount, $response->getAmount()); | ||
$this->assertSame($this->description, $response->getDescription()); | ||
$this->assertSame($this->purse, $response->getPurse()); | ||
$this->assertSame($this->currency, $response->getCurrency()); | ||
$this->assertSame($this->transactionId, $response->getTransactionId()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/* | ||
* OKPAY driver for Omnipay PHP payment library | ||
* | ||
* @link https://github.com/hiqdev/omnipay-okpay | ||
* @package omnipay-okpay | ||
* @license MIT | ||
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) | ||
*/ | ||
|
||
namespace Omnipay\OKPAY\Message; | ||
|
||
use Omnipay\Tests\TestCase; | ||
|
||
class PurchaseRequestTest extends TestCase | ||
{ | ||
private $request; | ||
|
||
private $purse = '[email protected]'; | ||
private $secret = 'sDf#$Sdf#$%'; | ||
private $description = 'Test Transaction long description'; | ||
private $transactionId = '12345ASD67890sd'; | ||
private $amount = '14.65'; | ||
private $currency = 'USD'; | ||
private $testMode = true; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); | ||
$this->request->initialize([ | ||
'purse' => $this->purse, | ||
'secret' => $this->secret, | ||
'description' => $this->description, | ||
'transactionId' => $this->transactionId, | ||
'amount' => $this->amount, | ||
'currency' => $this->currency, | ||
'testMode' => $this->testMode, | ||
]); | ||
} | ||
|
||
public function testGetData() | ||
{ | ||
$data = $this->request->getData(); | ||
|
||
$this->assertSame($this->purse, $data['ok_receiver']); | ||
$this->assertSame($this->description, $data['ok_item_1_name']); | ||
$this->assertSame($this->transactionId, $data['ok_invoice']); | ||
$this->assertSame($this->amount, $data['ok_item_1_price']); | ||
$this->assertSame($this->currency, $data['ok_currency']); | ||
} | ||
|
||
public function testSendData() | ||
{ | ||
$data = $this->request->getData(); | ||
$response = $this->request->sendData($data); | ||
$this->assertSame('Omnipay\OKPAY\Message\PurchaseResponse', get_class($response)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/* | ||
* OKPAY driver for Omnipay PHP payment library | ||
* | ||
* @link https://github.com/hiqdev/omnipay-okpay | ||
* @package omnipay-okpay | ||
* @license MIT | ||
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) | ||
*/ | ||
|
||
namespace Omnipay\OKPAY\Message; | ||
|
||
use Omnipay\Tests\TestCase; | ||
|
||
class PurchaseResponseTest extends TestCase | ||
{ | ||
private $request; | ||
|
||
private $purse = 'ec12345'; | ||
private $secret = '12()&*&+_)?><'; | ||
private $description = 'Test Transaction long description'; | ||
private $transactionId = '12345ASD67890sd'; | ||
private $amount = '14.65'; | ||
private $currency = 'USD'; | ||
private $testMode = true; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); | ||
$this->request->initialize([ | ||
'purse' => $this->purse, | ||
'secret' => $this->secret, | ||
'description' => $this->description, | ||
'transactionId' => $this->transactionId, | ||
'amount' => $this->amount, | ||
'currency' => $this->currency, | ||
'testMode' => $this->testMode, | ||
]); | ||
} | ||
|
||
public function testSuccess() | ||
{ | ||
$response = $this->request->send(); | ||
|
||
$this->assertFalse($response->isSuccessful()); | ||
$this->assertTrue($response->isRedirect()); | ||
$this->assertNull($response->getCode()); | ||
$this->assertSame('POST', $response->getRedirectMethod()); | ||
// $this->assertStringStartsWith('https://okpay.cc/account/mpay', $response->getRedirectUrl()); | ||
$this->assertSame([ | ||
'ok_receiver' => $this->purse, | ||
'ok_item_1_name' => $this->description, | ||
'ok_currency' => $this->currency, | ||
'ok_item_1_price' => $this->amount, | ||
'ok_invoice' => $this->transactionId, | ||
], $response->getRedirectData()); | ||
} | ||
} |