* Copyright 2001-2010 Strangecode, LLC * * This file is part of The Strangecode Codebase. * * The Strangecode Codebase is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your option) * any later version. * * The Strangecode Codebase is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * The Strangecode Codebase. If not, see . */ /** * PHPUnit test case for codebase/lib/AuthorizeNet.inc.php * * The method skeletons below need to be filled in with * real data so that the tests will run correctly. Replace * all EXPECTED_VAL and PARAM strings with real data. * * Created with PHPUnit_Skeleton on 2005-08-09 */ require_once 'PHPUnit.php'; class AuthorizeNetTest extends PHPUnit_TestCase { var $AuthorizeNet; function AuthorizeNetTest($name) { $this->PHPUnit_TestCase($name); } function setUp() { require dirname(__FILE__) . '/_config.inc.php'; require_once '../lib/AuthorizeNet.inc.php'; $this->AuthorizeNet =& new AuthorizeNet(); $this->AuthorizeNet->setParam(array( 'x_login' => 'myaccount', 'x_test_request' => 'true', 'x_first_name' => 'john', 'x_last_name' => 'doe', 'x_amount' => '1.20', 'x_card_num' => '4111111111111111', 'x_card_code' => '123', 'x_exp_date' => '042008', 'x_invoice_num' => '100', 'x_address' => '10 rue levouvé', 'x_city' => 'somecity', 'x_state' => 'ca', 'x_zip' => '75010', )); } function tearDown() { unset($this->AuthorizeNet); } function test_setparam() { $this->AuthorizeNet->setparam(array('x_Login' => 'myaccount2')); $this->assertEquals('myaccount2', $this->AuthorizeNet->_params['x_Login']); } function test_getparam() { $result = $this->AuthorizeNet->getparam('x_card_num'); $expected = '4111111111111111'; $this->assertEquals($expected, $result); } function test_process() { $result_code = $this->AuthorizeNet->process(); $this->assertTrue(false != $result_code, 'Processing did not return valid response. Do you have net access?'); $this->assertEquals('3', $result_code); } function test_getresult() { $result_code = $this->AuthorizeNet->process(); $result_array = $this->AuthorizeNet->getResult(); $this->assertTrue(false != $result_code, 'Processing did not return valid response. Do you have net access?'); $this->assertTrue(isset($result_array['x_response_reason_code']) && '13' == $result_array['x_response_reason_code'], 'Server resonse did not include x_response.'); } // function test_validmd5hash() // { // $this->AuthorizeNet->process(); // $result = $this->AuthorizeNet->validmd5hash(); // $this->assertTrue($result, 'Invalid md5 hash returned from server.'); // } // function test_reset() // { // $result = $this->AuthorizeNet->reset(PARAM); // $expected = EXPECTED_VAL; // $this->assertEquals($expected, $result); // } // // function test__processresult() // { // $result = $this->AuthorizeNet->_processresult(PARAM); // $expected = EXPECTED_VAL; // $this->assertEquals($expected, $result); // } } // Running the test. $suite = new PHPUnit_TestSuite('AuthorizeNetTest'); $result = PHPUnit::run($suite); echo $result->toString(); ?>