-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathsite-empty.feature
More file actions
130 lines (106 loc) · 4.2 KB
/
site-empty.feature
File metadata and controls
130 lines (106 loc) · 4.2 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
Feature: Empty a WordPress site of its data
@require-mysql
Scenario: Empty a site
Given a WP installation
And I run `wp option update uploads_use_yearmonth_folders 0`
And download:
| path | url |
| {CACHE_DIR}/large-image.jpg | http://wp-cli.org/behat-data/large-image.jpg |
And a insert_link_data.sql file:
"""
INSERT INTO `wp_links` (`link_url`, `link_name`, `link_image`, `link_target`, `link_description`, `link_visible`, `link_owner`, `link_rating`, `link_rel`, `link_notes`, `link_rss`)
VALUES ('http://wordpress.org/', 'test', '', '', 'test', 'Y', 1, 0, '', '', '')
"""
When I run `wp db query "SOURCE insert_link_data.sql;"`
Then STDERR should be empty
When I run `wp db query "SELECT COUNT(link_id) FROM wp_links;"`
Then STDOUT should be:
"""
COUNT(link_id)
1
"""
When I run `wp media import {CACHE_DIR}/large-image.jpg --post_id=1`
Then the wp-content/uploads/large-image.jpg file should exist
When I try `wp site url 1`
Then STDERR should be:
"""
Error: This is not a multisite installation.
"""
And the return code should be 1
When I run `wp post create --post_title='Test post' --post_content='Test content.'`
Then STDOUT should contain:
"""
Success: Created post
"""
When I run `wp term create post_tag 'Test term' --slug=test --description='This is a test term'`
Then STDOUT should be:
"""
Success: Created post_tag 2.
"""
When I run `wp post create --post_type=page --post_title='Sample Privacy Page' --post_content='Sample Privacy Terms' --porcelain`
Then save STDOUT as {PAGE_ID}
When I run `wp option set wp_page_for_privacy_policy {PAGE_ID}`
Then STDOUT should be:
"""
Success: Updated 'wp_page_for_privacy_policy' option.
"""
When I run `wp option get wp_page_for_privacy_policy`
Then STDOUT should be:
"""
{PAGE_ID}
"""
When I run `wp post create --post_title='Sticky Post' --post_content='This is just a sticky post' --porcelain`
Then save STDOUT as {STICKY_POST_ID}
When I run `wp option set sticky_posts '[{STICKY_POST_ID}]' --format=json`
Then STDOUT should be:
"""
Success: Updated 'sticky_posts' option.
"""
When I run `wp site empty --yes`
Then STDOUT should be:
"""
Success: The site at 'http://example.com' was emptied.
"""
And the wp-content/uploads/large-image.jpg file should exist
When I run `wp post list --format=ids`
Then STDOUT should be empty
When I run `wp term list post_tag --format=ids`
Then STDOUT should be empty
When I run `wp option get wp_page_for_privacy_policy`
Then STDOUT should be:
"""
0
"""
When I run `wp option get sticky_posts --format=json`
Then STDOUT should be:
"""
[]
"""
When I run `wp db query "SELECT COUNT(link_id) FROM wp_links;"`
Then STDOUT should be:
"""
COUNT(link_id)
0
"""
Scenario: Empty a site and its uploads directory
Given a WP multisite installation
And I run `wp site create --slug=foo`
And I run `wp --url=example.com/foo option update uploads_use_yearmonth_folders 0`
And download:
| path | url |
| {CACHE_DIR}/large-image.jpg | http://wp-cli.org/behat-data/large-image.jpg |
When I run `wp --url=example.com/foo media import {CACHE_DIR}/large-image.jpg --post_id=1`
Then the wp-content/uploads/sites/2/large-image.jpg file should exist
When I run `wp site empty --uploads --yes`
Then STDOUT should not be empty
And the wp-content/uploads/sites/2/large-image.jpg file should exist
When I run `wp post list --format=ids`
Then STDOUT should be empty
When I run `wp --url=example.com/foo site empty --uploads --yes`
Then STDOUT should contain:
"""
://example.com/foo' was emptied.
"""
And the wp-content/uploads/sites/2/large-image.jpg file should not exist
When I run `wp --url=example.com/foo post list --format=ids`
Then STDOUT should be empty