WordPress.org

Make WordPress Core

Changeset 1249 in tests


Ignore:
Timestamp:
03/25/13 09:31:06 (13 months ago)
Author:
ryan
Message:

Test updating the 'public' site option value via update_blog_status(). see #WP23155

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/ms.php

    r1248 r1249  
    575575 
    576576        $test_action_counter = 0; 
     577        $count = 1; 
    577578 
    578579        add_action( 'make_ham_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 
     
    581582        $blog = get_blog_details( $blog_id ); 
    582583        $this->assertEquals( '0', $blog->spam ); 
    583         $this->assertEquals( 1, $test_action_counter ); 
    584  
    585         // Same again 
     584        $this->assertEquals( $count, $test_action_counter ); 
     585 
     586        // Same again 
     587        $count++; 
    586588        $result = update_blog_status( $blog_id, 'spam', 0 ); 
    587589        $this->assertEquals( 0, $result ); 
    588590        $blog = get_blog_details( $blog_id ); 
    589591        $this->assertEquals( '0', $blog->spam ); 
    590         $this->assertEquals( 2, $test_action_counter ); 
     592        $this->assertEquals( $count, $test_action_counter ); 
    591593        remove_action( 'make_ham_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 
    592594 
     595        $count++; 
    593596        add_action( 'make_spam_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 
    594597        $result = update_blog_status( $blog_id, 'spam', 1 ); 
     
    596599        $blog = get_blog_details( $blog_id ); 
    597600        $this->assertEquals( '1', $blog->spam ); 
    598         $this->assertEquals( 3, $test_action_counter ); 
    599  
    600         // Same again 
     601        $this->assertEquals( $count, $test_action_counter ); 
     602 
     603        // Same again 
     604        $count++; 
    601605        $result = update_blog_status( $blog_id, 'spam', 1 ); 
    602606        $this->assertEquals( 1, $result ); 
    603607        $blog = get_blog_details( $blog_id ); 
    604608        $this->assertEquals( '1', $blog->spam ); 
    605         $this->assertEquals( 4, $test_action_counter ); 
     609        $this->assertEquals( $count, $test_action_counter ); 
    606610        remove_action( 'make_spam_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 
    607611 
    608612        add_action( 'archive_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 
     613        $count++; 
    609614        $result = update_blog_status( $blog_id, 'archived', 1 ); 
    610615        $this->assertEquals( 1, $result ); 
    611616        $blog = get_blog_details( $blog_id ); 
    612617        $this->assertEquals( '1', $blog->archived ); 
    613         $this->assertEquals( 5, $test_action_counter ); 
    614  
    615         // Same again 
     618        $this->assertEquals( $count, $test_action_counter ); 
     619 
     620        // Same again 
     621        $count++; 
    616622        $result = update_blog_status( $blog_id, 'archived', 1 ); 
    617623        $this->assertEquals( 1, $result ); 
    618624        $blog = get_blog_details( $blog_id ); 
    619625        $this->assertEquals( '1', $blog->archived ); 
    620         $this->assertEquals( 6, $test_action_counter ); 
     626        $this->assertEquals( $count, $test_action_counter ); 
    621627        remove_action( 'archive_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 
    622628 
    623629        add_action( 'unarchive_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 
     630        $count++; 
    624631        $result = update_blog_status( $blog_id, 'archived', 0 ); 
    625632        $this->assertEquals( 0, $result ); 
    626633        $blog = get_blog_details( $blog_id ); 
    627634        $this->assertEquals( '0', $blog->archived ); 
    628         $this->assertEquals( 7, $test_action_counter ); 
     635        $this->assertEquals( $count, $test_action_counter ); 
    629636 
    630637        // Same again 
    631638        $result = update_blog_status( $blog_id, 'archived', 0 ); 
     639        $count++; 
    632640        $this->assertEquals( 0, $result ); 
    633641        $blog = get_blog_details( $blog_id ); 
    634642        $this->assertEquals( '0', $blog->archived ); 
    635         $this->assertEquals( 8, $test_action_counter ); 
     643        $this->assertEquals( $count, $test_action_counter ); 
    636644        remove_action( 'unarchive_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 
    637645 
    638646        add_action( 'make_delete_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 
     647        $count++; 
    639648        $result = update_blog_status( $blog_id, 'deleted', 1 ); 
    640649        $this->assertEquals( 1, $result ); 
    641650        $blog = get_blog_details( $blog_id ); 
    642651        $this->assertEquals( '1', $blog->deleted ); 
    643         $this->assertEquals( 9, $test_action_counter ); 
    644  
    645         // Same again 
     652        $this->assertEquals( $count, $test_action_counter ); 
     653 
     654        // Same again 
     655        $count++; 
    646656        $result = update_blog_status( $blog_id, 'deleted', 1 ); 
    647657        $this->assertEquals( 1, $result ); 
    648658        $blog = get_blog_details( $blog_id ); 
    649659        $this->assertEquals( '1', $blog->deleted ); 
    650         $this->assertEquals( 10, $test_action_counter ); 
     660        $this->assertEquals( $count, $test_action_counter ); 
    651661        remove_action( 'make_delete_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 
    652662 
    653663        add_action( 'make_undelete_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 
     664        $count++; 
    654665        $result = update_blog_status( $blog_id, 'deleted', 0 ); 
    655666        $this->assertEquals( 0, $result ); 
    656667        $blog = get_blog_details( $blog_id ); 
    657668        $this->assertEquals( '0', $blog->deleted ); 
    658         $this->assertEquals( 11, $test_action_counter ); 
    659  
    660         // Same again 
     669        $this->assertEquals( $count, $test_action_counter ); 
     670 
     671        // Same again 
     672        $count++; 
    661673        $result = update_blog_status( $blog_id, 'deleted', 0 ); 
    662674        $this->assertEquals( 0, $result ); 
    663675        $blog = get_blog_details( $blog_id ); 
    664676        $this->assertEquals( '0', $blog->deleted ); 
    665         $this->assertEquals( 12, $test_action_counter ); 
     677        $this->assertEquals( $count, $test_action_counter ); 
    666678        remove_action( 'make_undelete_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 
    667679 
    668680        add_action( 'mature_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 
     681        $count++; 
    669682        $result = update_blog_status( $blog_id, 'mature', 1 ); 
    670683        $this->assertEquals( 1, $result ); 
    671684        $blog = get_blog_details( $blog_id ); 
    672685        $this->assertEquals( '1', $blog->mature ); 
    673         $this->assertEquals( 13, $test_action_counter ); 
    674  
    675         // Same again 
     686        $this->assertEquals( $count, $test_action_counter ); 
     687 
     688        // Same again 
     689        $count++; 
    676690        $result = update_blog_status( $blog_id, 'mature', 1 ); 
    677691        $this->assertEquals( 1, $result ); 
    678692        $blog = get_blog_details( $blog_id ); 
    679693        $this->assertEquals( '1', $blog->mature ); 
    680         $this->assertEquals( 14, $test_action_counter ); 
     694        $this->assertEquals( $count, $test_action_counter ); 
    681695        remove_action( 'mature_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 
    682696 
    683697        add_action( 'unmature_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 
     698        $count++; 
    684699        $result = update_blog_status( $blog_id, 'mature', 0 ); 
    685700        $this->assertEquals( 0, $result ); 
    686701        $blog = get_blog_details( $blog_id ); 
    687702        $this->assertEquals( '0', $blog->mature ); 
    688         $this->assertEquals( 15, $test_action_counter ); 
    689  
    690         // Same again 
     703        $this->assertEquals( $count, $test_action_counter ); 
     704 
     705        // Same again 
     706        $count++; 
    691707        $result = update_blog_status( $blog_id, 'mature', 0 ); 
    692708        $this->assertEquals( 0, $result ); 
    693709        $blog = get_blog_details( $blog_id ); 
    694710        $this->assertEquals( '0', $blog->mature ); 
    695         $this->assertEquals( 16, $test_action_counter ); 
     711        $this->assertEquals( $count, $test_action_counter ); 
    696712        remove_action( 'unmature_blog', array( $this, '_action_counter_cb' ), 10, 1 ); 
     713 
     714        add_action( 'update_blog_public', array( $this, '_action_counter_cb' ), 10, 1 ); 
     715        $count++; 
     716        $result = update_blog_status( $blog_id, 'public', 0 ); 
     717        $this->assertEquals( 0, $result ); 
     718        $blog = get_blog_details( $blog_id ); 
     719        $this->assertEquals( '0', $blog->public ); 
     720        $this->assertEquals( $count, $test_action_counter ); 
     721 
     722        // Same again 
     723        $count++; 
     724        $result = update_blog_status( $blog_id, 'public', 0 ); 
     725        $this->assertEquals( 0, $result ); 
     726        $blog = get_blog_details( $blog_id ); 
     727        $this->assertEquals( '0', $blog->public ); 
     728        $this->assertEquals( $count, $test_action_counter ); 
     729        remove_action( 'update_blog_public', array( $this, '_action_counter_cb' ), 10, 1 ); 
     730 
     731        add_action( 'update_blog_public', array( $this, '_action_counter_cb' ), 10, 1 ); 
     732        $count++; 
     733        $result = update_blog_status( $blog_id, 'public', 1 ); 
     734        $this->assertEquals( 1, $result ); 
     735        $blog = get_blog_details( $blog_id ); 
     736        $this->assertEquals( '1', $blog->public ); 
     737        $this->assertEquals( $count, $test_action_counter ); 
     738 
     739        // Same again 
     740        $count++; 
     741        $result = update_blog_status( $blog_id, 'public', 1 ); 
     742        $this->assertEquals( 1, $result ); 
     743        $blog = get_blog_details( $blog_id ); 
     744        $this->assertEquals( '1', $blog->public ); 
     745        $this->assertEquals( $count, $test_action_counter ); 
     746        remove_action( 'update_blog_public', array( $this, '_action_counter_cb' ), 10, 1 ); 
    697747 
    698748        // Updating a dummy field returns the value passed. Go fig. 
Note: See TracChangeset for help on using the changeset viewer.