Make WordPress Core


Ignore:
Timestamp:
11/06/2022 03:54:34 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Remove a custom callback for checking action call count in multisite tests.

Use MockAction::get_call_count() instead, for consistency with the rest of the test suite.

Follow-up to [24/tests], [99/tests], [1078/tests], [1089/tests], [29916], [30784], [30785], [33253].

See #56793.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/updateBlogDetails.php

    r52010 r54756  
    5757         */
    5858        public function test_update_blog_details_flag_action( $flag, $flag_value, $hook ) {
    59             global $test_action_counter;
    60             $test_action_counter = 0;
     59            $test_action_counter = new MockAction();
    6160
    6261            $blog_id = self::factory()->blog->create();
     
    6766            }
    6867
    69             add_action( $hook, array( $this, 'action_counter_cb' ), 10 );
     68            add_action( $hook, array( $test_action_counter, 'action' ) );
    7069
    7170            update_blog_details( $blog_id, array( $flag => $flag_value ) );
     
    7574
    7675            // The hook attached to this flag should have fired once during update_blog_details().
    77             $this->assertSame( 1, $test_action_counter );
     76            $this->assertSame( 1, $test_action_counter->get_call_count() );
    7877
    7978            // Update the site to the exact same flag value for this flag.
     
    8180
    8281            // The hook attached to this flag should not have fired again.
    83             $this->assertSame( 1, $test_action_counter );
    84 
    85             remove_action( $hook, array( $this, 'action_counter_cb' ), 10 );
     82            $this->assertSame( 1, $test_action_counter->get_call_count() );
    8683        }
    8784
     
    9794                array( 'mature', '0', 'unmature_blog' ),
    9895            );
    99         }
    100 
    101         /**
    102          * Provide a counter to determine that hooks are firing when intended.
    103          */
    104         public function action_counter_cb() {
    105             global $test_action_counter;
    106             $test_action_counter++;
    10796        }
    10897
Note: See TracChangeset for help on using the changeset viewer.