TestNotificationParser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_init() 0 8 1
A test_parser() 0 6 1
A test_values() 0 8 1
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\IDealBasic;
4
5
use DateTime;
6
use Pronamic\WordPress\Pay\Gateways\IDeal\Statuses;
7
8
class TestNotificationParser extends \WP_UnitTestCase {
9
	public function test_init() {
10
		$filename = dirname( dirname( __FILE__ ) ) . '/Mock/notification.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
		$notification = XML\NotificationParser::parse( $simplexml );
26
27
		$this->assertInstanceOf( 'Pronamic\WordPress\Pay\Gateways\IDealBasic\Notification', $notification );
28
29
		return $notification;
30
	}
31
32
	/**
33
	 * Test values
34
	 *
35
	 * @depends test_parser
36
	 */
37
	public function test_values( $notification ) {
38
		$expected = new Notification();
39
		$expected->set_date( new DateTime( '20131022120742' ) );
40
		$expected->set_transaction_id( '0020000048638175' );
41
		$expected->set_purchase_id( '1382436458' );
42
		$expected->set_status( Statuses::SUCCESS );
43
44
		$this->assertEquals( $expected, $notification );
45
	}
46
}
47