Make WordPress Core

Changeset 838 in tests


Ignore:
Timestamp:
07/01/2012 09:42:52 PM (12 years ago)
Author:
nacin
Message:

Introduce WP_UnitTest_Factory_For_Blog. see #82.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-testlib/factory.php

    r760 r838  
    66        $this->comment = new WP_UnitTest_Factory_For_Comment( $this );
    77        $this->user = new WP_UnitTest_Factory_For_User( $this );
     8        if ( is_multisite() )
     9            $this->blog = new WP_UnitTest_Factory_For_Blog( $this );
    810    }
    911}
     
    3840        $this->default_generation_definitions = array(
    3941            'user_login' => new WP_UnitTest_Generator_Sequence( 'User %s' ),
    40             'user_pass' => 'a',
     42            'user_pass' => 'password',
    4143            'user_email' => new WP_UnitTest_Generator_Sequence( 'user_%s@example.org' ),
    4244        );
     
    7981}
    8082
     83class WP_UnitTest_Factory_For_Blog extends WP_UnitTest_Factory_For_Thing {
     84
     85    function __construct( $factory = null ) {
     86        global $current_site;
     87        parent::__construct( $factory );
     88        $this->default_generation_definitions = array(
     89            'domain' => $current_site->domain,
     90            'path' => new WP_UnitTest_Generator_Sequence( 'testpath%s' ),
     91            'title' => new WP_UnitTest_Generator_Sequence( 'Site %s' ),
     92            'site_id' => $current_site->id,
     93        );
     94    }
     95
     96    function create_object( $args ) {
     97        $meta = isset( $args['meta'] ) ? $args['meta'] : array();
     98        $user_id = isset( $args['user_id'] ) ? $args['user_id'] : get_current_user_id();
     99        return wpmu_create_blog( $args['domain'], $args['path'], $args['title'], $user_id, $meta, $args['site_id'] );
     100    }
     101
     102    function update_object( $blog_id, $fields ) {}
     103}
    81104
    82105abstract class WP_UnitTest_Factory_For_Thing {
Note: See TracChangeset for help on using the changeset viewer.