|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\MultiSafepay; |
|
4
|
|
|
|
|
5
|
|
|
use stdClass; |
|
6
|
|
|
use WP_UnitTestCase; |
|
7
|
|
|
|
|
8
|
|
|
class StatusParserTest extends WP_UnitTestCase { |
|
9
|
|
|
public function test_init() { |
|
10
|
|
|
$filename = dirname( dirname( __FILE__ ) ) . '/Mock/status-response.xml'; |
|
11
|
|
|
|
|
12
|
|
|
$simplexml = simplexml_load_file( $filename ); |
|
13
|
|
|
|
|
14
|
|
|
$this->assertInstanceOf( 'SimpleXMLElement', $simplexml ); |
|
15
|
|
|
|
|
16
|
|
|
return $simplexml; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Test parser |
|
21
|
|
|
* |
|
22
|
|
|
* @depends test_init |
|
23
|
|
|
*/ |
|
24
|
|
|
public function test_parser( $simplexml ) { |
|
25
|
|
|
$message = XML\StatusResponseMessage::parse( $simplexml ); |
|
26
|
|
|
|
|
27
|
|
|
$this->assertInstanceOf( __NAMESPACE__ . '\XML\StatusResponseMessage', $message ); |
|
28
|
|
|
|
|
29
|
|
|
return $message; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Test values |
|
34
|
|
|
* |
|
35
|
|
|
* @depends test_parser |
|
36
|
|
|
*/ |
|
37
|
|
|
public function test_values( $message ) { |
|
38
|
|
|
$expected = new XML\StatusResponseMessage(); |
|
39
|
|
|
|
|
40
|
|
|
$expected->result = 'ok'; |
|
41
|
|
|
|
|
42
|
|
|
// E-wallet |
|
43
|
|
|
$ewallet = new stdClass(); |
|
44
|
|
|
|
|
45
|
|
|
$ewallet->id = '12345'; |
|
46
|
|
|
$ewallet->status = 'completed'; |
|
47
|
|
|
$ewallet->created = '20070723171623'; |
|
48
|
|
|
$ewallet->modified = '20070903155907'; |
|
49
|
|
|
$ewallet->reason_code = null; |
|
50
|
|
|
$ewallet->reason = null; |
|
51
|
|
|
|
|
52
|
|
|
$expected->ewallet = $ewallet; |
|
53
|
|
|
|
|
54
|
|
|
// Customer |
|
55
|
|
|
$customer = new stdClass(); |
|
56
|
|
|
|
|
57
|
|
|
$customer->currency = 'EUR'; |
|
58
|
|
|
$customer->amount = '1000'; |
|
59
|
|
|
$customer->exchange_rate = '1'; |
|
60
|
|
|
$customer->first_name = 'First'; |
|
61
|
|
|
$customer->last_name = 'Last'; |
|
62
|
|
|
$customer->city = 'City'; |
|
63
|
|
|
$customer->state = null; |
|
64
|
|
|
$customer->country = 'NL'; |
|
65
|
|
|
|
|
66
|
|
|
$expected->customer = $customer; |
|
67
|
|
|
|
|
68
|
|
|
// Transaction |
|
69
|
|
|
$transaction = new stdClass(); |
|
70
|
|
|
|
|
71
|
|
|
$transaction->id = 'ABCD1234'; |
|
72
|
|
|
$transaction->currency = 'EUR'; |
|
73
|
|
|
$transaction->amount = '1000'; |
|
74
|
|
|
$transaction->description = 'My Description'; |
|
75
|
|
|
$transaction->var1 = null; |
|
76
|
|
|
$transaction->var2 = null; |
|
77
|
|
|
$transaction->var3 = null; |
|
78
|
|
|
$transaction->items = 'My Items'; |
|
79
|
|
|
|
|
80
|
|
|
$expected->transaction = $transaction; |
|
81
|
|
|
|
|
82
|
|
|
// Payment Details |
|
83
|
|
|
$payment_details = new stdClass(); |
|
84
|
|
|
|
|
85
|
|
|
$payment_details->type = 'IDEAL'; |
|
86
|
|
|
$payment_details->account_iban = null; |
|
87
|
|
|
$payment_details->account_bic = null; |
|
88
|
|
|
$payment_details->account_id = null; |
|
89
|
|
|
$payment_details->account_holder_name = null; |
|
90
|
|
|
$payment_details->external_transaction_id = null; |
|
91
|
|
|
|
|
92
|
|
|
$expected->payment_details = $payment_details; |
|
93
|
|
|
|
|
94
|
|
|
$this->assertEquals( $expected, $message ); |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|