-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathuser-term.feature
More file actions
114 lines (93 loc) · 2.82 KB
/
user-term.feature
File metadata and controls
114 lines (93 loc) · 2.82 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
Feature: Manage user term
Scenario: Userterm CRUD
Given a WP install
And a wp-content/plugins/test-add-tax/plugin.php file:
"""
<?php
// Plugin Name: Test Add Tax
function add_cli_tax(){
register_taxonomy( 'user_type', 'user' );
}
add_action('init','add_cli_tax');
"""
And I run `wp plugin activate test-add-tax`
When I run `wp user term add 1 user_type foo`
Then STDOUT should be:
"""
Success: Added term.
"""
When I run `wp user term list 1 user_type --fields=name,slug,taxonomy`
Then STDOUT should be a table containing rows:
| name | slug | taxonomy |
| foo | foo | user_type |
When I run `wp user term add 1 user_type bar`
Then STDOUT should be:
"""
Success: Added term.
"""
When I run `wp user term list 1 user_type --fields=name,slug,taxonomy`
Then STDOUT should be a table containing rows:
| name | slug | taxonomy |
| foo | foo | user_type |
| bar | bar | user_type |
When I run `wp user term list 1 user_type --format=ids`
Then STDOUT should be:
"""
3 2
"""
When I run `wp user term set 1 user_type new`
Then STDOUT should be:
"""
Success: Set term.
"""
When I run `wp user term list 1 user_type --fields=name,slug,taxonomy --format=count`
Then STDOUT should be:
"""
1
"""
When I run `wp user term remove 1 user_type new`
Then STDOUT should be:
"""
Success: Removed term.
"""
When I run `wp user term list 1 user_type --fields=name,slug,taxonomy --format=count`
Then STDOUT should be:
"""
0
"""
Scenario: Multiple user term
Given a WP install
And a wp-content/plugins/test-add-tax/plugin.php file:
"""
<?php
// Plugin Name: Test Add Tax
function add_cli_tax(){
register_taxonomy( 'user_type', 'user' );
}
add_action('init','add_cli_tax');
"""
And I run `wp plugin activate test-add-tax`
When I run `wp user term add 1 user_type apple`
And I run `wp user term add 1 user_type apple`
Then STDOUT should contain:
"""
Success: Added term.
"""
When I run `wp user term set 1 user_type apple1 apple2`
Then STDOUT should contain:
"""
Success: Set terms.
"""
When I run `wp user term list 1 user_type --format=json --fields=name,slug,taxonomy`
Then STDOUT should contain:
"""
[{"name":"apple1","slug":"apple1","taxonomy":"user_type"},{"name":"apple2","slug":"apple2","taxonomy":"user_type"}]
"""
Scenario: Userterm Add invalid tax
Given a WP install
When I try `wp user term add 1 boo foo2`
Then the return code should be 1
And STDERR should be:
"""
Error: Invalid taxonomy boo.
"""