Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/13/2022 08:58:51 AM (2 years 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/activity/notifications.php

    r12222 r13314  
    1212    protected $a2;
    1313
    14     public function setUp() {
    15         parent::setUp();
     14    public function set_up() {
     15        parent::set_up();
    1616        $this->current_user = get_current_user_id();
    1717        $this->u1 = self::factory()->user->create();
     
    2323         * When updating an activity, the following filter is fired to prevent sending more than one
    2424         * notification. Once we've reached this filter all at_mentions tests fails so we need to
    25          * temporarly remove it and restore it in $this->tearDown()
     25         * temporarly remove it and restore it in $this->tear_down()
    2626         */
    2727        remove_filter( 'bp_activity_at_name_do_notifications', '__return_false' );
    2828    }
    2929
    30     public function tearDown() {
     30    public function tear_down() {
    3131        $this->set_current_user( $this->current_user );
    32         parent::tearDown();
     32        parent::tear_down();
    3333
    3434        // Restore the filter
     
    310310        $multiple = 'You have 2 new mentions';
    311311
    312         $this->assertContains( $single, $format_tests['string_single'] );
    313         $this->assertContains( $single, $format_tests['array_single']['text'] );
    314         $this->assertContains( $multiple, $format_tests['string_multiple'] );
    315         $this->assertContains( $multiple, $format_tests['array_multiple']['text'] );
     312        $this->assertStringContainsString( $single, $format_tests['string_single'] );
     313        $this->assertStringContainsString( $single, $format_tests['array_single']['text'] );
     314        $this->assertStringContainsString( $multiple, $format_tests['string_multiple'] );
     315        $this->assertStringContainsString( $multiple, $format_tests['array_multiple']['text'] );
    316316
    317317        // Check filters
Note: See TracChangeset for help on using the changeset viewer.