<?php | |
namespace phpUnitTutorial\Test; | |
use phpUnitTutorial\Payment; | |
class PaymentTest extends \PHPUnit_Framework_TestCase | |
{ | |
public function testProcessPaymentReturnsTrueOnSuccessfulPayment() | |
{ | |
$paymentDetails = array( | |
'amount' => 123.99, | |
'card_num' => '4111-1111-1111-1111', | |
'exp_date' => '03/2013', | |
); | |
$payment = new Payment(); | |
//Payment is a real one | |
$response = new \stdClass(); | |
$response->approved = true; | |
$response->transaction_id = 123; | |
$authorizeNet = $this->getMockBuilder('\AuthorizeNetAIM') | |
->setConstructorArgs(array($payment::API_ID, $payment::TRANS_KEY)) | |
->getMock(); | |
//External system is mocked | |
$authorizeNet->expects($this->once()) | |
->method('authorizeAndCapture') | |
->will($this->returnValue($response)); | |
$result = $payment->processPayment($authorizeNet, $paymentDetails); | |
$this->assertTrue($result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment