-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathtaxonomy.feature
More file actions
128 lines (109 loc) · 5.6 KB
/
taxonomy.feature
File metadata and controls
128 lines (109 loc) · 5.6 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
Feature: Manage WordPress taxonomies
Background:
Given a WP install
@require-wp-3.7
Scenario: Listing taxonomies
When I run `wp taxonomy list --format=csv`
Then STDOUT should be CSV containing:
| name | label | description | object_type | show_tagcloud | hierarchical | public |
| category | Categories | | post | true | true | true |
| post_tag | Tags | | post | true | false | true |
When I run `wp taxonomy list --object_type=nav_menu_item --format=csv`
Then STDOUT should be CSV containing:
| name | label | description | object_type | show_tagcloud | hierarchical | public |
| nav_menu | Navigation Menus | | nav_menu_item | false | false | false |
@require-wp-5.0
Scenario: Listing taxonomies with counts
When I run `wp taxonomy list --fields=name,count --format=csv`
Then STDOUT should be CSV containing:
| name | count |
| category | 1 |
| post_tag | 0 |
Scenario: Get taxonomy
When I try `wp taxonomy get invalid-taxonomy`
Then STDERR should be:
"""
Error: Taxonomy invalid-taxonomy doesn't exist.
"""
And the return code should be 1
When I run `wp taxonomy get category`
Then STDOUT should be a table containing rows:
| Field | Value |
| name | category |
| object_type | ["post"] |
| label | Categories |
@require-wp-5.0
Scenario: Get taxonomy with count
When I run `wp taxonomy get category --fields=name,count`
Then STDOUT should be a table containing rows:
| Field | Value |
| name | category |
| count | 1 |
@require-wp-5.1
Scenario: Listing taxonomies with strict/no-strict mode
Given a WP installation
And a wp-content/mu-plugins/test-taxonomy-list.php file:
"""
<?php
// Plugin Name: Test Taxonomy Strict/No-Strict Mode
add_action( 'init', function() {
$args = array(
'hierarchical' => true,
'show_ui' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'labels' => array(
'name' => _x( 'Genres', 'taxonomy general name', 'textdomain' ),
),
);
register_taxonomy( 'genres', array( 'post','page' ), $args );
} );
"""
When I run `wp taxonomy list --object_type=post --strict`
Then STDOUT should be a table containing rows:
| name | label | description | object_type | show_tagcloud | hierarchical | public |
| category | Categories | | post | true | true | true |
| post_tag | Tags | | post | true | false | true |
| post_format | Formats | | post | false | false | true |
When I run `wp taxonomy list --object_type=post --no-strict`
Then STDOUT should be a table containing rows:
| name | label | description | object_type | show_tagcloud | hierarchical | public |
| category | Categories | | post | true | true | true |
| post_tag | Tags | | post | true | false | true |
| post_format | Formats | | post | false | false | true |
| genres | Genres | | post, page | true | true | true |
@less-than-wp-5.1
Scenario: Listing taxonomies with strict/no-strict mode (for WP < 5.1)
Given a WP installation
And a wp-content/mu-plugins/test-taxonomy-list.php file:
"""
<?php
// Plugin Name: Test Taxonomy Strict/No-Strict Mode
add_action( 'init', function() {
$args = array(
'hierarchical' => true,
'show_ui' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'labels' => array(
'name' => _x( 'Genres', 'taxonomy general name', 'textdomain' ),
),
);
register_taxonomy( 'genres', array( 'post','page' ), $args );
} );
"""
When I run `wp taxonomy list --object_type=post --strict`
Then STDOUT should be a table containing rows:
| name | label | description | object_type | show_tagcloud | hierarchical | public |
| category | Categories | | post | true | true | true |
| post_tag | Tags | | post | true | false | true |
| post_format | Format | | post | false | false | true |
When I run `wp taxonomy list --object_type=post --no-strict`
Then STDOUT should be a table containing rows:
| name | label | description | object_type | show_tagcloud | hierarchical | public |
| category | Categories | | post | true | true | true |
| post_tag | Tags | | post | true | false | true |
| post_format | Format | | post | false | false | true |
| genres | Genres | | post, page | true | true | true |