source: trunk/tests/AuthorizeNetTest.php

Last change on this file was 468, checked in by anonymous, 10 years ago

Completed integrating /branches/eli_branch into /trunk. Changes include:

  • Removed closing ?> from end of files
  • Upgrade old-style contructor methods to use construct() instead.
  • Class properties and methods defined as public, private, static or protected
  • Ensure code runs under E_ALL with only mysql_* deprecated warnings
  • Search for the '@' symbol anywhere it might be used to supress runtime errors, then replace with proper error recovery.
  • Run the php cli -l option to check files for syntax errors.
  • Bring tests up-to-date with latest version and methods of PHPUnit
File size: 3.9 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-2012 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 */
32
33class AuthorizeNetTest extends PHPUnit_Framework_TestCase {
34
35    var $AuthorizeNet;
36   
37    static $shared_session;
38   
39    function setUp()
40    {
41        require dirname(__FILE__) . '/_config.inc.php';
42        require_once '../lib/AuthorizeNet.inc.php';
43
44        $this->AuthorizeNet = new AuthorizeNet();
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',
55            'x_address' => '10 rue levouvé',
56            'x_city' => 'somecity',
57            'x_state' => 'ca',
58            'x_zip' => '75010',
59        ));
60        $_SESSION = AuthorizeNetTest::$shared_session;
61    }
62
63    function tearDown()
64    {
65        unset($this->AuthorizeNet);
66        AuthorizeNetTest::$shared_session = $_SESSION;
67    }
68
69    function test_setparam()
70    {
71        $this->AuthorizeNet->setparam(array('x_Login' => 'myaccount2'));
72        $this->assertEquals('myaccount2', $this->AuthorizeNet->getParam('x_Login'));
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();
85
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//     }
111//
112//     function test__processresult()
113//     {
114//         $result = $this->AuthorizeNet->_processresult(PARAM);
115//         $expected = EXPECTED_VAL;
116//         $this->assertEquals($expected, $result);
117//     }
118
119}
Note: See TracBrowser for help on using the repository browser.