1 | <?php |
||
2 | |||
3 | namespace Pronamic\WordPress\Pay\Gateways\Ingenico\XML; |
||
4 | |||
5 | use Pronamic\WordPress\Pay\Gateways\Ingenico\DirectLink\OrderResponse; |
||
6 | |||
7 | class OrderResponseParser46Test extends \WP_UnitTestCase { |
||
8 | /** |
||
9 | * Test initialize. |
||
10 | * |
||
11 | * @return SimpleXMLElement |
||
12 | */ |
||
13 | public function test_init() { |
||
14 | $filename = dirname( dirname( dirname( __FILE__ ) ) ) . '/Mock/response-status-46.xml'; |
||
15 | |||
16 | $simplexml = simplexml_load_file( $filename ); |
||
17 | |||
18 | $this->assertInstanceOf( 'SimpleXMLElement', $simplexml ); |
||
19 | |||
20 | return $simplexml; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
21 | } |
||
22 | |||
23 | /** |
||
24 | * Test parser. |
||
25 | * |
||
26 | * @depends test_init |
||
27 | * |
||
28 | * @param SimpleXMLElement $simplexml XML element. |
||
29 | * |
||
30 | * @return OrderResponse |
||
31 | */ |
||
32 | public function test_parser( $simplexml ) { |
||
33 | $order_response = OrderResponseParser::parse( $simplexml ); |
||
34 | |||
35 | $this->assertInstanceOf( 'Pronamic\WordPress\Pay\Gateways\Ingenico\DirectLink\OrderResponse', $order_response ); |
||
36 | |||
37 | return $order_response; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Test values. |
||
42 | * |
||
43 | * @depends test_parser |
||
44 | * |
||
45 | * @param OrderResponse $order_response Order response. |
||
46 | */ |
||
47 | public function test_values( $order_response ) { |
||
48 | $filename = dirname( dirname( dirname( __FILE__ ) ) ) . '/Mock/response-status-46-html-answer.html'; |
||
49 | |||
50 | $expected = new OrderResponse(); |
||
51 | $expected->order_id = '1387195001'; |
||
52 | $expected->pay_id = '26187584'; |
||
53 | $expected->nc_error = '0'; |
||
54 | $expected->status = '46'; |
||
55 | $expected->nc_error_plus = 'Identification requested'; |
||
56 | $expected->html_answer = file_get_contents( $filename, true ); |
||
57 | |||
58 | $this->assertEquals( $expected, $order_response ); |
||
59 | } |
||
60 | } |
||
61 |