| 1 |
<?php
|
| 2 |
// $Id: ec_eway.test,v 1.1 2008/10/29 03:35:37 gordon Exp $
|
| 3 |
/**
|
| 4 |
* @file
|
| 5 |
* Test scripts for Eway
|
| 6 |
*/
|
| 7 |
|
| 8 |
class ec_ewayTestCase extends DrupalWebTestCase {
|
| 9 |
function getInfo() {
|
| 10 |
return array(
|
| 11 |
'name' => t('Eway payment gateway'),
|
| 12 |
'description' => t('Test the Eway payment gateway to make sure that receipts are being created correctly'),
|
| 13 |
'group' => t('Eway'),
|
| 14 |
);
|
| 15 |
}
|
| 16 |
|
| 17 |
function setUp() {
|
| 18 |
parent::setUp('ec_anon', 'ec_common', 'ec_customer', 'ec_receipt_test', 'ec_receipt', 'ec_eway');
|
| 19 |
|
| 20 |
variable_set('ec_eway_clientid', '87654321');
|
| 21 |
variable_set('ec_eway_debug', 1);
|
| 22 |
variable_get('ec_eway_default_description', 'Eway Payment Gateway test');
|
| 23 |
}
|
| 24 |
|
| 25 |
function testPaymentSuccessful() {
|
| 26 |
$config = array(
|
| 27 |
'payment_type' => 'eway',
|
| 28 |
'amount' => 10,
|
| 29 |
'cardno' => '4444333322221111',
|
| 30 |
'currency' => 'AUD',
|
| 31 |
'fname' => 'John',
|
| 32 |
'lname' => 'Doe',
|
| 33 |
'address' => array(
|
| 34 |
'street1' => '1 Elizabeth St',
|
| 35 |
'suburb' => 'Melbourne',
|
| 36 |
'state' => 'VIC',
|
| 37 |
'zip' => '3000',
|
| 38 |
),
|
| 39 |
);
|
| 40 |
$receipt_no = ec_receipt_payment_process('test', $config);
|
| 41 |
|
| 42 |
$this->assertNotNull($receipt_no, 'Receipt no returned');
|
| 43 |
|
| 44 |
if ($receipt_no) {
|
| 45 |
$receipt = ec_receipt_load($receipt_no);
|
| 46 |
|
| 47 |
$this->assertTrue($receipt->status == RECEIPT_STATUS_COMPLETED, t('Receipt Completed'));
|
| 48 |
}
|
| 49 |
}
|
| 50 |
|
| 51 |
/**
|
| 52 |
function testPaymentFailure() {
|
| 53 |
$config = array(
|
| 54 |
'payment_type' => 'eway',
|
| 55 |
'amount' => 10.50,
|
| 56 |
'cardno' => '4444333322221111',
|
| 57 |
);
|
| 58 |
$receipt_no = ec_receipt_payment_process('test', $config);
|
| 59 |
|
| 60 |
$this->assertNotNull($receipt_no, 'Receipt no returned');
|
| 61 |
|
| 62 |
if ($receipt_no) {
|
| 63 |
$receipt = ec_receipt_load($receipt_no);
|
| 64 |
|
| 65 |
$this->assertTrue($receipt->RECEIPT_STATUS_FAILED, t('Receipt Failed'));
|
| 66 |
}
|
| 67 |
watchdog('test', print_r($_SESSION, TRUE));
|
| 68 |
}
|
| 69 |
*/
|
| 70 |
}
|
| 71 |
|