Changeset 13316
- Timestamp:
- 08/13/2022 12:59:52 PM (2 years ago)
- Location:
- trunk/tests/phpunit/testcases/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/core/avatars.php
r13315 r13316 6 6 class BP_Tests_Avatars extends BP_UnitTestCase { 7 7 private $params = array(); 8 protected $allowed_image_types = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ); 9 protected $allowed_image_mimes = array( 'image/jpeg', 'image/jpeg', 'image/jpeg', 'image/gif', 'image/png' ); 10 11 public function set_up() { 12 parent::set_up(); 13 14 if ( bp_is_running_wp( '5.8.0', '>=' ) ) { 15 $this->allowed_image_types[] = 'webp'; 16 $this->allowed_image_mimes[] = 'image/webp'; 17 } 18 } 8 19 9 20 private function clean_existing_avatars( $type = 'user' ) { … … 256 267 */ 257 268 public function test_bp_core_get_allowed_avatar_types_filter() { 269 $allowed_image_types = $this->allowed_image_types; 258 270 add_filter( 'bp_core_get_allowed_avatar_types', array( $this, 'avatar_types_filter_add_type' ) ); 259 271 260 $this->assertEquals( array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'webp' ), bp_core_get_allowed_avatar_types() );272 $this->assertEquals( $allowed_image_types, bp_core_get_allowed_avatar_types() ); 261 273 262 274 remove_filter( 'bp_core_get_allowed_avatar_types', array( $this, 'avatar_types_filter_add_type' ) ); 263 275 264 276 add_filter( 'bp_core_get_allowed_avatar_types', array( $this, 'avatar_types_filter_remove_type' ) ); 265 266 $this->assertEquals( array( 'jpeg', 'jpe', 'gif', 'png', 'webp' ), bp_core_get_allowed_avatar_types() ); 277 array_shift( $allowed_image_types ); 278 279 $this->assertEquals( $allowed_image_types, bp_core_get_allowed_avatar_types() ); 267 280 268 281 remove_filter( 'bp_core_get_allowed_avatar_types', array( $this, 'avatar_types_filter_remove_type' ) ); … … 270 283 add_filter( 'bp_core_get_allowed_avatar_types', '__return_empty_array' ); 271 284 272 $this->assertEquals( array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'webp' ), bp_core_get_allowed_avatar_types() );285 $this->assertEquals( $this->allowed_image_types, bp_core_get_allowed_avatar_types() ); 273 286 274 287 remove_filter( 'bp_core_get_allowed_avatar_types', '__return_empty_array' ); … … 280 293 */ 281 294 public function test_bp_core_get_allowed_avatar_mimes() { 282 $mimes = bp_core_get_allowed_avatar_mimes(); 283 284 $this->assertEqualSets( array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'webp' ), array_keys( $mimes ) ); 285 $this->assertEqualSets( array( 'image/jpeg', 'image/jpeg', 'image/jpeg', 'image/gif', 'image/png', 'image/webp' ), array_values( $mimes ) ); 295 $mimes = bp_core_get_allowed_avatar_mimes(); 296 $allowed_image_mimes = $this->allowed_image_mimes; 297 298 $this->assertEqualSets( $this->allowed_image_types, array_keys( $mimes ) ); 299 $this->assertEqualSets( $allowed_image_mimes, array_values( $mimes ) ); 286 300 287 301 add_filter( 'bp_core_get_allowed_avatar_types', array( $this, 'avatar_types_filter_add_type' ) ); 288 302 289 $this->assertEqualSets( array( 'image/jpeg', 'image/jpeg', 'image/jpeg', 'image/gif', 'image/png', 'image/webp' ), array_values( bp_core_get_allowed_avatar_mimes() ) );303 $this->assertEqualSets( $allowed_image_mimes, array_values( bp_core_get_allowed_avatar_mimes() ) ); 290 304 291 305 remove_filter( 'bp_core_get_allowed_avatar_types', array( $this, 'avatar_types_filter_add_type' ) ); 292 306 293 307 add_filter( 'bp_core_get_allowed_avatar_types', array( $this, 'avatar_types_filter_remove_type' ) ); 294 295 $this->assertEqualSets( array( 'image/jpeg', 'image/jpeg', 'image/gif', 'image/png', 'image/webp', 'image/jpeg' ), array_values( bp_core_get_allowed_avatar_mimes() ) ); 308 array_shift( $allowed_image_mimes ); 309 310 $this->assertEqualSets( array_merge( $allowed_image_mimes, array( 'image/jpeg' ) ), array_values( bp_core_get_allowed_avatar_mimes() ) ); 296 311 297 312 remove_filter( 'bp_core_get_allowed_avatar_types', array( $this, 'avatar_types_filter_remove_type' ) ); … … 299 314 add_filter( 'bp_core_get_allowed_avatar_types', '__return_empty_array' ); 300 315 301 $this->assertEqualSets( array( 'image/jpeg', 'image/jpeg', 'image/jpeg', 'image/gif', 'image/png', 'image/webp' ), array_values( bp_core_get_allowed_avatar_mimes() ) );316 $this->assertEqualSets( $this->allowed_image_mimes, array_values( bp_core_get_allowed_avatar_mimes() ) ); 302 317 303 318 remove_filter( 'bp_core_get_allowed_avatar_types', '__return_empty_array' ); -
trunk/tests/phpunit/testcases/core/functions.php
r13315 r13316 785 785 */ 786 786 public function test_bp_attachments_get_allowed_types() { 787 $supported = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'webp' ); 787 $supported = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ); 788 if ( bp_is_running_wp( '5.8.0', '>=' ) ) { 789 $supported[] = 'webp'; 790 } 788 791 789 792 $avatar = bp_attachments_get_allowed_types( 'avatar' );
Note: See TracChangeset
for help on using the changeset viewer.