[1] | 1 | <?php |
---|
| 2 | /** |
---|
[362] | 3 | * The Strangecode Codebase - a general application development framework for PHP |
---|
| 4 | * For details visit the project site: <http://trac.strangecode.com/codebase/> |
---|
[396] | 5 | * Copyright 2001-2012 Strangecode, LLC |
---|
[362] | 6 | * |
---|
| 7 | * This file is part of The Strangecode Codebase. |
---|
[42] | 8 | * |
---|
[362] | 9 | * The Strangecode Codebase is free software: you can redistribute it and/or |
---|
| 10 | * modify it under the terms of the GNU General Public License as published by the |
---|
| 11 | * Free Software Foundation, either version 3 of the License, or (at your option) |
---|
| 12 | * any later version. |
---|
| 13 | * |
---|
| 14 | * The Strangecode Codebase is distributed in the hope that it will be useful, but |
---|
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
| 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
---|
| 17 | * details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License along with |
---|
| 20 | * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | /** |
---|
| 24 | * PHPUnit test case for codebase/lib/AuthorizeNet.inc.php |
---|
| 25 | * |
---|
[42] | 26 | * The method skeletons below need to be filled in with |
---|
| 27 | * real data so that the tests will run correctly. Replace |
---|
| 28 | * all EXPECTED_VAL and PARAM strings with real data. |
---|
| 29 | * |
---|
[1] | 30 | * Created with PHPUnit_Skeleton on 2005-08-09 |
---|
| 31 | */ |
---|
| 32 | |
---|
[468] | 33 | class AuthorizeNetTest extends PHPUnit_Framework_TestCase { |
---|
| 34 | |
---|
[1] | 35 | var $AuthorizeNet; |
---|
[468] | 36 | |
---|
| 37 | static $shared_session; |
---|
| 38 | |
---|
[1] | 39 | function setUp() |
---|
| 40 | { |
---|
| 41 | require dirname(__FILE__) . '/_config.inc.php'; |
---|
| 42 | require_once '../lib/AuthorizeNet.inc.php'; |
---|
| 43 | |
---|
[468] | 44 | $this->AuthorizeNet = new AuthorizeNet(); |
---|
[1] | 45 | $this->AuthorizeNet->setParam(array( |
---|
| 46 | 'x_login' => 'myaccount', |
---|
| 47 | 'x_test_request' => 'true', |
---|
| 48 | 'x_first_name' => 'john', |
---|
| 49 | 'x_last_name' => 'doe', |
---|
| 50 | 'x_amount' => '1.20', |
---|
| 51 | 'x_card_num' => '4111111111111111', |
---|
| 52 | 'x_card_code' => '123', |
---|
| 53 | 'x_exp_date' => '042008', |
---|
| 54 | 'x_invoice_num' => '100', |
---|
[362] | 55 | 'x_address' => '10 rue levouvé', |
---|
[1] | 56 | 'x_city' => 'somecity', |
---|
| 57 | 'x_state' => 'ca', |
---|
| 58 | 'x_zip' => '75010', |
---|
| 59 | )); |
---|
[468] | 60 | $_SESSION = AuthorizeNetTest::$shared_session; |
---|
[1] | 61 | } |
---|
| 62 | |
---|
| 63 | function tearDown() |
---|
| 64 | { |
---|
| 65 | unset($this->AuthorizeNet); |
---|
[468] | 66 | AuthorizeNetTest::$shared_session = $_SESSION; |
---|
[1] | 67 | } |
---|
| 68 | |
---|
| 69 | function test_setparam() |
---|
| 70 | { |
---|
| 71 | $this->AuthorizeNet->setparam(array('x_Login' => 'myaccount2')); |
---|
[468] | 72 | $this->assertEquals('myaccount2', $this->AuthorizeNet->getParam('x_Login')); |
---|
[1] | 73 | } |
---|
| 74 | |
---|
| 75 | function test_getparam() |
---|
| 76 | { |
---|
| 77 | $result = $this->AuthorizeNet->getparam('x_card_num'); |
---|
| 78 | $expected = '4111111111111111'; |
---|
| 79 | $this->assertEquals($expected, $result); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | function test_process() |
---|
| 83 | { |
---|
| 84 | $result_code = $this->AuthorizeNet->process(); |
---|
[42] | 85 | |
---|
[1] | 86 | $this->assertTrue(false != $result_code, 'Processing did not return valid response. Do you have net access?'); |
---|
| 87 | $this->assertEquals('3', $result_code); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | function test_getresult() |
---|
| 91 | { |
---|
| 92 | $result_code = $this->AuthorizeNet->process(); |
---|
| 93 | $result_array = $this->AuthorizeNet->getResult(); |
---|
| 94 | $this->assertTrue(false != $result_code, 'Processing did not return valid response. Do you have net access?'); |
---|
| 95 | $this->assertTrue(isset($result_array['x_response_reason_code']) && '13' == $result_array['x_response_reason_code'], 'Server resonse did not include x_response.'); |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | // function test_validmd5hash() |
---|
| 99 | // { |
---|
| 100 | // $this->AuthorizeNet->process(); |
---|
| 101 | // $result = $this->AuthorizeNet->validmd5hash(); |
---|
| 102 | // $this->assertTrue($result, 'Invalid md5 hash returned from server.'); |
---|
| 103 | // } |
---|
| 104 | |
---|
| 105 | // function test_reset() |
---|
| 106 | // { |
---|
| 107 | // $result = $this->AuthorizeNet->reset(PARAM); |
---|
| 108 | // $expected = EXPECTED_VAL; |
---|
| 109 | // $this->assertEquals($expected, $result); |
---|
| 110 | // } |
---|
[42] | 111 | // |
---|
[1] | 112 | // function test__processresult() |
---|
| 113 | // { |
---|
| 114 | // $result = $this->AuthorizeNet->_processresult(PARAM); |
---|
| 115 | // $expected = EXPECTED_VAL; |
---|
| 116 | // $this->assertEquals($expected, $result); |
---|
| 117 | // } |
---|
| 118 | |
---|
| 119 | } |
---|