Changeset 10177
- Timestamp:
- 10/03/2015 09:55:08 PM (9 years ago)
- Location:
- trunk/tests/phpunit
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/core/class-bp-attachment.php
r10159 r10177 365 365 $_POST = $reset_post; 366 366 } 367 368 /** 369 * @group shrink 370 * @group avatars 371 */ 372 public function test_bp_attachment_avatar_shrink() { 373 $image = BP_TESTS_DIR . 'assets/upside-down.jpg'; 374 375 $dir_copy = bp_upload_dir(); 376 377 // in case cleaning files fails 378 if ( ! is_dir( $dir_copy['basedir'] . '/shrink' ) ) { 379 mkdir( $dir_copy['basedir'] . '/shrink' ); 380 } 381 382 $abs_path_copy = $dir_copy['basedir'] . '/shrink/upside-down.jpg'; 383 384 copy( $image, $abs_path_copy ); 385 386 add_filter( 'bp_core_avatar_original_max_width', array( $this, 'limit_to_50px' ) ); 387 388 $shrink = BP_Attachment_Avatar::shrink( $abs_path_copy ); 389 390 remove_filter( 'bp_core_avatar_original_max_width', array( $this, 'limit_to_50px' ) ); 391 392 $this->assertTrue( 50 === $shrink['width'] && 50 === $shrink['height'] ); 393 394 // Cleanup 395 $this->clean_files( 'shrink' ); 396 } 397 398 public function limit_to_50px( $max_width ) { 399 return 50; 400 } 401 402 /** 403 * @group shrink 404 * @group avatars 405 */ 406 public function test_bp_attachment_avatar_shrink_not_needed() { 407 $shrink = BP_Attachment_Avatar::shrink( $this->image_file ); 408 409 $this->assertTrue( empty( $shrink ) ); 410 } 411 412 /** 413 * @group shrink 414 * @group cover_images 415 */ 416 public function test_bp_attachment_cover_image_fit() { 417 $image = BP_TESTS_DIR . 'assets/upside-down.jpg'; 418 419 $cover_image_class = new BP_Attachment_Cover_Image(); 420 421 $abs_path_copy = $cover_image_class->upload_path . '/upside-down.jpg'; 422 423 copy( $image, $abs_path_copy ); 424 425 $fit = $cover_image_class->fit( $abs_path_copy, array( 'width' => 50, 'height' => 50 ) ); 426 427 $this->assertTrue( 50 === $fit['width'] && 50 === $fit['height'] ); 428 429 // Cleanup 430 $this->clean_files( 'buddypress' ); 431 } 432 433 /** 434 * @group shrink 435 * @group cover_images 436 */ 437 public function test_bp_attachment_cover_image_fit_not_needed() { 438 $cover_image_class = new BP_Attachment_Cover_Image(); 439 $fit = $cover_image_class->fit( $this->image_file, array( 'width' => 1300, 'height' => 225 ) ); 440 441 $this->assertTrue( empty( $fit ) ); 442 443 // Cleanup 444 $this->clean_files( 'buddypress' ); 445 } 367 446 }
Note: See TracChangeset
for help on using the changeset viewer.