Make WordPress Core

Ticket #38187: trac-38187-unit-tests-for-the-oembed-regex-fixes.patch

File trac-38187-unit-tests-for-the-oembed-regex-fixes.patch, 3.8 KB (added by jrf, 8 years ago)

Adjust the related unit test provider array + add unit tests for the issue

  • tests/phpunit/tests/oembed.php

    From b7eb19f8ddb7ccbb6866182d79f86e1209dbae6e Mon Sep 17 00:00:00 2001
    From: jrfnl <github_nospam@adviesenzo.nl>
    Date: Thu, 29 Sep 2016 18:44:53 +0200
    Subject: [PATCH] Unit tests for the oembed regex fixes.
    
    ---
     tests/phpunit/tests/oembed.php | 43 ++++++++++++++++++++++++++++++++++++++----
     1 file changed, 39 insertions(+), 4 deletions(-)
    
    diff --git a/tests/phpunit/tests/oembed.php b/tests/phpunit/tests/oembed.php
    index 6f8787d..92e816a 100644
    a b class Tests_oEmbed extends WP_UnitTestCase { 
    88                'youtube-shorturl'     => '#https?://youtu\.be/.*#i',
    99                'vimeo'                => '#https?://(.+\.)?vimeo\.com/.*#i',
    1010                'dailymotion'          => '#https?://(www\.)?dailymotion\.com/.*#i',
    11                 'dailymotion-shorturl' => '#https?://dai.ly/.*#i',
     11                'dailymotion-shorturl' => '#https?://dai\.ly/.*#i',
    1212                'flickr'               => '#https?://(www\.)?flickr\.com/.*#i',
    1313                'flickr-shorturl'      => '#https?://flic\.kr/.*#i',
    1414                'smugmug'              => '#https?://(.+\.)?smugmug\.com/.*#i',
    class Tests_oEmbed extends WP_UnitTestCase { 
    1616                'photobucket-album'    => 'http://i*.photobucket.com/albums/*',
    1717                'photobucket-group'    => 'http://gi*.photobucket.com/groups/*',
    1818                'scribd'               => '#https?://(www\.)?scribd\.com/doc/.*#i',
    19                 'wordpress-tv'         => '#https?://wordpress.tv/.*#i',
     19                'wordpress-tv'         => '#https?://wordpress\.tv/.*#i',
    2020                'polldaddy'            => '#https?://(.+\.)?polldaddy\.com/.*#i',
    2121                'polldaddy-shorturl'   => '#https?://poll\.fm/.*#i',
    2222                'funnyordie'           => '#https?://(www\.)?funnyordie\.com/videos/.*#i',
    2323                'twitter'              => '#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i',
    2424                'twitter-timeline'     => '#https?://(www\.)?twitter\.com/.+?/timelines/.*#i',
    2525                'twitter-moment'       => '#https?://(www\.)?twitter\.com/i/moments/.*#i',
    26                 'vine'                 => '#https?://vine.co/v/.*#i',
     26                'vine'                 => '#https?://vine\.co/v/.*#i',
    2727                'soundcloud'           => '#https?://(www\.)?soundcloud\.com/.*#i',
    2828                'slideshare'           => '#https?://(.+?\.)?slideshare\.net/.*#i',
    2929                'instagram'            => '#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i',
    class Tests_oEmbed extends WP_UnitTestCase { 
    4040                'kickstarter-shorturl' => '#https?://kck\.st/.*#i',
    4141                'cloudup'              => '#https?://cloudup\.com/.*#i',
    4242                'reverbnation'         => '#https?://(www\.)?reverbnation\.com/.*#i',
    43                 'videopress'           => '#https?://videopress.com/v/.*#',
     43                'videopress'           => '#https?://videopress\.com/v/.*#',
    4444                'reddit-comments'      => '#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i',
    4545                'speakerdeck'          => '#https?://(www\.)?speakerdeck\.com/.*#i',
    4646                'facebook-post'        => '#https?://www\.facebook\.com/.*/posts/.*#i',
    class Tests_oEmbed extends WP_UnitTestCase { 
    812812
    813813        }
    814814
     815
     816        /**
     817         * Test the tests
     818         *
     819         * @group oembed
     820         * @ticket 38187
     821         * @dataProvider dataShouldNotMatchOembedRegex
     822         *
     823         * @param string $url A url which should not match any of the predefined providers.
     824         */
     825        public function testUrlShouldNotMatchOembedRegex( $url ) {
     826
     827                $this->assertSame( false, self::$oembed->get_provider( $url, array( 'discover' => false ) ) );
     828
     829        }
     830
     831        /**
     832         * Data provider for our oEmbed tests
     833         *
     834         * @return array
     835         */
     836        public function dataShouldNotMatchOembedRegex() {
     837                $providers = self::$provider_map;
     838
     839                return array(
     840                        array( 'http://dairly/something' ),
     841                        array( 'https://daisly/' ),
     842                        array( 'http://wordpressstv/' ),
     843                        array( 'https://wordpressstv/somethingelse' ),
     844                        array( 'http://vinerco/v/andanother' ),
     845                        array( 'https://vineqco/v/' ),
     846                        array( 'http://videopressscom/v/' ),
     847                        array( 'https://videopresstcom/v/covered' ),
     848                );
     849        }
    815850}