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/testcases/core/suggestions.php

    r11739 r13314  
    9494    }
    9595
    96     public static function tearDownAfterClass() {
     96    public static function tear_down_after_class() {
    9797        foreach ( self::$group_ids as $group_id ) {
    9898            groups_delete_group( $group_id );
     
    110110    }
    111111
    112     public function setUp() {
    113         parent::setUp();
     112    public function set_up() {
     113        parent::set_up();
    114114        $this->set_current_user( self::$current_user );
    115115    }
    116116
    117     public function tearDown() {
    118         parent::tearDown();
     117    public function tear_down() {
     118        parent::tear_down();
    119119        $this->set_current_user( self::$old_user_id );
    120120    }
     
    392392
    393393        $this->assertFalse( is_wp_error( $suggestions ) );
    394         $this->assertInternalType( 'array', $suggestions );
     394        $this->assertIsArray( $suggestions );
    395395        $this->assertEmpty( $suggestions );
    396396    }
     
    403403
    404404        $this->assertFalse( is_wp_error( $suggestion ) );
    405         $this->assertInternalType( 'array', $suggestion );
     405        $this->assertIsArray( $suggestion );
    406406        $this->assertNotEmpty( $suggestion );
    407407
    408408        $suggestion = array_shift( $suggestion );
    409409
    410         $this->assertInternalType( 'object', $suggestion );
    411         $this->assertAttributeNotEmpty( 'image', $suggestion );
    412         $this->assertAttributeNotEmpty( 'ID', $suggestion );
    413         $this->assertAttributeNotEmpty( 'name', $suggestion );
     410        $this->assertIsObject( $suggestion );
     411        $this->assertNotEmpty( $suggestion->image );
     412        $this->assertNotEmpty( $suggestion->ID );
     413        $this->assertNotEmpty( $suggestion->name );
    414414    }
    415415
     
    421421
    422422        $this->assertFalse( is_wp_error( $suggestions ) );
    423         $this->assertInternalType( 'array', $suggestions );
     423        $this->assertIsArray( $suggestions );
    424424        $this->assertNotEmpty( $suggestions );
    425425
    426426        foreach ( $suggestions as $suggestion ) {
    427             $this->assertInternalType( 'object', $suggestion );
    428             $this->assertAttributeNotEmpty( 'image', $suggestion );
    429             $this->assertAttributeNotEmpty( 'ID', $suggestion );
    430             $this->assertAttributeNotEmpty( 'name', $suggestion );
     427            $this->assertIsObject( $suggestion );
     428            $this->assertNotEmpty( $suggestion->image );
     429            $this->assertNotEmpty( $suggestion->ID );
     430            $this->assertNotEmpty( $suggestion->name );
    431431        }
    432432    }
     
    458458
    459459        $this->assertFalse( is_wp_error( $suggestion ) );
    460         $this->assertInternalType( 'array', $suggestion );
     460        $this->assertIsArray( $suggestion );
    461461        $this->assertNotEmpty( $suggestion );
    462462
    463463        $suggestion = array_shift( $suggestion );
    464464
    465         $this->assertInternalType( 'object', $suggestion );
    466         $this->assertAttributeInternalType( 'string', 'image', $suggestion );
    467         $this->assertAttributeInternalType( 'string', 'ID', $suggestion );
    468         $this->assertAttributeInternalType( 'string', 'name', $suggestion );
     465        $this->assertIsObject( $suggestion );
     466        $this->assertIsString( $suggestion->image );
     467        $this->assertIsString( $suggestion->ID );
     468        $this->assertIsString( $suggestion->name );
    469469    }
    470470
Note: See TracChangeset for help on using the changeset viewer.