-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests nearly done. Test namespace autoload reverted to allow test cla…
…sses inheritance.
- Loading branch information
Showing
18 changed files
with
370 additions
and
41 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
build | ||
.idea | ||
composer.lock | ||
vendor |
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
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 |
---|---|---|
@@ -1,39 +1,170 @@ | ||
<?php | ||
|
||
namespace Omnipay\Creditcall; | ||
namespace Omnipay\Creditcall\Test; | ||
|
||
use Omnipay\Creditcall\Gateway; | ||
use Omnipay\Tests\GatewayTestCase; | ||
use Omnipay\Common\CreditCard; | ||
|
||
class GatewayTest extends GatewayTestCase | ||
{ | ||
|
||
/** | ||
* @var Gateway | ||
*/ | ||
protected $gateway; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $purchaseOptions; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $captureOptions; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest()); | ||
|
||
$this->options = array( | ||
'amount' => '10.00', | ||
'card' => new CreditCard(array( | ||
'firstName' => 'Example', | ||
'lastName' => 'User', | ||
'number' => '4111111111111111', | ||
'expiryMonth' => '12', | ||
'expiryYear' => '2016', | ||
'cvv' => '123', | ||
)), | ||
$this->gateway->setTerminalId('923632313'); | ||
$this->gateway->setTransactionKey('23ASDas3d323ASs6'); | ||
|
||
$this->purchaseOptions = array( | ||
'amount' => '10.00', | ||
'transactionId' => '123', | ||
'card' => $this->getValidCard(), | ||
); | ||
$this->captureOptions = array( | ||
'amount' => '10.00', | ||
'transactionReference' => '6f3b812a-dafa-e311-983c-00505692354f', | ||
); | ||
} | ||
|
||
public function testAuthorize() | ||
public function testGatewaySettersGetters() | ||
{ | ||
$this->assertSame('923632313', $this->gateway->getTerminalId()); | ||
$this->assertSame('23ASDas3d323ASs6', $this->gateway->getTransactionKey()); | ||
$this->gateway->setVerifyCvv(false); | ||
$this->gateway->setVerifyAddress(true); | ||
$this->gateway->setVerifyZip(true); | ||
$this->assertFalse($this->gateway->getVerifyCvv()); | ||
$this->assertTrue($this->gateway->getVerifyAddress()); | ||
$this->assertTrue($this->gateway->getVerifyZip()); | ||
} | ||
|
||
public function testAuthorizeSuccess() | ||
{ | ||
$this->setMockHttpResponse('AuthorizeSuccess.txt'); | ||
$response = $this->gateway->authorize($this->purchaseOptions)->send(); | ||
|
||
$response = $this->gateway->authorize($this->options)->send(); | ||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertFalse($response->isRedirect()); | ||
$this->assertNull($response->getMessage()); | ||
$this->assertSame('6f3b812a-dafa-e311-983c-00505692354f', $response->getTransactionReference()); | ||
$this->assertSame('a4f483ca-55fc-e311-8ca6-001422187e37', $response->getCardReference()); | ||
$this->assertSame('qo3tCvArxWUxsCONcIWGyHUhXKs=', $response->getCardHash()); | ||
} | ||
|
||
public function testAuthorizeFailure() | ||
{ | ||
$this->setMockHttpResponse('AuthorizeFailure.txt'); | ||
$response = $this->gateway->authorize($this->purchaseOptions)->send(); | ||
|
||
$this->assertFalse($response->isSuccessful()); | ||
$this->assertFalse($response->isRedirect()); | ||
$this->assertSame('CvvNotMatched', $response->getMessage()); | ||
} | ||
|
||
public function testPurchaseSuccess() | ||
{ | ||
$this->setMockHttpResponse('AuthorizeSuccess.txt'); | ||
$response = $this->gateway->purchase($this->purchaseOptions)->send(); | ||
|
||
$requestData = $response->getRequest()->getData(); | ||
$this->assertSame('true', (string)$requestData->TransactionDetails->MessageType->attributes()->autoconfirm); | ||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertEquals('1234', $response->getTransactionReference()); | ||
$this->assertFalse($response->isRedirect()); | ||
$this->assertNull($response->getMessage()); | ||
$this->assertSame('6f3b812a-dafa-e311-983c-00505692354f', $response->getTransactionReference()); | ||
$this->assertSame('a4f483ca-55fc-e311-8ca6-001422187e37', $response->getCardReference()); | ||
$this->assertSame('qo3tCvArxWUxsCONcIWGyHUhXKs=', $response->getCardHash()); | ||
} | ||
|
||
public function testPurchaseFailure() | ||
{ | ||
$this->setMockHttpResponse('AuthorizeFailure.txt'); | ||
$response = $this->gateway->purchase($this->purchaseOptions)->send(); | ||
|
||
$requestData = $response->getRequest()->getData(); | ||
$this->assertSame('true', (string)$requestData->TransactionDetails->MessageType->attributes()->autoconfirm); | ||
$this->assertFalse($response->isSuccessful()); | ||
$this->assertFalse($response->isRedirect()); | ||
$this->assertSame('CvvNotMatched', $response->getMessage()); | ||
} | ||
|
||
public function testCaptureSuccess() | ||
{ | ||
$this->setMockHttpResponse('CaptureSuccess.txt'); | ||
$response = $this->gateway->capture($this->captureOptions)->send(); | ||
|
||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertFalse($response->isRedirect()); | ||
$this->assertNull($response->getMessage()); | ||
$this->assertNotNull($response->getTransactionReference()); | ||
} | ||
|
||
public function testCaptureFailure() | ||
{ | ||
$this->setMockHttpResponse('CaptureFailure.txt'); | ||
$response = $this->gateway->capture($this->captureOptions)->send(); | ||
|
||
$this->assertFalse($response->isSuccessful()); | ||
$this->assertFalse($response->isRedirect()); | ||
$this->assertSame('CardEaseReferenceInvalid', $response->getMessage()); | ||
} | ||
|
||
public function testRefundSuccess() | ||
{ | ||
$this->setMockHttpResponse('RefundSuccess.txt'); | ||
$response = $this->gateway->refund($this->captureOptions)->send(); | ||
|
||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertFalse($response->isRedirect()); | ||
$this->assertNull($response->getMessage()); | ||
$this->assertNotNull($response->getTransactionReference()); | ||
} | ||
|
||
public function testRefundFailure() | ||
{ | ||
$this->setMockHttpResponse('RefundFailure.txt'); | ||
$response = $this->gateway->refund($this->captureOptions)->send(); | ||
|
||
$this->assertFalse($response->isSuccessful()); | ||
$this->assertFalse($response->isRedirect()); | ||
$this->assertSame('TransactionAlreadyVoided', $response->getMessage()); | ||
} | ||
|
||
public function testVoidSuccess() | ||
{ | ||
$this->setMockHttpResponse('VoidSuccess.txt'); | ||
$response = $this->gateway->void($this->captureOptions)->send(); | ||
|
||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertFalse($response->isRedirect()); | ||
$this->assertNull($response->getMessage()); | ||
$this->assertNotNull($response->getTransactionReference()); | ||
} | ||
|
||
public function testVoidFailure() | ||
{ | ||
$this->setMockHttpResponse('VoidFailure.txt'); | ||
$response = $this->gateway->void($this->captureOptions)->send(); | ||
|
||
$this->assertFalse($response->isSuccessful()); | ||
$this->assertFalse($response->isRedirect()); | ||
$this->assertSame('TransactionAlreadyVoided', $response->getMessage()); | ||
} | ||
} |
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,43 @@ | ||
<?php | ||
|
||
namespace Omnipay\Creditcall\Test\Message; | ||
|
||
use Omnipay\Creditcall\Message\AuthorizeRequest; | ||
|
||
class AuthorizeCardReferenceRequestTest extends AuthorizeRequestTest | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->request = new AuthorizeRequest($this->getHttpClient(), $this->getHttpRequest()); | ||
$this->request->initialize(array_merge($this->getOptions(), array( | ||
'card' => null, | ||
'cardReference' => 'a4f483ca-55fc-e311-8ca6-001422187e37', | ||
'cardHash' => 'qo3tCvArxWUxsCONcIWGyHUhXKs=', | ||
))); | ||
} | ||
|
||
public function testTransactionData() | ||
{ | ||
$data = $this->request->getData(); | ||
|
||
$this->assertSame('123', (string)$data->TransactionDetails->Reference); | ||
$this->assertSame('12.00', (string)$data->TransactionDetails->Amount); | ||
$this->assertSame('major', (string)$data->TransactionDetails->Amount->attributes()->unit); | ||
$this->assertSame('826', (string)$data->TransactionDetails->CurrencyCode); | ||
|
||
$this->assertNull($this->request->getCard()); | ||
|
||
$manual = $data->CardDetails->Manual; | ||
$this->assertSame('cnp', (string)$manual->attributes()->type); | ||
$this->assertSame('a4f483ca-55fc-e311-8ca6-001422187e37', (string)$manual->CardReference); | ||
$this->assertSame('qo3tCvArxWUxsCONcIWGyHUhXKs=', (string)$manual->CardHash); | ||
$this->assertSame('826', (string)$data->TransactionDetails->CurrencyCode); | ||
} | ||
|
||
public function testGetDataCustomerDetails() | ||
{ | ||
// | ||
} | ||
} |
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
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,31 @@ | ||
<?php | ||
|
||
namespace Omnipay\Creditcall\Test\Message; | ||
|
||
use Omnipay\Creditcall\Message\CaptureRequest; | ||
use Omnipay\Tests\TestCase; | ||
|
||
class CaptureRequestTest extends TestCase | ||
{ | ||
/** | ||
* @var CaptureRequest | ||
*/ | ||
protected $request; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->request = new CaptureRequest($this->getHttpClient(), $this->getHttpRequest()); | ||
$this->request->initialize(array( | ||
'transactionReference' => '6f3b812a-dafa-e311-983c-00505692354f', | ||
)); | ||
} | ||
|
||
public function testGetData() | ||
{ | ||
$data = $this->request->getData(); | ||
|
||
$this->assertSame('6f3b812a-dafa-e311-983c-00505692354f', (string)$data->TransactionDetails->CardEaseReference); | ||
} | ||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace Omnipay\Creditcall\Test\Message; | ||
|
||
use Omnipay\Creditcall\Message\PurchaseRequest; | ||
|
||
class PurchaseRequestTest extends AuthorizeRequestTest | ||
{ | ||
/** | ||
* @var PurchaseRequest | ||
*/ | ||
protected $request; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); | ||
$this->request->initialize($this->getOptions()); | ||
} | ||
|
||
public function testAutoconfirmProperty() | ||
{ | ||
$data = $this->request->getData(); | ||
|
||
$this->assertSame('true', (string)$data->TransactionDetails->MessageType->attributes()->autoconfirm); | ||
} | ||
} |
Oops, something went wrong.