Completed
Push — master ( 96a06a...b44fdc )
by Benjamin
07:18
created

APITest::test_rest_api_plugin_namespace_exists()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Class APITest
4
 *
5
 * @package WPSiteMonitor
6
 * @since 1.0.0
7
 */
8
9
use Tests\Test_Case;
10
11
/**
12
 * API test case.
13
 */
14
class APITest extends Test_Case {
15
16
	/**
17
	 * @var WP_REST_Server;
18
	 */
19
	protected $server;
20
21
	public function setUp() {
22
		parent::setUp();
23
24
		$this->server = rest_get_server();
25
	}
26
27
	/**
28
	 * Assert that REST API namespace for the plugin exists.
29
	 */
30
	public function test_rest_api_plugin_namespace_exists() {
31
		$namespaces = $this->server->get_namespaces();
32
33
		$this->assertContains( self::API_NAMESPACE, $namespaces );
34
	}
35
36
	/**
37
	 * Assert that WordPress version endpoint exists.
38
	 */
39
	public function test_wp_version_endpoint_exists() {
40
		$routes = $this->server->get_routes();
41
42
		$this->assertArrayHasKey( '/' . self::API_NAMESPACE . '/wp-version', $routes );
43
	}
44
}
45