Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/13/2022 08:58:51 AM (21 months ago)
Author:
imath
Message:

Fully enjoy Yoast’s PHPUnit polyfills

Using these polyfills let us use PHPUnit v9.x for our tests and add PHP 8.1 to our testing matrix. Some additional edits to our PHP unit tests suite were needed:

  • Stop using PHPunit deprecated functions.
  • Rename some BP_UnitTestCase methods to use Yoast's polyfills.
  • Edit the PHP Unit test GH action and also run this action on pull requests.
  • Update some composer dependencies, remove the one about phpunit/phpunit:^7.5 and add a new composer script to use PHPUnit v9.x.

Props renatonascalves, rafiahmedd

Closes https://github.com/buddypress/buddypress/pull/13
Fixes #8649

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase.php

    r13140 r13314  
    3131     * @since 3.0.0
    3232     */
    33     public static function setUpBeforeClass() {
     33    public static function set_up_before_class() {
    3434        global $wpdb;
    3535
     
    4949    }
    5050
    51     public function setUp() {
    52         parent::setUp();
     51    public function set_up() {
     52        parent::set_up();
    5353
    5454        /*
     
    7575    }
    7676
    77     public function tearDown() {
     77    public function tear_down() {
    7878        global $wpdb;
    7979
    8080        remove_action( 'bp_blogs_recorded_existing_blogs', array( $this, 'set_autocommit_flag' ) );
    8181
    82         parent::tearDown();
     82        parent::tear_down();
    8383
    8484        // If we detect that a COMMIT has been triggered during the test, clean up blog and user fixtures.
     
    116116        $deleted = parent::delete_user( $user_id );
    117117
    118         // When called in tearDownAfterClass(), BP's cleanup functions may no longer be hooked.
     118        // When called in tear_down_after_class(), BP's cleanup functions may no longer be hooked.
    119119        if ( bp_is_active( 'activity' ) ) {
    120120            bp_activity_remove_all_user_data( $user_id );
     
    126126    }
    127127
    128     function clean_up_global_scope() {
     128    public function clean_up_global_scope() {
    129129        buddypress()->bp_nav                = buddypress()->bp_options_nav = buddypress()->action_variables = buddypress()->canonical_stack = buddypress()->unfiltered_uri = $GLOBALS['bp_unfiltered_uri'] = array();
    130130        buddypress()->current_component     = buddypress()->current_item = buddypress()->current_action = buddypress()->current_member_type = '';
     
    181181    }
    182182
    183     function assertPreConditions() {
    184         parent::assertPreConditions();
     183    public function assert_pre_conditions() {
     184        parent::assert_pre_conditions();
    185185
    186186        // Reinit some of the globals that might have been cleared by BP_UnitTestCase::clean_up_global_scope().
     
    189189    }
    190190
    191     function go_to( $url ) {
     191    public function go_to( $url ) {
    192192        $GLOBALS['bp']->loggedin_user = NULL;
    193193        $GLOBALS['bp']->pages = bp_core_get_directory_pages();
Note: See TracChangeset for help on using the changeset viewer.