Make WordPress Core

Changeset 38935


Ignore:
Timestamp:
10/25/2016 11:03:15 PM (9 years ago)
Author:
jeremyfelt
Message:

Multisite: Use get_site() in tests where get_blog_details() is not tested.

Remaining tests either rely on the blog-details cache key or test get_blog_details() itself.

Props flixos90.
Fixes #38497.

Location:
trunk/tests/phpunit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/factory/class-wp-unittest-factory-for-blog.php

    r37418 r38935  
    3232
    3333    function get_object_by_id( $blog_id ) {
    34         return get_blog_details( $blog_id, false );
     34        return get_site( $blog_id );
    3535    }
    3636}
  • trunk/tests/phpunit/tests/multisite/site.php

    r38762 r38935  
    302302
    303303        // compare the update time with the current time, allow delta < 2
    304         $blog = get_blog_details( $wpdb->blogid );
     304        $blog = get_site( $wpdb->blogid );
    305305        $current_time = time();
    306306        $time_difference = $current_time - strtotime( $blog->last_updated );
     
    369369        add_action( 'make_ham_blog', array( $this, '_action_counter_cb' ), 10 );
    370370        update_blog_status( $blog_id, 'spam', 0 );
    371         $blog = get_blog_details( $blog_id );
     371        $blog = get_site( $blog_id );
    372372
    373373        $this->assertEquals( '0', $blog->spam );
     
    376376        // The action should fire if the status of 'spam' stays the same.
    377377        update_blog_status( $blog_id, 'spam', 0 );
    378         $blog = get_blog_details( $blog_id );
     378        $blog = get_site( $blog_id );
    379379
    380380        $this->assertEquals( '0', $blog->spam );
     
    392392        add_action( 'make_spam_blog', array( $this, '_action_counter_cb' ), 10 );
    393393        update_blog_status( $blog_id, 'spam', 1 );
    394         $blog = get_blog_details( $blog_id );
     394        $blog = get_site( $blog_id );
    395395
    396396        $this->assertEquals( '1', $blog->spam );
     
    399399        // The action should fire if the status of 'spam' stays the same.
    400400        update_blog_status( $blog_id, 'spam', 1 );
    401         $blog = get_blog_details( $blog_id );
     401        $blog = get_site( $blog_id );
    402402
    403403        $this->assertEquals( '1', $blog->spam );
     
    415415        add_action( 'archive_blog', array( $this, '_action_counter_cb' ), 10 );
    416416        update_blog_status( $blog_id, 'archived', 1 );
    417         $blog = get_blog_details( $blog_id );
     417        $blog = get_site( $blog_id );
    418418
    419419        $this->assertEquals( '1', $blog->archived );
     
    422422        // The action should fire if the status of 'archived' stays the same.
    423423        update_blog_status( $blog_id, 'archived', 1 );
    424         $blog = get_blog_details( $blog_id );
     424        $blog = get_site( $blog_id );
    425425
    426426        $this->assertEquals( '1', $blog->archived );
     
    439439        add_action( 'unarchive_blog', array( $this, '_action_counter_cb' ), 10 );
    440440        update_blog_status( $blog_id, 'archived', 0 );
    441         $blog = get_blog_details( $blog_id );
     441        $blog = get_site( $blog_id );
    442442
    443443        $this->assertEquals( '0', $blog->archived );
     
    446446        // The action should fire if the status of 'archived' stays the same.
    447447        update_blog_status( $blog_id, 'archived', 0 );
    448         $blog = get_blog_details( $blog_id );
     448        $blog = get_site( $blog_id );
    449449        $this->assertEquals( '0', $blog->archived );
    450450        $this->assertEquals( 2, $test_action_counter );
     
    461461        add_action( 'make_delete_blog', array( $this, '_action_counter_cb' ), 10 );
    462462        update_blog_status( $blog_id, 'deleted', 1 );
    463         $blog = get_blog_details( $blog_id );
     463        $blog = get_site( $blog_id );
    464464
    465465        $this->assertEquals( '1', $blog->deleted );
     
    468468        // The action should fire if the status of 'deleted' stays the same.
    469469        update_blog_status( $blog_id, 'deleted', 1 );
    470         $blog = get_blog_details( $blog_id );
     470        $blog = get_site( $blog_id );
    471471
    472472        $this->assertEquals( '1', $blog->deleted );
     
    485485        add_action( 'make_undelete_blog', array( $this, '_action_counter_cb' ), 10 );
    486486        update_blog_status( $blog_id, 'deleted', 0 );
    487         $blog = get_blog_details( $blog_id );
     487        $blog = get_site( $blog_id );
    488488
    489489        $this->assertEquals( '0', $blog->deleted );
     
    492492        // The action should fire if the status of 'deleted' stays the same.
    493493        update_blog_status( $blog_id, 'deleted', 0 );
    494         $blog = get_blog_details( $blog_id );
     494        $blog = get_site( $blog_id );
    495495
    496496        $this->assertEquals( '0', $blog->deleted );
     
    508508        add_action( 'mature_blog', array( $this, '_action_counter_cb' ), 10 );
    509509        update_blog_status( $blog_id, 'mature', 1 );
    510         $blog = get_blog_details( $blog_id );
     510        $blog = get_site( $blog_id );
    511511
    512512        $this->assertEquals( '1', $blog->mature );
     
    515515        // The action should fire if the status of 'mature' stays the same.
    516516        update_blog_status( $blog_id, 'mature', 1 );
    517         $blog = get_blog_details( $blog_id );
     517        $blog = get_site( $blog_id );
    518518
    519519        $this->assertEquals( '1', $blog->mature );
     
    533533        update_blog_status( $blog_id, 'mature', 0 );
    534534
    535         $blog = get_blog_details( $blog_id );
     535        $blog = get_site( $blog_id );
    536536        $this->assertEquals( '0', $blog->mature );
    537537        $this->assertEquals( 1, $test_action_counter );
     
    539539        // The action should fire if the status of 'mature' stays the same.
    540540        update_blog_status( $blog_id, 'mature', 0 );
    541         $blog = get_blog_details( $blog_id );
     541        $blog = get_site( $blog_id );
    542542
    543543        $this->assertEquals( '0', $blog->mature );
     
    556556        update_blog_status( $blog_id, 'public', 0 );
    557557
    558         $blog = get_blog_details( $blog_id );
     558        $blog = get_site( $blog_id );
    559559        $this->assertEquals( '0', $blog->public );
    560560        $this->assertEquals( 1, $test_action_counter );
     
    562562        // The action should fire if the status of 'mature' stays the same.
    563563        update_blog_status( $blog_id, 'public', 0 );
    564         $blog = get_blog_details( $blog_id );
     564        $blog = get_site( $blog_id );
    565565
    566566        $this->assertEquals( '0', $blog->public );
     
    576576        self::factory()->post->create();
    577577        $post2 = self::factory()->post->create();
    578         $this->assertEquals( 2, get_blog_details()->post_count );
     578        $this->assertEquals( 2, get_site()->post_count );
    579579
    580580        wp_delete_post( $post2 );
    581         $this->assertEquals( 1, get_blog_details()->post_count );
     581        $this->assertEquals( 1, get_site()->post_count );
    582582    }
    583583
     
    587587    function test_blog_details_cache_invalidation() {
    588588        update_option( 'blogname', 'foo' );
    589         $details = get_blog_details( get_current_blog_id() );
     589        $details = get_site( get_current_blog_id() );
    590590        $this->assertEquals( 'foo', $details->blogname );
    591591
    592592        update_option( 'blogname', 'bar' );
    593         $details = get_blog_details( get_current_blog_id() );
     593        $details = get_site( get_current_blog_id() );
    594594        $this->assertEquals( 'bar', $details->blogname );
    595595    }
     
    601601    function test_get_blog_id_from_url() {
    602602        $blog_id = self::factory()->blog->create();
    603         $details = get_blog_details( $blog_id, false );
     603        $details = get_site( $blog_id );
    604604        $key = md5( $details->domain . $details->path );
    605605
     
    614614    function test_get_blog_id_from_url_is_case_insensitive() {
    615615        $blog_id = self::factory()->blog->create( array( 'domain' => 'example.com', 'path' => '/xyz' ) );
    616         $details = get_blog_details( $blog_id, false );
     616        $details = get_site( $blog_id );
    617617
    618618        $this->assertEquals( $blog_id, get_blog_id_from_url( strtoupper( $details->domain ), strtoupper( $details->path ) ) );
     
    624624    function test_get_blog_id_from_url_that_does_not_exist() {
    625625        $blog_id = self::factory()->blog->create( array( 'path' => '/xyz' ) );
    626         $details = get_blog_details( $blog_id, false );
     626        $details = get_site( $blog_id );
    627627
    628628        $this->assertEquals( 0, get_blog_id_from_url( $details->domain, 'foo' ) );
     
    636636    function test_get_blog_id_from_url_with_deleted_flag() {
    637637        $blog_id = self::factory()->blog->create();
    638         $details = get_blog_details( $blog_id, false );
     638        $details = get_site( $blog_id );
    639639        $key = md5( $details->domain . $details->path );
    640640        wpmu_delete_blog( $blog_id );
     
    650650    function test_get_blog_id_from_url_after_dropped() {
    651651        $blog_id = self::factory()->blog->create();
    652         $details = get_blog_details( $blog_id, false );
     652        $details = get_site( $blog_id );
    653653        $key = md5( $details->domain . $details->path );
    654654        wpmu_delete_blog( $blog_id, true );
     
    767767
    768768    function test_domain_exists_with_default_site_id() {
    769         $details = get_blog_details( 1, false );
     769        $details = get_site( 1 );
    770770
    771771        $this->assertEquals( 1, domain_exists( $details->domain, $details->path ) );
     
    773773
    774774    function test_domain_exists_with_specified_site_id() {
    775         $details = get_blog_details( 1, false );
     775        $details = get_site( 1 );
    776776
    777777        $this->assertEquals( 1, domain_exists( $details->domain, $details->path, $details->site_id ) );
     
    783783     */
    784784    function test_domain_does_not_exist_with_invalid_site_id() {
    785         $details = get_blog_details( 1, false );
     785        $details = get_site( 1 );
    786786
    787787        $this->assertEquals( null, domain_exists( $details->domain, $details->path, 999 ) );
  • trunk/tests/phpunit/tests/multisite/updateBlogDetails.php

    r35242 r38935  
    3232        $this->assertTrue( $result );
    3333
    34         $blog = get_blog_details( $blog_id );
     34        $blog = get_site( $blog_id );
    3535
    3636        $this->assertEquals( 'example.com', $blog->domain );
     
    6464
    6565        update_blog_details( $blog_id, array( $flag => $flag_value ) );
    66         $blog = get_blog_details( $blog_id );
     66        $blog = get_site( $blog_id );
    6767
    6868        $this->assertEquals( $flag_value, $blog->{$flag} );
     
    109109    public function test_update_blog_details_single_directory_path( $path, $expected ) {
    110110        update_blog_details( 1, array( 'path' => $path ) );
    111         $site = get_blog_details( 1 );
     111        $site = get_site( 1 );
    112112
    113113        $this->assertEquals( $expected, $site->path );
Note: See TracChangeset for help on using the changeset viewer.