Repository navigation
Expand file tree
/
Copy pathability-category.feature
More file actions
173 lines (154 loc) · 4.9 KB
/
Copy pathability-category.feature
File metadata and controls
173 lines (154 loc) · 4.9 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
Feature: Manage ability categories registered via the WordPress Abilities API.
Background:
Given a WP install
@less-than-wp-6.9
Scenario: Require WordPress 6.9 or greater.
When I try `wp ability category list`
Then STDERR should contain:
"""
Error: Requires WordPress 6.9 or greater.
"""
@require-wp-6.9
Scenario: List ability categories.
Given a wp-content/mu-plugins/test-ability.php file:
"""
<?php
add_action(
'wp_abilities_api_categories_init',
function () {
wp_register_ability_category(
'test-content',
array(
'label' => 'Content',
'description' => 'Content management abilities.',
)
);
wp_register_ability_category(
'test-ai',
array(
'label' => 'AI',
'description' => 'AI-powered abilities.',
)
);
}
);
"""
When I run `wp ability category list`
Then STDOUT should be a table containing rows:
| slug | label | description |
| test-content | Content | Content management abilities. |
| test-ai | AI | AI-powered abilities. |
When I run `wp ability category list --field=slug`
Then STDOUT should contain:
"""
test-content
"""
And STDOUT should contain:
"""
test-ai
"""
When I run `wp ability category list --format=json`
Then STDOUT should contain:
"""
{"slug":"test-content"
"""
@require-wp-6.9
Scenario: Get ability category details.
Given a wp-content/mu-plugins/test-ability.php file:
"""
<?php
add_action(
'wp_abilities_api_categories_init',
function () {
wp_register_ability_category(
'test-content',
array(
'label' => 'Content',
'description' => 'Content management abilities.',
)
);
}
);
"""
When I run `wp ability category get test-content`
Then STDOUT should be a table containing rows:
| Field | Value |
| slug | test-content |
| label | Content |
| description | Content management abilities. |
When I run `wp ability category get test-content --field=label`
Then STDOUT should be:
"""
Content
"""
When I run `wp ability category get test-content --format=json`
Then STDOUT should be JSON containing:
"""
{"slug":"test-content"}
"""
When I try `wp ability category get nonexistent`
Then STDERR should be:
"""
Error: Ability category 'nonexistent' not found.
"""
@require-wp-6.9
Scenario: Check if ability category exists.
Given a wp-content/mu-plugins/test-ability.php file:
"""
<?php
add_action(
'wp_abilities_api_categories_init',
function () {
wp_register_ability_category(
'test-content',
array(
'label' => 'Content',
'description' => 'Content management abilities.',
)
);
}
);
"""
When I run `wp ability category exists test-content`
Then the return code should be 0
When I try `wp ability category exists nonexistent`
Then the return code should be 1
@require-wp-6.9
Scenario: Get ability category with meta.
Given a wp-content/mu-plugins/test-ability.php file:
"""
<?php
add_action(
'wp_abilities_api_categories_init',
function () {
wp_register_ability_category(
'custom-meta',
array(
'label' => 'Custom Meta Category',
'description' => 'A category with custom meta.',
'meta' => array(
'custom_key' => 'custom_value',
'version' => '1.0',
),
)
);
wp_register_ability_category(
'no-meta',
array(
'label' => 'No Meta Category',
'description' => 'A category without custom meta.',
)
);
}
);
"""
When I run `wp ability category get custom-meta --format=json`
Then STDOUT should be JSON containing:
"""
{"meta":"{\"custom_key\":\"custom_value\",\"version\":\"1.0\"}"}
"""
When I run `wp ability category get no-meta --field=meta`
Then STDOUT should be:
"""
{}
"""