WordPress.org

Make WordPress Core

Ticket #37630: 37630.2.diff

File 37630.2.diff, 959 bytes (added by bcole808, 4 years ago)
  • tests/phpunit/includes/factory/class-wp-unittest-factory-for-attachment.php

     
    22
    33class WP_UnitTest_Factory_For_Attachment extends WP_UnitTest_Factory_For_Post {
    44
    5         function create_object( $file, $parent = 0, $args = array() ) {
    6                 return wp_insert_attachment( $args, $file, $parent );
     5        function create_object( $args, $legacy_parent = 0, $legacy_args = array() ) {
     6
     7                if ( is_string( $args ) ) {
     8                        $filename = $args;
     9                        $args = $legacy_args;
     10                        $args['post_parent'] = $legacy_parent;
     11                        $args['filename'] = $filename;
     12                }
     13
     14                return wp_insert_attachment( $args, $args['filename'], $args['post_parent'] );
    715        }
    816
    917        function create_upload_object( $file, $parent = 0 ) {