source: trunk/tests/AuthorizeNetTest.php @ 376

Last change on this file since 376 was 376, checked in by quinn, 14 years ago

Updated copyright date, name to Strangecode LLC.

File size: 4.0 KB
Line 
1<?php
2/**
3 * The Strangecode Codebase - a general application development framework for PHP
4 * For details visit the project site: <http://trac.strangecode.com/codebase/>
5 * Copyright 2001-2010 Strangecode, LLC
6 *
7 * This file is part of The Strangecode Codebase.
8 *
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 *
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 *
30 * Created with PHPUnit_Skeleton on 2005-08-09
31 */
32require_once 'PHPUnit.php';
33class AuthorizeNetTest extends PHPUnit_TestCase {
34
35    var $AuthorizeNet;
36
37    function AuthorizeNetTest($name)
38    {
39        $this->PHPUnit_TestCase($name);
40    }
41
42    function setUp()
43    {
44        require dirname(__FILE__) . '/_config.inc.php';
45        require_once '../lib/AuthorizeNet.inc.php';
46
47        $this->AuthorizeNet =& new AuthorizeNet();
48        $this->AuthorizeNet->setParam(array(
49            'x_login' => 'myaccount',
50            'x_test_request' => 'true',
51            'x_first_name' => 'john',
52            'x_last_name' => 'doe',
53            'x_amount' => '1.20',
54            'x_card_num' => '4111111111111111',
55            'x_card_code' => '123',
56            'x_exp_date' => '042008',
57            'x_invoice_num' => '100',
58            'x_address' => '10 rue levouvé',
59            'x_city' => 'somecity',
60            'x_state' => 'ca',
61            'x_zip' => '75010',
62        ));
63    }
64
65    function tearDown()
66    {
67        unset($this->AuthorizeNet);
68    }
69
70    function test_setparam()
71    {
72        $this->AuthorizeNet->setparam(array('x_Login' => 'myaccount2'));
73        $this->assertEquals('myaccount2', $this->AuthorizeNet->_params['x_Login']);
74    }
75
76    function test_getparam()
77    {
78        $result = $this->AuthorizeNet->getparam('x_card_num');
79        $expected = '4111111111111111';
80        $this->assertEquals($expected, $result);
81    }
82
83    function test_process()
84    {
85        $result_code = $this->AuthorizeNet->process();
86
87        $this->assertTrue(false != $result_code, 'Processing did not return valid response. Do you have net access?');
88        $this->assertEquals('3', $result_code);
89    }
90
91    function test_getresult()
92    {
93        $result_code = $this->AuthorizeNet->process();
94        $result_array = $this->AuthorizeNet->getResult();
95        $this->assertTrue(false != $result_code, 'Processing did not return valid response. Do you have net access?');
96        $this->assertTrue(isset($result_array['x_response_reason_code']) && '13' == $result_array['x_response_reason_code'], 'Server resonse did not include x_response.');
97    }
98
99//     function test_validmd5hash()
100//     {
101//         $this->AuthorizeNet->process();
102//         $result = $this->AuthorizeNet->validmd5hash();
103//         $this->assertTrue($result, 'Invalid md5 hash returned from server.');
104//     }
105
106//     function test_reset()
107//     {
108//         $result = $this->AuthorizeNet->reset(PARAM);
109//         $expected = EXPECTED_VAL;
110//         $this->assertEquals($expected, $result);
111//     }
112//
113//     function test__processresult()
114//     {
115//         $result = $this->AuthorizeNet->_processresult(PARAM);
116//         $expected = EXPECTED_VAL;
117//         $this->assertEquals($expected, $result);
118//     }
119
120}
121// Running the test.
122$suite = new PHPUnit_TestSuite('AuthorizeNetTest');
123$result = PHPUnit::run($suite);
124echo $result->toString();
125?>
Note: See TracBrowser for help on using the repository browser.