Make WordPress Core


Ignore:
Timestamp:
08/22/2015 04:38:09 PM (10 years ago)
Author:
wonderboymusic
Message:

Ensure that attachment_url_to_postid() matches cross-scheme when front-end and back-end schemes are different.

Adds unit test.

Props welcher.
Fixes #33109.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/media.php

    r33506 r33705  
    534534        $image_url  = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_path;
    535535        $this->assertEquals( $attachment_id, attachment_url_to_postid( $image_url ) );
     536    }
     537
     538    function test_attachment_url_to_postid_schemes() {
     539        $image_path = '2014/11/' . $this->img_name;
     540        $attachment_id = $this->factory->attachment->create_object( $image_path, 0, array(
     541            'post_mime_type' => 'image/jpeg',
     542            'post_type'      => 'attachment',
     543        ) );
     544
     545        /**
     546         * @ticket 33109 Testing protocols not matching
     547         */
     548        $image_url  = 'https://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_path;
     549        $this->assertEquals( $attachment_id, attachment_url_to_postid( $image_url ) );
     550    }
     551
     552    function test_attachment_url_to_postid_filtered() {
     553        $image_path = '2014/11/' . $this->img_name;
     554        $attachment_id = $this->factory->attachment->create_object( $image_path, 0, array(
     555            'post_mime_type' => 'image/jpeg',
     556            'post_type'      => 'attachment',
     557        ) );
    536558
    537559        add_filter( 'upload_dir', array( $this, '_upload_dir' ) );
Note: See TracChangeset for help on using the changeset viewer.