Make WordPress Core

Ticket #20950: 20950-ut.diff

File 20950-ut.diff, 1.9 KB (added by ryan, 11 years ago)

Unit tests and blog factory fix

  • tests/ms.php

     
    1919                        $this->assertInternalType( 'int', $blog_id );
    2020                        $prefix = $wpdb->get_blog_prefix( $blog_id );
    2121
     22                        $details = get_blog_details( $blog_id, false );
     23                        $this->assertEquals( $blog_id, get_id_from_blogname( $details->path ) );
     24                        $this->assertEquals( $blog_id, wp_cache_get( 'get_id_from_blogname_' . trim( $details->path, '/' ), 'blog-details' ) );
     25
    2226                        foreach ( $wpdb->tables( 'blog', false ) as $table ) {
    2327                                $wpdb->suppress_errors();
    2428                                $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
     
    4145                foreach ( $blog_ids as $blog_id ) {
    4246                        // drop tables for every second blog
    4347                        $drop_tables = ! $drop_tables;
     48                        $details = get_blog_details( $blog_id, false );
    4449                        wpmu_delete_blog( $blog_id, $drop_tables );
    4550
     51                        $this->assertEquals( false, wp_cache_get( 'get_id_from_blogname_' . trim( $details->path, '/' ), 'blog-details' ) );
     52
    4653                        $prefix = $wpdb->get_blog_prefix( $blog_id );
    4754                        foreach ( $wpdb->tables( 'blog', false ) as $table ) {
    4855                                $wpdb->suppress_errors();
  • includes/factory.php

     
    9797class WP_UnitTest_Factory_For_Blog extends WP_UnitTest_Factory_For_Thing {
    9898
    9999        function __construct( $factory = null ) {
    100                 global $current_site;
     100                global $current_site, $base;
    101101                parent::__construct( $factory );
    102102                $this->default_generation_definitions = array(
    103103                        'domain' => $current_site->domain,
    104                         'path' => new WP_UnitTest_Generator_Sequence( 'testpath%s' ),
     104                        'path' => new WP_UnitTest_Generator_Sequence( $base . 'testpath%s' ),
    105105                        'title' => new WP_UnitTest_Generator_Sequence( 'Site %s' ),
    106106                        'site_id' => $current_site->id,
    107107                );