Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/12/2015 11:13:47 PM (9 years ago)
Author:
djpaul
Message:

Tests: fix test failures on PHP7

PHP7 has changed its array sorting behaviour so that it is not
necessarily guaranteed to match previous versions of PHP. Brittle
tests, such as these, fail because of the change.

As a workaround, let's try using assertEqualSets, which is a
WordPress-provided testing assert that does a sort on each array
before comparing the arrays.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/avatars.php

    r9831 r10260  
    256256        $mimes = bp_core_get_allowed_avatar_mimes();
    257257
    258         $this->assertEquals( array( 'jpeg', 'gif', 'png', 'jpg' ), array_keys( $mimes ) );
    259         $this->assertEquals( array( 'image/jpeg', 'image/gif', 'image/png', 'image/jpeg' ), array_values( $mimes ) );
     258        $this->assertEqualSets( array( 'jpeg', 'gif', 'png', 'jpg' ), array_keys( $mimes ) );
     259        $this->assertEqualSets( array( 'image/jpeg', 'image/gif', 'image/png', 'image/jpeg' ), array_values( $mimes ) );
    260260
    261261        add_filter( 'bp_core_get_allowed_avatar_types', array( $this, 'avatar_types_filter_add_type' ) );
    262262
    263         $this->assertEquals( array( 'image/jpeg', 'image/gif', 'image/png', 'image/jpeg' ), array_values( bp_core_get_allowed_avatar_mimes() ) );
     263        $this->assertEqualSets( array( 'image/jpeg', 'image/gif', 'image/png', 'image/jpeg' ), array_values( bp_core_get_allowed_avatar_mimes() ) );
    264264
    265265        remove_filter( 'bp_core_get_allowed_avatar_types', array( $this, 'avatar_types_filter_add_type' ) );
     
    267267        add_filter( 'bp_core_get_allowed_avatar_types', array( $this, 'avatar_types_filter_remove_type' ) );
    268268
    269         $this->assertEquals( array( 'image/gif', 'image/png' ), array_values( bp_core_get_allowed_avatar_mimes() ) );
     269        $this->assertEqualSets( array( 'image/gif', 'image/png' ), array_values( bp_core_get_allowed_avatar_mimes() ) );
    270270
    271271        remove_filter( 'bp_core_get_allowed_avatar_types', array( $this, 'avatar_types_filter_remove_type' ) );
     
    273273        add_filter( 'bp_core_get_allowed_avatar_types', '__return_empty_array' );
    274274
    275         $this->assertEquals( array( 'image/jpeg', 'image/gif', 'image/png', 'image/jpeg' ), array_values( bp_core_get_allowed_avatar_mimes() ) );
     275        $this->assertEqualSets( array( 'image/jpeg', 'image/gif', 'image/png', 'image/jpeg' ), array_values( bp_core_get_allowed_avatar_mimes() ) );
    276276
    277277        remove_filter( 'bp_core_get_allowed_avatar_types', '__return_empty_array' );
Note: See TracChangeset for help on using the changeset viewer.