Changeset 10159
- Timestamp:
- 09/29/2015 11:22:24 PM (9 years ago)
- Location:
- trunk/tests/phpunit/testcases/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/core/class-bp-attachment.php
r9874 r10159 329 329 $this->clean_files(); 330 330 } 331 332 /** 333 * @group upload 334 * @group cover_image 335 */ 336 public function test_bp_attachment_cover_image_user_upload() { 337 $reset_files = $_FILES; 338 $reset_post = $_POST; 339 $bp = buddypress(); 340 $displayed_user = $bp->displayed_user; 341 $bp->displayed_user = new stdClass; 342 343 $u1 = $this->factory->user->create(); 344 $bp->displayed_user->id = $u1; 345 346 // Upload the file 347 $cover_image_attachment = new BP_Attachment_Cover_Image(); 348 $_POST['action'] = $cover_image_attachment->action; 349 $_FILES[ $cover_image_attachment->file_input ] = array( 350 'tmp_name' => $this->image_file, 351 'name' => 'mystery-man.jpg', 352 'type' => 'image/jpeg', 353 'error' => 0, 354 'size' => filesize( $this->image_file ) 355 ); 356 357 /* No error */ 358 $cover_image = $cover_image_attachment->upload( $_FILES ); 359 $this->assertEquals( $cover_image['file'], $bp->avatar->upload_path . '/buddypress/members/' . $u1 .'/cover-image/mystery-man.jpg' ); 360 361 // clean up! 362 $bp->displayed_user = $displayed_user; 363 $this->clean_files( 'buddypress' ); 364 $_FILES = $reset_files; 365 $_POST = $reset_post; 366 } 331 367 } -
trunk/tests/phpunit/testcases/core/functions.php
r10092 r10159 685 685 $bp->active_components = $reset_active_components; 686 686 } 687 688 /** 689 * @group bp_attachments 690 */ 691 public function test_bp_attachments_get_allowed_types() { 692 $supported = array( 'jpeg', 'gif', 'png' ); 693 694 $avatar = bp_attachments_get_allowed_types( 'avatar' ); 695 $this->assertSame( $supported, $avatar ); 696 697 $cover_image = bp_attachments_get_allowed_types( 'cover_image' ); 698 $this->assertSame( $supported, $cover_image ); 699 700 $images = bp_attachments_get_allowed_types( 'image/' ); 701 702 foreach ( $images as $image ) { 703 if ( 'image' !== wp_ext2type( $image ) ) { 704 $not_image = $image; 705 } 706 } 707 708 $this->assertTrue( empty( $not_image ) ); 709 } 687 710 }
Note: See TracChangeset
for help on using the changeset viewer.