@@ 61-78 (lines=18) @@ | ||
58 | /** |
|
59 | * Test get payment status. |
|
60 | */ |
|
61 | public function test_get_payment_status() { |
|
62 | $config = new Config( Gateway::MODE_TEST, '123456', 'Test', '●●●●●●●●', '1' ); |
|
63 | ||
64 | $gateway = new Gateway( $config ); |
|
65 | ||
66 | $this->factory->fake( |
|
67 | 'https://stagconnect.acehubpaymentservices.com/gateway/v3/payments/00a502ba-d289-4ee1-a43e-3c4e1de76b4d', |
|
68 | __DIR__ . '/../http/get-payment-result-0.http' |
|
69 | ); |
|
70 | ||
71 | $payment = new Payment(); |
|
72 | ||
73 | $payment->set_transaction_id( '00a502ba-d289-4ee1-a43e-3c4e1de76b4d' ); |
|
74 | ||
75 | $gateway->update_status( $payment ); |
|
76 | ||
77 | $this->assertEquals( PaymentStatus::SUCCESS, $payment->get_status() ); |
|
78 | } |
|
79 | ||
80 | /** |
|
81 | * Test get payment status. |
|
@@ 83-103 (lines=21) @@ | ||
80 | /** |
|
81 | * Test get payment status. |
|
82 | */ |
|
83 | public function test_get_payment_status_fake() { |
|
84 | $config = new Config( Gateway::MODE_TEST, '123456', 'Test', '●●●●●●●●', '1' ); |
|
85 | ||
86 | $gateway = new Gateway( $config ); |
|
87 | ||
88 | $this->factory->fake( |
|
89 | 'https://stagconnect.acehubpaymentservices.com/gateway/v3/payments/00a502ba-d289-4ee1-a43e-3c4e1de76b4e', |
|
90 | __DIR__ . '/../http/get-payment-by-fake-id.http' |
|
91 | ); |
|
92 | ||
93 | $payment = new Payment(); |
|
94 | ||
95 | $payment->set_transaction_id( '00a502ba-d289-4ee1-a43e-3c4e1de76b4e' ); |
|
96 | ||
97 | $this->expectException( \Throwable::class ); |
|
98 | $this->expectExceptionMessage( |
|
99 | 'Could not JSON decode response, HTTP response: "404 Not Found", HTTP body length: "2", JSON error: "Syntax error".' |
|
100 | ); |
|
101 | ||
102 | $gateway->update_status( $payment ); |
|
103 | } |
|
104 | ||
105 | /** |
|
106 | * Test get payment empty body. |
|
@@ 108-126 (lines=19) @@ | ||
105 | /** |
|
106 | * Test get payment empty body. |
|
107 | */ |
|
108 | public function test_get_payment_empty_body() { |
|
109 | $config = new Config( Gateway::MODE_TEST, '123456', 'Test', '●●●●●●●●', '1' ); |
|
110 | ||
111 | $gateway = new Gateway( $config ); |
|
112 | ||
113 | $this->factory->fake( |
|
114 | 'https://stagconnect.acehubpaymentservices.com/gateway/v3/payments/00a502ba-d289-4ee1-a43e-3c4e1de76b4e', |
|
115 | __DIR__ . '/../http/get-payment-body-empty.http' |
|
116 | ); |
|
117 | ||
118 | $payment = new Payment(); |
|
119 | ||
120 | $payment->set_transaction_id( '00a502ba-d289-4ee1-a43e-3c4e1de76b4e' ); |
|
121 | ||
122 | $this->expectException( \Throwable::class ); |
|
123 | $this->expectExceptionMessage( 'Response is empty, HTTP response: "200 OK".' ); |
|
124 | ||
125 | $gateway->update_status( $payment ); |
|
126 | } |
|
127 | ||
128 | /** |
|
129 | * Test get payment no object. |
|
@@ 131-151 (lines=21) @@ | ||
128 | /** |
|
129 | * Test get payment no object. |
|
130 | */ |
|
131 | public function test_get_payment_no_object() { |
|
132 | $config = new Config( Gateway::MODE_TEST, '123456', 'Test', '●●●●●●●●', '1' ); |
|
133 | ||
134 | $gateway = new Gateway( $config ); |
|
135 | ||
136 | $this->factory->fake( |
|
137 | 'https://stagconnect.acehubpaymentservices.com/gateway/v3/payments/00a502ba-d289-4ee1-a43e-3c4e1de76b4e', |
|
138 | __DIR__ . '/../http/get-payment-no-object.http' |
|
139 | ); |
|
140 | ||
141 | $payment = new Payment(); |
|
142 | ||
143 | $payment->set_transaction_id( '00a502ba-d289-4ee1-a43e-3c4e1de76b4e' ); |
|
144 | ||
145 | $this->expectException( \Throwable::class ); |
|
146 | $this->expectExceptionMessage( |
|
147 | 'Could not JSON decode Payvision response to an object, HTTP response: "200 OK", HTTP body: "[]".' |
|
148 | ); |
|
149 | ||
150 | $gateway->update_status( $payment ); |
|
151 | } |
|
152 | ||
153 | /** |
|
154 | * Test WordPress error. |