|
| 1 | +<?php |
| 2 | +namespace net\authorize\api\controller\test; |
| 3 | + |
| 4 | +use net\authorize\api\contract\v1 AS apiContract; |
| 5 | +use net\authorize\api\controller AS apiController; |
| 6 | + |
| 7 | +require_once __DIR__ . '/../../../../../autoload.php'; |
| 8 | +//include if tests/bootstrap.php is not loaded automatically |
| 9 | +//require_once __DIR__ . '/../../../../bootstrap.php'; |
| 10 | + |
| 11 | +class ApiCoreTestBase extends \PHPUnit_Framework_TestCase |
| 12 | +{ |
| 13 | + protected $paymentOne = null; |
| 14 | + protected $orderType = null; |
| 15 | + protected $customerDataOne = null; |
| 16 | + protected $customerAddressOne = null; |
| 17 | + protected $payPalOne = null; |
| 18 | + |
| 19 | + protected $counter = 0; |
| 20 | + protected $counterStr = "0"; |
| 21 | + protected $refId = ''; |
| 22 | + |
| 23 | + protected static $LoginName = ''; |
| 24 | + protected static $TransactionKey = ''; |
| 25 | + |
| 26 | + protected static $TestEnvironment = \net\authorize\api\constants\ANetEnvironment::SANDBOX; |
| 27 | + protected static $log_file = false; |
| 28 | + |
| 29 | + public static function setUpBeforeClass() |
| 30 | + { |
| 31 | + if (!defined('AUTHORIZENET_LOG_FILE')) |
| 32 | + { |
| 33 | + define( "AUTHORIZENET_LOG_FILE", __DIR__ . "/../../../../../log/authorize-net.log"); |
| 34 | + } |
| 35 | + //self::$name = (defined('AUTHORIZENET_API_LOGIN_ID') && ''!=AUTHORIZENET_API_LOGIN_ID) ? AUTHORIZENET_API_LOGIN_ID : getenv("api_login_id"); |
| 36 | + //self::$transactionKey = (defined('AUTHORIZENET_TRANSACTION_KEY') && ''!=AUTHORIZENET_TRANSACTION_KEY) ? AUTHORIZENET_TRANSACTION_KEY : getenv("transaction_key"); |
| 37 | + self::$LoginName = '9q2yWeA3J3Q'; |
| 38 | + self::$TransactionKey = '7KTb8aThMJ35y879'; |
| 39 | + self::$log_file = (defined('AUTHORIZENET_LOG_FILE') ? AUTHORIZENET_LOG_FILE : false); |
| 40 | + } |
| 41 | + |
| 42 | + public static function tearDownAfterClass() |
| 43 | + { |
| 44 | + } |
| 45 | + |
| 46 | + public function __construct() |
| 47 | + { |
| 48 | + } |
| 49 | + |
| 50 | + protected function setUp() |
| 51 | + { |
| 52 | + $this->refId = 'ref' . time(); |
| 53 | + |
| 54 | + $this->counter = rand(); |
| 55 | + $this->counterStr = sprintf("%s", $this->counter); |
| 56 | + |
| 57 | + $driversLicenseOne = new apiContract\DriversLicenseType(); |
| 58 | + $driversLicenseOne->setNumber( $this->getRandomString( "DL-" )); |
| 59 | + $driversLicenseOne->setState( "WA"); |
| 60 | + $driversLicenseOne->setDateOfBirth( "01/01/1960"); |
| 61 | + |
| 62 | + $customerOne = new apiContract\CustomerType(); |
| 63 | + $customerOne->setType("individual"); //TODO: CHANGE TO ENUM |
| 64 | + $customerOne->setId( $this->getRandomString( "Id" )); |
| 65 | + $customerOne->setEmail ( $this->counterStr . ".customerOne@test.anet.net"); |
| 66 | + $customerOne->setPhoneNumber("1234567890"); |
| 67 | + $customerOne->setFaxNumber("1234567891"); |
| 68 | + //$customerOne->setDriversLicense( $driversLicenseOne); |
| 69 | + $customerOne->setTaxId( "911011011"); |
| 70 | + |
| 71 | + $creditCardOne = new apiContract\CreditCardType(); |
| 72 | + $creditCardOne->setCardNumber( "4111111111111111" ); |
| 73 | + $creditCardOne->setExpirationDate( "2038-12"); |
| 74 | + |
| 75 | + $this->paymentOne = new apiContract\PaymentType(); |
| 76 | + $this->paymentOne->setCreditCard( $creditCardOne); |
| 77 | + |
| 78 | + $this->orderType = new apiContract\OrderType(); |
| 79 | + $this->orderType->setInvoiceNumber( $this->getRandomString( "Inv:" )); |
| 80 | + $this->orderType->setDescription( $this->getRandomString( "Description" )); |
| 81 | + |
| 82 | + $this->customerDataOne = new apiContract\CustomerDataType(); |
| 83 | + //$this->customerDataOne->setDriversLicense( $customerOne->getDriversLicense()); |
| 84 | + $this->customerDataOne->setEmail( $customerOne->getEmail()); |
| 85 | + $this->customerDataOne->setId( $customerOne->getId()); |
| 86 | + $this->customerDataOne->setTaxId( $customerOne->getTaxId()); |
| 87 | + $this->customerDataOne->setType( $customerOne->getType()); |
| 88 | + |
| 89 | + $this->customerAddressOne = new apiContract\CustomerAddressType(); |
| 90 | + $this->customerAddressOne->setFirstName( $this->getRandomString( "FName" )); |
| 91 | + $this->customerAddressOne->setLastName( $this->getRandomString( "LName" )); |
| 92 | + $this->customerAddressOne->setCompany( $this->getRandomString( "Company" )); |
| 93 | + $this->customerAddressOne->setAddress( $this->getRandomString( "StreetAdd" )); |
| 94 | + $this->customerAddressOne->setCity( "Bellevue"); |
| 95 | + $this->customerAddressOne->setState( "WA"); |
| 96 | + $this->customerAddressOne->setZip( "98004"); |
| 97 | + $this->customerAddressOne->setCountry( "USA"); |
| 98 | + $this->customerAddressOne->setPhoneNumber( $customerOne->getPhoneNumber()); |
| 99 | + $this->customerAddressOne->setFaxNumber( $customerOne->getFaxNumber()); |
| 100 | + |
| 101 | + $this->payPalOne = new apiContract\PayPalType(); |
| 102 | + $this->payPalOne->setPaypalLc( "IT" ); |
| 103 | + $this->payPalOne->setPaypalPayflowcolor( "FFFFF0"); |
| 104 | + $this->payPalOne->setSuccessUrl( $this->getRandomString( "http://success.anet.net")); |
| 105 | + $this->payPalOne->setCancelUrl( $this->getRandomString( "http://cancel.anet.net")); |
| 106 | + //payPalHdrImg = GetRandomString("Hdr"), |
| 107 | + //payerID = GetRandomString("PayerId"), |
| 108 | + } |
| 109 | + |
| 110 | + protected function tearDown() |
| 111 | + { |
| 112 | + |
| 113 | + } |
| 114 | + |
| 115 | + protected function getRandomString( $title) |
| 116 | + { |
| 117 | + return sprintf( "%s%s", $title, $this->counterStr); |
| 118 | + } |
| 119 | + |
| 120 | + protected function setValidAmount( $number) |
| 121 | + { |
| 122 | + return min( $number, self::MaxTransactionAmount); |
| 123 | + } |
| 124 | + |
| 125 | + const MaxTransactionAmount = 10000; //214747; |
| 126 | +} |
0 commit comments