Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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))
//External system is mocked
$result = $payment->processPayment($authorizeNet, $paymentDetails);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment