Passed
Push — develop ( ff447e...e7f3f0 )
by Remco
04:02
created

PaymentTest::test_set_and_get_consumer_bic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Payment test
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2018 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Payments
9
 */
10
11
namespace Pronamic\WordPress\Pay\Payments;
12
13
use Pronamic\WordPress\Pay\CreditCard;
14
use stdClass;
15
use WP_UnitTestCase;
0 ignored issues
show
Bug introduced by
The type WP_UnitTestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
17
/**
18
 * Payment test
19
 *
20
 * @author Remco Tolsma
21
 * @version 1.0
22
 */
23
class PaymentTest extends WP_UnitTestCase {
24
	/**
25
	 * Test construct payment object.
26
	 */
27
	public function test_construct() {
28
		$payment = new Payment();
29
30
		$this->assertInstanceOf( __NAMESPACE__ . '\Payment', $payment );
31
	}
32
33
	/**
34
	 * Test getting no payment.
35
	 *
36
	 * @see https://github.com/easydigitaldownloads/easy-digital-downloads/blob/2.8.18/tests/tests-payment-class.php#L70-L79
37
	 */
38
	public function test_getting_no_payment() {
39
		$payment = new Payment();
40
41
		$this->assertNull( $payment->get_id() );
42
	}
43
44
	/** 
45
	 * Test setting and getting the payment ID.
46
	 */
47
	public function test_set_and_get_id() {
48
		$payment = new Payment();
49
50
		$id = uniqid();
51
52
		$payment->set_id( $id );
53
54
		$this->assertEquals( $id, $payment->get_id() );
55
	}
56
57
	/** 
58
	 * Test setting and getting the payment transaction ID.
59
	 */
60
	public function test_set_and_get_transaction_id() {
61
		$payment = new Payment();
62
63
		$transaction_id = uniqid();
64
65
		$payment->set_transaction_id( $transaction_id );
66
67
		$this->assertEquals( $transaction_id, $payment->get_transaction_id() );
68
	}
69
70
	/** 
71
	 * Test setting and getting the payment status.
72
	 */
73
	public function test_set_and_get_status() {
74
		$payment = new Payment();
75
76
		$status = 'completed';
77
78
		$payment->set_status( $status );
79
80
		$this->assertEquals( $status, $payment->get_status() );
81
	}
82
83
	/**
84
	 * Test setting and getting the payment consumer name.
85
	 */
86
	public function test_set_and_get_consumer_name() {
87
		$payment = new Payment();
88
89
		$name = 'John Doe';
90
91
		$payment->set_consumer_name( $name );
92
93
		$this->assertEquals( $name, $payment->consumer_name );
94
	}
95
96
	/**
97
	 * Test setting and getting the payment consumer account number.
98
	 */
99
	public function test_set_and_get_consumer_account_number() {
100
		$payment = new Payment();
101
102
		$number = '1086.34.779';
103
104
		$payment->set_consumer_account_number( $number );
105
106
		$this->assertEquals( $number, $payment->consumer_account_number );
107
	}
108
109
	/**
110
	 * Test setting and getting the payment consumer IBAN.
111
	 */
112
	public function test_set_and_get_consumer_iban() {
113
		$payment = new Payment();
114
115
		$iban = 'NL56 RABO 0108 6347 79';
116
117
		$payment->set_consumer_iban( $iban );
118
119
		$this->assertEquals( $iban, $payment->consumer_iban );
120
	}
121
122
	/**
123
	 * Test setting and getting the payment consumer BIC.
124
	 */
125
	public function test_set_and_get_consumer_bic() {
126
		$payment = new Payment();
127
128
		$bic = 'RABONL2U';
129
130
		$payment->set_consumer_bic( $bic );
131
132
		$this->assertEquals( $bic, $payment->consumer_bic );
133
	}
134
135
	/**
136
	 * Test setting and getting the payment consumer city.
137
	 */
138
	public function test_set_and_get_consumer_city() {
139
		$payment = new Payment();
140
141
		$city = 'Drachten';
142
143
		$payment->set_consumer_city( $city );
144
145
		$this->assertEquals( $city, $payment->consumer_city );
146
	}
147
148
	/**
149
	 * Test setting and getting the payment credit card.
150
	 */
151
	public function test_set_and_get_credit_card() {
152
		$payment = new Payment();
153
154
		$credit_card = new CreditCard();
155
		$credit_card->set_number( '5300000000000006' );
156
		$credit_card->set_expiration_month( 12 );
157
		$credit_card->set_expiration_year( date( 'Y' ) + 5 );
158
		$credit_card->set_security_code( '123' );
159
		$credit_card->set_name( 'Pronamic' );
160
161
		$payment->set_credit_card( $credit_card );
162
163
		$this->assertEquals( $credit_card, $payment->get_credit_card() );
164
	}
165
}
166