Code Duplication    Length = 14-14 lines in 6 locations

tests/test-rest-post-statuses-controller.php 1 location

@@ 11-24 (lines=14) @@
8
		$this->assertArrayHasKey( '/wp/v2/statuses/(?P<status>[\w-]+)', $routes );
9
	}
10
11
	public function test_context_param() {
12
		// Collection
13
		$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/statuses' );
14
		$response = $this->server->dispatch( $request );
15
		$data = $response->get_data();
16
		$this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
17
		$this->assertEqualSets( array( 'embed', 'view', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
18
		// Single
19
		$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/statuses/publish' );
20
		$response = $this->server->dispatch( $request );
21
		$data = $response->get_data();
22
		$this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
23
		$this->assertEqualSets( array( 'embed', 'view', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
24
	}
25
26
	public function test_get_items() {
27
		$request = new WP_REST_Request( 'GET', '/wp/v2/statuses' );

tests/test-rest-post-types-controller.php 1 location

@@ 11-24 (lines=14) @@
8
		$this->assertArrayHasKey( '/wp/v2/types/(?P<type>[\w-]+)', $routes );
9
	}
10
11
	public function test_context_param() {
12
		// Collection
13
		$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/types' );
14
		$response = $this->server->dispatch( $request );
15
		$data = $response->get_data();
16
		$this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
17
		$this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] );
18
		// Single
19
		$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/types/post' );
20
		$response = $this->server->dispatch( $request );
21
		$data = $response->get_data();
22
		$this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
23
		$this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] );
24
	}
25
26
	public function test_get_items() {
27
		$request = new WP_REST_Request( 'GET', '/wp/v2/types' );

tests/test-rest-posts-controller.php 1 location

@@ 38-51 (lines=14) @@
35
		$this->assertCount( 3, $routes['/wp/v2/posts/(?P<id>[\d]+)'] );
36
	}
37
38
	public function test_context_param() {
39
		// Collection
40
		$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts' );
41
		$response = $this->server->dispatch( $request );
42
		$data = $response->get_data();
43
		$this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
44
		$this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
45
		// Single
46
		$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . $this->post_id );
47
		$response = $this->server->dispatch( $request );
48
		$data = $response->get_data();
49
		$this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
50
		$this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
51
	}
52
53
	public function test_registered_query_params() {
54
		$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts' );

tests/test-rest-taxonomies-controller.php 1 location

@@ 12-25 (lines=14) @@
9
		$this->assertArrayHasKey( '/wp/v2/taxonomies/(?P<taxonomy>[\w-]+)', $routes );
10
	}
11
12
	public function test_context_param() {
13
		// Collection
14
		$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/taxonomies' );
15
		$response = $this->server->dispatch( $request );
16
		$data = $response->get_data();
17
		$this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
18
		$this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] );
19
		// Single
20
		$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/taxonomies/post_tag' );
21
		$response = $this->server->dispatch( $request );
22
		$data = $response->get_data();
23
		$this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
24
		$this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] );
25
	}
26
27
	public function test_get_items() {
28
		$request = new WP_REST_Request( 'GET', '/wp/v2/taxonomies' );

tests/test-rest-users-controller.php 1 location

@@ 38-51 (lines=14) @@
35
		$this->assertArrayHasKey( '/wp/v2/users/me', $routes );
36
	}
37
38
	public function test_context_param() {
39
		// Collection
40
		$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' );
41
		$response = $this->server->dispatch( $request );
42
		$data = $response->get_data();
43
		$this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
44
		$this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
45
		// Single
46
		$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users/' . $this->user );
47
		$response = $this->server->dispatch( $request );
48
		$data = $response->get_data();
49
		$this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
50
		$this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
51
	}
52
53
	public function test_registered_query_params() {
54
		$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' );

tests/test-rest-comments-controller.php 1 location

@@ 67-80 (lines=14) @@
64
		$this->assertCount( 3, $routes['/wp/v2/comments/(?P<id>[\d]+)'] );
65
	}
66
67
	public function test_context_param() {
68
		// Collection
69
		$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' );
70
		$response = $this->server->dispatch( $request );
71
		$data = $response->get_data();
72
		$this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
73
		$this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
74
		// Single
75
		$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments/' . $this->approved_id );
76
		$response = $this->server->dispatch( $request );
77
		$data = $response->get_data();
78
		$this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] );
79
		$this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] );
80
	}
81
82
	public function test_registered_query_params() {
83
		$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' );