Completed
Push — renovate/dealerdirect-phpcodes... ( 14797c...4cde9a )
by
unknown
27:42 queued 19:25
created

test_get_jetpack_api_version_with_constant()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2
/**
3
 * The UtilsTest class file.
4
 *
5
 * @package automattic/jetpack-connection
6
 */
7
8
namespace Automattic\Jetpack\Connection;
9
10
use Automattic\Jetpack\Constants;
11
use PHPUnit\Framework\TestCase;
12
13
/**
14
 * Provides unit tests for the methods in the Utils class.
15
 */
16
class UtilsTest extends TestCase {
17
18
	/**
19
	 * This method is called after each test.
20
	 */
21
	public function tearDown() {
22
		Constants::clear_constants();
23
	}
24
25
	/**
26
	 * Utils::get_jetpack_api_version should return the JETPACK__API_VERSION
27
	 * constant when the constant is defined.
28
	 *
29
	 *  @covers Automattic\Jetpack\Connection\Utils::get_jetpack_api_version
30
	 */
31
	public function test_get_jetpack_api_version_with_constant() {
32
		$test_constant_value = 3;
33
		Constants::set_constant( 'JETPACK__API_VERSION', $test_constant_value );
34
		$this->assertEquals( $test_constant_value, Utils::get_jetpack_api_version() );
35
	}
36
37
	/**
38
	 * Utils::get_jetpack_api_version should return the default Jetpack API version
39
	 * value when the JETPACK__API_VERSION constant is not defined.
40
	 */
41
	public function test_get_jetpack_api_version_without_constant() {
42
		$this->assertEquals( Utils::DEFAULT_JETPACK_API_VERSION, Utils::get_jetpack_api_version() );
43
	}
44
}
45