Make WordPress Core

Changeset 1241 in tests


Ignore:
Timestamp:
03/08/2013 08:31:37 PM (12 years ago)
Author:
nacin
Message:

Test suite: Add $this->factory->attachment->create( $file, $parent = 0, $args = array() ), which wraps wp_insert_attachment().

In the future, we may want an upload() method that wraps (and fakes) media_handle_upload(), to populate metadata.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/factory.php

    r1230 r1241  
    44    function __construct() {
    55        $this->post = new WP_UnitTest_Factory_For_Post( $this );
     6        $this->attachment = new WP_UnitTest_Factory_For_Attachment( $this );
    67        $this->comment = new WP_UnitTest_Factory_For_Comment( $this );
    78        $this->user = new WP_UnitTest_Factory_For_User( $this );
     
    3940        return get_post( $post_id );
    4041    }
     42}
     43
     44class WP_UnitTest_Factory_For_Attachment extends WP_UnitTest_Factory_For_Post {
     45
     46        function create_object( $file, $parent = 0, $args = array() ) {
     47            return wp_insert_attachment( $args, $file, $parent );
     48        }
    4149}
    4250
Note: See TracChangeset for help on using the changeset viewer.