Failed Conditions
Push — develop ( 85c02b...acd263 )
by Remco
04:09
created

tests/src/XML/OrderResponseParser0Test.php (2 issues)

1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\Ingenico\XML;
4
5
use Pronamic\WordPress\Pay\Gateways\Ingenico\DirectLink\OrderResponse;
6
7
class OrderResponseParser0Test extends \WP_UnitTestCase {
8
	/**
9
	 * Test initialize.
10
	 *
11
	 * @return SimpleXMLElement
0 ignored issues
show
The type Pronamic\WordPress\Pay\G...co\XML\SimpleXMLElement was not found. Did you mean SimpleXMLElement? If so, make sure to prefix the type with \.
Loading history...
12
	 */
13
	public function test_init() {
14
		$filename = dirname( dirname( dirname( __FILE__ ) ) ) . '/Mock/response-status-0-50001123.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
The expression return $simplexml returns the type SimpleXMLElement which is incompatible with the documented return type Pronamic\WordPress\Pay\G...co\XML\SimpleXMLElement.
Loading history...
21
	}
22
23
	/**
24
	 * Test parser.
25
	 *
26
	 * @depends test_init
27
	 *
28
	 * @param SimpleXMLElement $simplexml
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
46
	 */
47
	public function test_values( $order_response ) {
48
		$expected                = new OrderResponse();
49
		$expected->order_id      = '52';
50
		$expected->pay_id        = '0';
51
		$expected->nc_error      = '50001123';
52
		$expected->status        = '0';
53
		$expected->nc_error_plus = 'Card type not active for the merchant';
54
55
		$this->assertEquals( $expected, $order_response );
56
	}
57
}
58