1
|
|
|
<?php |
2
|
|
|
require_once 'Intraface/modules/onlinepayment/OnlinePayment.php'; |
3
|
|
|
require_once 'Intraface/functions.php'; |
4
|
|
|
require_once 'DB/Sql.php'; |
5
|
|
|
|
6
|
|
|
class OnlinePaymentTest extends PHPUnit_Framework_TestCase |
7
|
|
|
{ |
8
|
|
|
private $kernel; |
|
|
|
|
9
|
|
|
|
10
|
|
|
function setUp() |
11
|
|
|
{ |
12
|
|
|
$db = MDB2::singleton(DB_DSN); |
13
|
|
|
$db->query('TRUNCATE onlinepayment'); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
View Code Duplication |
function createKernel() |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
$kernel = new Stub_Kernel; |
19
|
|
|
$kernel->setting->set('intranet', 'onlinepayment.provider_key', 1); |
20
|
|
|
$kernel->setting->set('intranet', 'onlinepayment.quickpay.md5_secret', 'abc'); |
21
|
|
|
$kernel->setting->set('intranet', 'onlinepayment.quickpay.merchant_id', 12345678); |
22
|
|
|
return $kernel; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
function testConstruct() |
26
|
|
|
{ |
27
|
|
|
$this->markTestIncomplete( |
28
|
|
|
'This test has not been implemented yet - QP changed since.' |
29
|
|
|
); |
30
|
|
|
$onlinepayment = new OnlinePayment($this->createKernel()); |
31
|
|
|
$this->assertEquals('OnlinePayment', get_class($onlinepayment)); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
function testFactoryWithTypeProvider() |
35
|
|
|
{ |
36
|
|
|
$this->markTestIncomplete( |
37
|
|
|
'This test has not been implemented yet - QP changed since.' |
38
|
|
|
); |
39
|
|
|
$onlinepayment = OnlinePayment::factory($this->createKernel(), 'provider', 'quickpay'); |
40
|
|
|
$this->assertEquals('OnlinePaymentQuickPay', get_class($onlinepayment)); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
function testSaveWithEmptyArray() |
44
|
|
|
{ |
45
|
|
|
$this->markTestIncomplete( |
46
|
|
|
'This test has not been implemented yet - QP changed since.' |
47
|
|
|
); |
48
|
|
|
$onlinepayment = new OnlinePayment($this->createKernel()); |
49
|
|
|
$this->assertEquals(0, $onlinepayment->save(array())); |
50
|
|
|
$this->assertEquals(2, $onlinepayment->error->count()); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
function testSaveWithValidDataReturnsInteger() |
54
|
|
|
{ |
55
|
|
|
$this->markTestIncomplete( |
56
|
|
|
'This test has not been implemented yet - QP changed since.' |
57
|
|
|
); |
58
|
|
|
$onlinepayment = new OnlinePayment($this->createKernel()); |
59
|
|
|
$this->assertTrue($onlinepayment->save(array( |
60
|
|
|
'belong_to' => 'invoice', |
61
|
|
|
'belong_to_id' => 1, |
62
|
|
|
'transaction_number' => 1, |
63
|
|
|
'transaction_status' => '000', |
64
|
|
|
'amount' => 100)) > 0); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
function testUpdateWithValidDataReturnsInteger() |
68
|
|
|
{ |
69
|
|
|
$this->markTestIncomplete( |
70
|
|
|
'This test has not been implemented yet - QP changed since.' |
71
|
|
|
); |
72
|
|
|
$onlinepayment = new OnlinePayment($this->createKernel()); |
73
|
|
|
$data = array( |
74
|
|
|
'belong_to' => 'invoice', |
75
|
|
|
'belong_to_id' => 1, |
76
|
|
|
'transaction_number' => 1, |
77
|
|
|
'transaction_status' => '000', |
78
|
|
|
'amount' => 100, |
79
|
|
|
'original_amount' => 100, |
80
|
|
|
'dk_original_amount' => 100, |
81
|
|
|
'dk_amount' => 100); |
82
|
|
|
$this->assertTrue($onlinepayment->save($data) > 0); |
83
|
|
|
// $this->assertTrue($onlinepayment->setStatus('authorized')); |
|
|
|
|
84
|
|
|
$id = $onlinepayment->update($data); |
85
|
|
|
$this->assertTrue($id > 0); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
function testLoad() |
89
|
|
|
{ |
90
|
|
|
$this->markTestIncomplete( |
91
|
|
|
'This test has not been implemented yet - QP changed since.' |
92
|
|
|
); |
93
|
|
|
$onlinepayment = new OnlinePayment($this->createKernel()); |
94
|
|
|
$onlinepayment->save(array( |
95
|
|
|
'belong_to' => 'invoice', |
96
|
|
|
'belong_to_id' => 1, |
97
|
|
|
'transaction_number' => 1, |
98
|
|
|
'transaction_status' => '000', |
99
|
|
|
'amount' => 100)); |
100
|
|
|
|
101
|
|
|
$onlinepayment = new OnlinePayment($this->createKernel(), 1); |
102
|
|
|
|
103
|
|
|
$this->assertEquals(1, $onlinepayment->get('id')); |
104
|
|
|
$this->assertEquals(date('d-m-Y'), $onlinepayment->get('dk_date_created')); |
105
|
|
|
$this->assertEquals(2, $onlinepayment->get('belong_to_key')); |
106
|
|
|
$this->assertEquals('invoice', $onlinepayment->get('belong_to')); |
107
|
|
|
$this->assertEquals(1, $onlinepayment->get('belong_to_id')); |
108
|
|
|
$this->assertEquals('authorized', $onlinepayment->get('status')); |
109
|
|
|
$this->assertEquals(100, $onlinepayment->get('amount')); |
110
|
|
|
$this->assertEquals('100,00', $onlinepayment->get('dk_amount')); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
function testCreateReturnsAPaymentIdLargerThanZero() |
114
|
|
|
{ |
115
|
|
|
$this->markTestIncomplete( |
116
|
|
|
'This test has not been implemented yet - QP changed since.' |
117
|
|
|
); |
118
|
|
|
$onlinepayment = new OnlinePayment($this->createKernel()); |
119
|
|
|
$id = $onlinepayment->create(); |
120
|
|
|
$this->assertTrue($id > 0); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.