Failed Conditions
Push — develop ( e1eaf3...e2a320 )
by Remco
04:21
created

tests/src/CurrencyTest.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * Currency Test
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2021 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Money
9
 */
10
11
namespace Pronamic\WordPress\Money;
12
13
use WP_Locale;
14
use WP_UnitTestCase;
15
16
/**
17
 * Currency Test
18
 *
19
 * @author Remco Tolsma
20
 * @version 1.2.2
21
 * @since   1.0.0
22
 */
23
class CurrencyTest extends WP_UnitTestCase {
24
	/**
25
	 * Test Euro.
26
	 */
27
	public function test_euro() {
28
		$currency = Currencies::get_currency( 'EUR' );
29
30
		$this->assertSame( '978', $currency->get_numeric_code() );
31
		$this->assertSame( 'Euro', $currency->get_name() );
32
		$this->assertJsonStringEqualsJsonString( '"EUR"', \wp_json_encode( $currency ) );
0 ignored issues
show
It seems like wp_json_encode($currency) can also be of type false; however, parameter $actualJson of PHPUnit\Framework\Assert...tringEqualsJsonString() 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

32
		$this->assertJsonStringEqualsJsonString( '"EUR"', /** @scrutinizer ignore-type */ \wp_json_encode( $currency ) );
Loading history...
33
	}
34
35
	/**
36
	 * Test invalid alphabetic code.
37
	 */
38
	public function test_invalid_alphabetic_code() {
39
		$alphabetic_code = 'ABCDEF';
40
41
		$this->expectException( \InvalidArgumentException::class );
42
43
		$currency = new Currency( 'ABCDEF' );
44
	}
45
}
46