TransactionTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 10
c 3
b 0
f 0
dl 0
loc 21
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A test() 0 17 1
1
<?php
2
/**
3
 * Transaction Test
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2022 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\Payvision
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Payvision;
12
13
/**
14
 * Transaction Test
15
 *
16
 * @author  Remco Tolsma
17
 * @version 1.1.0
18
 * @since   1.0.0
19
 */
20
class TransactionTest extends \WP_UnitTestCase {
21
	/**
22
	 * Test.
23
	 */
24
	public function test() {
25
		$transaction = new Transaction( '123456', 50, 'EUR', '12345678' );
0 ignored issues
show
Bug introduced by
'12345678' of type string is incompatible with the type Pronamic\WordPress\Pay\G...\Payvision\TrackingCode expected by parameter $tracking_code of Pronamic\WordPress\Pay\G...nsaction::__construct(). ( Ignorable by Annotation )

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

25
		$transaction = new Transaction( '123456', 50, 'EUR', /** @scrutinizer ignore-type */ '12345678' );
Loading history...
26
27
		$transaction->set_brand_id( BrandId::IDEAL );
28
		$transaction->set_purchase_id( 123456 );
29
		$transaction->set_return_url( 'https://example.com/' );
30
31
		$this->assertInstanceOf( Transaction::class, $transaction );
32
33
		$this->assertEquals( BrandId::IDEAL, $transaction->get_brand_id() );
34
35
		// JSON.
36
		$json_file = __DIR__ . '/../json/transaction-request.json';
37
38
		$json_string = \wp_json_encode( $transaction, \JSON_PRETTY_PRINT );
39
40
		$this->assertJsonStringEqualsJsonFile( $json_file, $json_string );
0 ignored issues
show
Bug introduced by
It seems like $json_string can also be of type false; however, parameter $actualJson of PHPUnit\Framework\Assert...nStringEqualsJsonFile() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

40
		$this->assertJsonStringEqualsJsonFile( $json_file, /** @scrutinizer ignore-type */ $json_string );
Loading history...
41
	}
42
}
43