Last active
August 23, 2023 13:30
-
-
Save mcsee/191cee3a71132501564cdb58abef27a7 to your computer and use it in GitHub Desktop.
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
<? | |
class PaymentTest extends TestCase | |
{ | |
public function testProcessPaymentReturnsTrueOnSuccessfulPayment() | |
{ | |
$paymentDetails = array( | |
'amount' => 123.99, | |
'card_num' => '4111-1111-1111-1111', | |
'exp_date' => '03/2013', | |
); | |
$payment = $this->getMockBuilder('Payment') | |
->setConstructorArgs(array()) | |
->getMock(); | |
// You should not mock a business object! | |
$authorizeNet = new AuthorizeNetAIM( | |
$payment::API_ID, $payment::TRANS_KEY); | |
// This is an external and coupled system. | |
// You have no control over it so tests become fragile | |
$paymentProcessResult = $payment->processPayment( | |
$authorizeNet, $paymentDetails); | |
$this->assertTrue($paymentProcessResult); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment