-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwp-graphql-filter-query.test.php
87 lines (80 loc) · 2.07 KB
/
wp-graphql-filter-query.test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
use function WPGraphQL\FILTER_QUERY\filter_query_get_supported_post_types;
class Wp_GraphqlFilterQueryTest extends WP_UnitTestCase {
protected function setUp(): void {
register_post_type(
'zombie',
array(
'labels' => array(
'name' => 'Zombies',
),
'public' => true,
'capability_type' => 'post',
'map_meta_cap' => false,
/** WP GRAPHQL */
'show_in_graphql' => true,
'hierarchical' => true,
'graphql_single_name' => 'zombie',
'graphql_plural_name' => 'zombies',
)
);
register_post_type(
'vampire',
array(
'labels' => array(
'name' => 'Vampires',
),
'public' => true,
'capability_type' => 'post',
'map_meta_cap' => false,
/** WP GRAPHQL */
'show_in_graphql' => true,
'hierarchical' => true,
'graphql_single_name' => 'vampire',
'graphql_plural_name' => 'vampires',
)
);
register_post_type(
'rabbit',
array(
'labels' => array(
'name' => 'Rabbits',
),
'public' => true,
'capability_type' => 'post',
'map_meta_cap' => false,
/** WP GRAPHQL */
'show_in_graphql' => false,
'hierarchical' => true,
'graphql_single_name' => 'rabbit',
'graphql_plural_name' => 'rabbits',
)
);
}
public function test_filter_query_get_supported_post_types() {
$post_types = filter_query_get_supported_post_types();
$expected_types = [
'post' => [
'name' => 'post',
'capitalize_name' => 'Post',
'plural_name' => 'posts',
],
'page' => [
'name' => 'page',
'capitalize_name' => 'Page',
'plural_name' => 'pages',
],
'zombie' => [
'name' => 'zombie',
'capitalize_name' => 'Zombie',
'plural_name' => 'zombies',
],
'vampire' => [
'name' => 'vampire',
'capitalize_name' => 'Vampire',
'plural_name' => 'vampires',
],
];
$this->assertEquals( $expected_types, $post_types );
}
}