/[drupal]/contributions/modules/quickpay/quickpay.test
ViewVC logotype

Contents of /contributions/modules/quickpay/quickpay.test

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Fri Mar 27 21:38:01 2009 UTC (8 months ago) by xen
Branch: MAIN
CVS Tags: DRUPAL-6--0-1, DRUPAL-6--1-0-BETA1, DRUPAL-6--0-2, HEAD
Branch point for: DRUPAL-6--1
File MIME type: text/x-php
Moved test file.
1 <?php
2
3 // $Id: quickpay.test,v 1.2 2009/03/07 19:46:03 xen Exp $
4 class QuickPayTest extends DrupalWebTestCase {
5 /**
6 * Implementation of get_info() for information
7 */
8 function getInfo() {
9 return array(
10 'name' => t('QuickPay'),
11 'description' => t('Tests that core QuickPay functions work. <em>WARNING:</em> This assumes that the configured QuickPay account is running in test mode. Don\'t run this on a production account.'),
12 'group' => 'Quickpay Tests',
13 );
14 }
15
16 function setUp() {
17 parent::setUp();
18 // setUp is called before each test. Just set the order prefix once
19 if (!$this->orderPrefix) {
20 $this->orderPrefix = "qptest" . time() . 't';
21 $this->orderNum = 1;
22 }
23 variable_set('quickpay_order_prefix', $this->orderPrefix);
24 variable_set('quickpay_merchant', '30453131');
25 variable_set('quickpay_secret', '6vgz29iFVym86rkut4X23K8EBRjGQ651pA5ZHl933749M6n47D5P4eba3qxC7U8T');
26 variable_set('quickpay_default_currency', 'DKK');
27 }
28
29 function tearDown() {
30 parent::tearDown();
31 }
32
33 function assertState($txn, $state) {
34 $code = array_search($state, _quickpay_state_codes());
35 $this->assertTrue($code !== false, 'Unknown status');
36 if ($code) {
37 $this->assertTrue($txn['state'] == $code, 'Transaction state is \'' .
38 $state . '\'');
39 }
40 }
41 function testCore() {
42 $txn = quickpay_authorize(array('number' => '4571222233334444',
43 'exp_month' => '3',
44 'exp_year' => '19',
45 'cvd' => '123'), $this->orderNum++, 100);
46
47 $this->assertTrue($txn !== false, 'Simple authorization');
48 $this->assertTrue(quickpay_successful($txn), 'Was successful');
49 $this->assertState($txn, 'Authorized');
50 $txn = quickpay_cancel($txn);
51 $this->assertTrue(quickpay_successful($txn), 'Reversing as successful');
52 $this->assertState($txn, 'Cancelled');
53
54 // check that reusing orders doesn't work
55 }
56
57 function testCaptureCredit() {
58 $txn = quickpay_authorize(array('number' => '4571222233334444',
59 'exp_month' => '3',
60 'exp_year' => '19',
61 'cvd' => '123'), $this->orderNum++, 100);
62
63 $this->assertTrue($txn !== false, 'Simple authorization');
64 $this->assertTrue(quickpay_successful($txn), 'Was successful');
65 $this->assertState($txn, 'Authorized');
66 $txn = quickpay_capture($txn, 100);
67 $this->assertTrue(quickpay_successful($txn), 'Was successful');
68 $this->assertState($txn, 'Captured');
69 $txn = quickpay_refund($txn, 100);
70 $this->assertTrue(quickpay_successful($txn), 'Was successful');
71 $this->assertState($txn, 'Refunded');
72
73 $txn = quickpay_authorize(array('number' => '4571222233334444',
74 'exp_month' => '3',
75 'exp_year' => '19',
76 'cvd' => '123'), $this->orderNum++, 100,
77 null, true);
78
79 $this->assertTrue($txn !== false, 'Autocapture authorization');
80 $this->assertTrue(quickpay_successful($txn), 'Was successful');
81 $this->assertState($txn, 'Captured');
82
83 }
84 function testSubscribe() {
85 $txn = quickpay_subscribe(array('number' => '4571222233334444',
86 'exp_month' => '3',
87 'exp_year' => '19',
88 'cvd' => '123'), $this->orderNum++,
89 'Subscriptiontest');
90
91 $this->assertTrue($txn !== false, 'Subscription authorization');
92 $this->assertTrue(quickpay_successful($txn), 'Was successful');
93 $this->assertState($txn, 'Subscribed');
94 $txn = quickpay_recurring($txn, $this->orderNum++, 100);
95 $this->assertTrue(quickpay_successful($txn), 'Recurring was successful');
96 $this->assertState($txn, 'Authorized');
97 $txn = quickpay_capture($txn, 100);
98 $this->assertTrue(quickpay_successful($txn), 'Capture was successful');
99 $this->assertState($txn, 'Captured');
100
101 }
102
103 function testCaptureLess() {
104 $txn = quickpay_authorize(array('number' => '4571222233334444',
105 'exp_month' => '3',
106 'exp_year' => '19',
107 'cvd' => '123'), $this->orderNum++, 100);
108
109 $this->assertTrue($txn !== false, 'Simple authorization');
110 $this->assertTrue(quickpay_successful($txn), 'Was successful');
111 $this->assertState($txn, 'Authorized');
112 $txn = quickpay_capture($txn, 50);
113 $this->assertTrue(quickpay_successful($txn), 'Was successful');
114 $this->assertState($txn, 'Captured');
115 }
116 /*
117 // In test, it's just approved?
118 function testCaptureMore() {
119 $txn = quickpay_authorize(array('number' => '4571222233334444',
120 'exp_month' => '3',
121 'exp_year' => '9',
122 'cvd' => '123'), $this->orderNum++, 100);
123
124 $this->assertTrue($txn !== false, 'Simple authorization');
125 $this->assertTrue(quickpay_successful($txn), 'Was successful');
126 $this->assertState($txn, 'Authorized');
127 $txn = quickpay_capture($txn, 200);
128 dpm($txn);
129 $this->assertFalse(quickpay_successful($txn), 'Wasn\'t successful');
130 $this->assertState($txn, 'Capture failed');
131 }
132 */
133 }

  ViewVC Help
Powered by ViewVC 1.1.2