mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Multisite: Add get_network_by_path() and wp_get_network() to begin cleanup of multisite load.
Tries to get network detection under control by simplifying wpmu_current_site(). It now also pops off each subdomain to find a more general match. Adds unit tests for get_network_by_path() and a new network factory for unit tests. Much of this is likely to change in 3.9 as more of ms-load.php and ms-settings.php gets hacked to bits. props jeremyfelt. see #27003. git-svn-id: https://develop.svn.wordpress.org/trunk@27178 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -42,6 +42,11 @@ class WP_UnitTest_Factory {
|
||||
*/
|
||||
public $blog;
|
||||
|
||||
/**
|
||||
* @var WP_UnitTest_Factory_For_Network
|
||||
*/
|
||||
public $network;
|
||||
|
||||
function __construct() {
|
||||
$this->post = new WP_UnitTest_Factory_For_Post( $this );
|
||||
$this->attachment = new WP_UnitTest_Factory_For_Attachment( $this );
|
||||
@@ -50,8 +55,10 @@ class WP_UnitTest_Factory {
|
||||
$this->term = new WP_UnitTest_Factory_For_Term( $this );
|
||||
$this->category = new WP_UnitTest_Factory_For_Term( $this, 'category' );
|
||||
$this->tag = new WP_UnitTest_Factory_For_Term( $this, 'post_tag' );
|
||||
if ( is_multisite() )
|
||||
if ( is_multisite() ) {
|
||||
$this->blog = new WP_UnitTest_Factory_For_Blog( $this );
|
||||
$this->network = new WP_UnitTest_Factory_For_Network( $this );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,6 +184,39 @@ class WP_UnitTest_Factory_For_Blog extends WP_UnitTest_Factory_For_Thing {
|
||||
}
|
||||
|
||||
|
||||
class WP_UnitTest_Factory_For_Network extends WP_UnitTest_Factory_For_Thing {
|
||||
|
||||
function __construct( $factory = null ) {
|
||||
parent::__construct( $factory );
|
||||
$this->default_generation_definitions = array(
|
||||
'domain' => WP_TESTS_DOMAIN,
|
||||
'title' => new WP_UnitTest_Generator_Sequence( 'Network %s' ),
|
||||
'path' => new WP_UnitTest_Generator_Sequence( '/testpath%s/' ),
|
||||
'network_id' => new WP_UnitTest_Generator_Sequence( '%s', 2 ),
|
||||
'subdomain_install' => false,
|
||||
);
|
||||
}
|
||||
|
||||
function create_object( $args ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
||||
|
||||
if ( ! isset( $args['user'] ) ) {
|
||||
$email = WP_TESTS_EMAIL;
|
||||
} else {
|
||||
$email = get_userdata( $args['user'] )->user_email;
|
||||
}
|
||||
|
||||
populate_network( $args['network_id'], $args['domain'], $email, $args['title'], $args['path'], $args['subdomain_install'] );
|
||||
return $args['network_id'];
|
||||
}
|
||||
|
||||
function update_object( $network_id, $fields ) {}
|
||||
|
||||
function get_object_by_id( $network_id ) {
|
||||
return wp_get_network( $network_id );
|
||||
}
|
||||
}
|
||||
|
||||
class WP_UnitTest_Factory_For_Term extends WP_UnitTest_Factory_For_Thing {
|
||||
|
||||
private $taxonomy;
|
||||
|
||||
Reference in New Issue
Block a user