source: trunk/tests/AuthorizeNetTest.php @ 1

Last change on this file since 1 was 1, checked in by scdev, 19 years ago

Initial import.

File size: 3.1 KB
Line 
1<?php
2/**
3 * PHPUnit test case for AuthorizeNet
4 *
5 * The method skeletons below need to be filled in with
6 * real data so that the tests will run correctly. Replace
7 * all EXPECTED_VAL and PARAM strings with real data.
8 *
9 * Created with PHPUnit_Skeleton on 2005-08-09
10 */
11require_once 'PHPUnit.php';
12class AuthorizeNetTest extends PHPUnit_TestCase {
13
14    var $AuthorizeNet;
15
16    function AuthorizeNetTest($name)
17    {
18        $this->PHPUnit_TestCase($name);
19    }
20
21    function setUp()
22    {
23        require dirname(__FILE__) . '/_config.inc.php';
24        require_once '../lib/AuthorizeNet.inc.php';
25
26        $this->AuthorizeNet =& new AuthorizeNet();
27        $this->AuthorizeNet->setParam(array(
28            'x_login' => 'myaccount',
29            'x_test_request' => 'true',
30            'x_first_name' => 'john',
31            'x_last_name' => 'doe',
32            'x_amount' => '1.20',
33            'x_card_num' => '4111111111111111',
34            'x_card_code' => '123',
35            'x_exp_date' => '042008',
36            'x_invoice_num' => '100',
37            'x_address' => '10 rue levouvŽ',
38            'x_city' => 'somecity',
39            'x_state' => 'ca',
40            'x_zip' => '75010',
41        ));
42    }
43
44    function tearDown()
45    {
46        unset($this->AuthorizeNet);
47    }
48
49    function test_setparam()
50    {
51        $this->AuthorizeNet->setparam(array('x_Login' => 'myaccount2'));
52        $this->assertEquals('myaccount2', $this->AuthorizeNet->_params['x_Login']);
53    }
54
55    function test_getparam()
56    {
57        $result = $this->AuthorizeNet->getparam('x_card_num');
58        $expected = '4111111111111111';
59        $this->assertEquals($expected, $result);
60    }
61
62    function test_process()
63    {
64        $result_code = $this->AuthorizeNet->process();
65       
66        $this->assertTrue(false != $result_code, 'Processing did not return valid response. Do you have net access?');
67        $this->assertEquals('3', $result_code);
68    }
69
70    function test_getresult()
71    {
72        $result_code = $this->AuthorizeNet->process();
73        $result_array = $this->AuthorizeNet->getResult();
74        $this->assertTrue(false != $result_code, 'Processing did not return valid response. Do you have net access?');
75        $this->assertTrue(isset($result_array['x_response_reason_code']) && '13' == $result_array['x_response_reason_code'], 'Server resonse did not include x_response.');
76    }
77
78//     function test_validmd5hash()
79//     {
80//         $this->AuthorizeNet->process();
81//         $result = $this->AuthorizeNet->validmd5hash();
82//         $this->assertTrue($result, 'Invalid md5 hash returned from server.');
83//     }
84
85//     function test_reset()
86//     {
87//         $result = $this->AuthorizeNet->reset(PARAM);
88//         $expected = EXPECTED_VAL;
89//         $this->assertEquals($expected, $result);
90//     }
91//
92//     function test__processresult()
93//     {
94//         $result = $this->AuthorizeNet->_processresult(PARAM);
95//         $expected = EXPECTED_VAL;
96//         $this->assertEquals($expected, $result);
97//     }
98
99}
100// Running the test.
101$suite = new PHPUnit_TestSuite('AuthorizeNetTest');
102$result = PHPUnit::run($suite);
103echo $result->toString();
104?>
Note: See TracBrowser for help on using the repository browser.