Skip to content

Commit

Permalink
Merge pull request #432 from xknown/fix/custom-super-admins-global
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy authored Nov 10, 2023
2 parents 45d4f3a + e8257c6 commit 4218a3a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
48 changes: 48 additions & 0 deletions features/site-create.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,51 @@ Feature: Create a new site on a WP multisite
| 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} --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/ |
2 changes: 1 addition & 1 deletion src/Site_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public function create( $args, $assoc_args ) {
$email = '';
if ( ! empty( $super_admins ) && is_array( $super_admins ) ) {
// Just get the first one
$super_login = $super_admins[0];
$super_login = reset( $super_admins );
$super_user = get_user_by( 'login', $super_login );
if ( $super_user ) {
$email = $super_user->user_email;
Expand Down

0 comments on commit 4218a3a

Please sign in to comment.