-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathsite-create.feature
More file actions
202 lines (170 loc) · 6.57 KB
/
site-create.feature
File metadata and controls
202 lines (170 loc) · 6.57 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
Feature: Create a new site on a WP multisite
Scenario: Respect defined `$base` in wp-config
Given an empty directory
And WP files
And a database
And a extra-config file:
"""
define( 'WP_ALLOW_MULTISITE', true );
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
$base = '/dev/';
define( 'DOMAIN_CURRENT_SITE', 'localhost' );
define( 'PATH_CURRENT_SITE', '/dev/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
"""
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --extra-php < extra-config`
Then STDOUT should be:
"""
Success: Generated 'wp-config.php' file.
"""
# Old versions of WP can generate wpdb database errors if the WP tables don't exist, so STDERR may or may not be empty
When I try `wp core multisite-install --url=localhost/dev/ --title=Test --admin_user=admin --admin_email=admin@example.org`
Then STDOUT should contain:
"""
Success: Network installed. Don't forget to set up rewrite rules
"""
And the return code should be 0
When I run `wp site list --fields=blog_id,url`
Then STDOUT should be a table containing rows:
| blog_id | url |
| 1 | http://localhost/dev/ |
When I run `wp site create --slug=newsite`
Then STDOUT should be:
"""
Success: Site 2 created: http://localhost/dev/newsite/
"""
When I run `wp site list --fields=blog_id,url`
Then STDOUT should be a table containing rows:
| blog_id | url |
| 1 | http://localhost/dev/ |
| 2 | http://localhost/dev/newsite/ |
Scenario: Create new site with custom `$super_admins` global
Given an empty directory
And WP files
And a database
And a extra-config file:
"""
define( 'WP_ALLOW_MULTISITE', true );
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
define( 'DOMAIN_CURRENT_SITE', 'localhost' );
define( 'PATH_CURRENT_SITE', '/' );
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
$super_admins = array( 1 => 'admin' );
"""
When I run `wp core config {CORE_CONFIG_SETTINGS} --skip-check --extra-php < extra-config`
Then STDOUT should be:
"""
Success: Generated 'wp-config.php' file.
"""
# Old versions of WP can generate wpdb database errors if the WP tables don't exist, so STDERR may or may not be empty
When I try `wp core multisite-install --url=localhost --title=Test --admin_user=admin --admin_email=admin@example.org`
Then STDOUT should contain:
"""
Success: Network installed. Don't forget to set up rewrite rules
"""
And the return code should be 0
When I run `wp site list --fields=blog_id,url`
Then STDOUT should be a table containing rows:
| blog_id | url |
| 1 | http://localhost/ |
When I run `wp site create --slug=newsite`
Then STDOUT should be:
"""
Success: Site 2 created: http://localhost/newsite/
"""
When I run `wp site list --fields=blog_id,url`
Then STDOUT should be a table containing rows:
| blog_id | url |
| 1 | http://localhost/ |
| 2 | http://localhost/newsite/ |
Scenario: Create site with custom URL in subdomain multisite
Given a WP multisite subdomain install
When I run `wp site create --site-url=http://custom.example.com`
Then STDOUT should contain:
"""
Success: Site 2 created: http://custom.example.com/
"""
When I run `wp site list --fields=blog_id,url`
Then STDOUT should be a table containing rows:
| blog_id | url |
| 1 | https://example.com/ |
| 2 | http://custom.example.com/ |
When I run `wp --url=custom.example.com option get home`
Then STDOUT should be:
"""
http://custom.example.com
"""
Scenario: Create site with custom URL in subdirectory multisite
Given a WP multisite subdirectory install
When I run `wp site create --site-url=http://example.com/custom/path/`
Then STDOUT should contain:
"""
Success: Site 2 created:
"""
And STDOUT should contain:
"""
://example.com/custom/path/
"""
When I run `wp site list --fields=blog_id,url`
Then STDOUT should contain:
"""
://example.com/custom/path/
"""
Scenario: Create site with custom URL and explicit slug
Given a WP multisite subdomain install
When I run `wp site create --site-url=http://custom.example.com --slug=myslug`
Then STDOUT should contain:
"""
Success: Site 2 created: http://custom.example.com/
"""
Scenario: Error when neither slug nor site-url is provided
Given a WP multisite install
When I try `wp site create --title="Test Site"`
Then STDERR should be:
"""
Error: Either --slug or --site-url must be provided.
"""
And the return code should be 1
Scenario: Error when invalid URL format is provided
Given a WP multisite install
When I try `wp site create --site-url=not-a-valid-url`
Then STDERR should contain:
"""
Error: Invalid URL format
"""
And the return code should be 1
Scenario: Error when numeric-only domain is provided without slug
Given a WP multisite subdomain install
When I try `wp site create --site-url=http://123.example.com`
Then STDERR should be:
"""
Error: Could not derive a valid slug from the domain (numeric-only or empty slugs are not allowed). Please provide --slug explicitly.
"""
And the return code should be 1
Scenario: Create site with different domain in subdirectory multisite
Given a WP multisite subdirectory install
When I run `wp site create --site-url=http://custom.example.com/mypath/`
Then STDOUT should contain:
"""
Success: Site 2 created:
"""
And STDOUT should contain:
"""
://custom.example.com/mypath/
"""
Scenario: Preserve existing slug behavior
Given a WP multisite subdomain install
When I run `wp site create --slug=testsite`
Then STDOUT should contain:
"""
Success: Site 2 created: http://testsite.example.com/
"""
When I run `wp site list --fields=blog_id,url`
Then STDOUT should be a table containing rows:
| blog_id | url |
| 1 | https://example.com/ |
| 2 | http://testsite.example.com/ |