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

test_set_and_get_expiration_month()   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
 * Credit card 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;
12
13
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...
14
15
/**
16
 * Payment test
17
 *
18
 * @author Remco Tolsma
19
 * @version 1.0
20
 */
21
class CreditCardTest extends WP_UnitTestCase {
22
	/**
23
	 * Test construct payment object.
24
	 */
25
	public function test_construct() {
26
		$credit_card = new CreditCard();
27
28
		$this->assertInstanceOf( __NAMESPACE__ . '\CreditCard', $credit_card );
29
	}
30
31
	/** 
32
	 * Test setting and getting the credit card number.
33
	 */
34
	public function test_set_and_get_number() {
35
		$credit_card = new CreditCard();
36
37
		$number = '5300000000000006';
38
39
		$credit_card->set_number( $number );
40
41
		$this->assertEquals( $number, $credit_card->get_number() );
42
	}
43
44
	/** 
45
	 * Test setting and getting the credit card expiration month.
46
	 */
47
	public function test_set_and_get_expiration_month() {
48
		$credit_card = new CreditCard();
49
50
		$month = 12;
51
52
		$credit_card->set_expiration_month( $month );
53
54
		$this->assertEquals( $month, $credit_card->get_expiration_month() );
55
	}
56
57
	/** 
58
	 * Test setting and getting the credit card expiration year.
59
	 */
60
	public function test_set_and_get_expiration_year() {
61
		$credit_card = new CreditCard();
62
63
		$year = date( 'Y' ) + 5;
64
65
		$credit_card->set_expiration_year( $year );
66
67
		$this->assertEquals( $year, $credit_card->get_expiration_year() );
68
	}
69
70
	/** 
71
	 * Test setting and getting the credit card security code.
72
	 */
73
	public function test_set_and_get_security_code() {
74
		$credit_card = new CreditCard();
75
76
		$code = '123';
77
78
		$credit_card->set_security_code( $code );
0 ignored issues
show
Bug introduced by
$code of type string is incompatible with the type integer expected by parameter $security_code of Pronamic\WordPress\Pay\C...rd::set_security_code(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

78
		$credit_card->set_security_code( /** @scrutinizer ignore-type */ $code );
Loading history...
79
80
		$this->assertEquals( $code, $credit_card->get_security_code() );
81
	}
82
83
	/** 
84
	 * Test setting and getting the credit card name.
85
	 */
86
	public function test_set_and_get_name() {
87
		$credit_card = new CreditCard();
88
89
		$name = 'Pronamic';
90
91
		$credit_card->set_name( $name );
92
93
		$this->assertEquals( $name, $credit_card->get_name() );
94
	}
95
}
96