Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/29/2015 11:22:24 PM (11 years ago)
Author:
imath
Message:

Add Unittests for the BP_Attachment_Cover_Image class and the bp_attachments_get_allowed_types function

See #6570

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/class-bp-attachment.php

    r9874 r10159  
    329329        $this->clean_files();
    330330    }
     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    }
    331367}
Note: See TracChangeset for help on using the changeset viewer.