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 { |
8 | 8 | 'youtube-shorturl' => '#https?://youtu\.be/.*#i', |
9 | 9 | 'vimeo' => '#https?://(.+\.)?vimeo\.com/.*#i', |
10 | 10 | 'dailymotion' => '#https?://(www\.)?dailymotion\.com/.*#i', |
11 | | 'dailymotion-shorturl' => '#https?://dai.ly/.*#i', |
| 11 | 'dailymotion-shorturl' => '#https?://dai\.ly/.*#i', |
12 | 12 | 'flickr' => '#https?://(www\.)?flickr\.com/.*#i', |
13 | 13 | 'flickr-shorturl' => '#https?://flic\.kr/.*#i', |
14 | 14 | 'smugmug' => '#https?://(.+\.)?smugmug\.com/.*#i', |
… |
… |
class Tests_oEmbed extends WP_UnitTestCase { |
16 | 16 | 'photobucket-album' => 'http://i*.photobucket.com/albums/*', |
17 | 17 | 'photobucket-group' => 'http://gi*.photobucket.com/groups/*', |
18 | 18 | 'scribd' => '#https?://(www\.)?scribd\.com/doc/.*#i', |
19 | | 'wordpress-tv' => '#https?://wordpress.tv/.*#i', |
| 19 | 'wordpress-tv' => '#https?://wordpress\.tv/.*#i', |
20 | 20 | 'polldaddy' => '#https?://(.+\.)?polldaddy\.com/.*#i', |
21 | 21 | 'polldaddy-shorturl' => '#https?://poll\.fm/.*#i', |
22 | 22 | 'funnyordie' => '#https?://(www\.)?funnyordie\.com/videos/.*#i', |
23 | 23 | 'twitter' => '#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i', |
24 | 24 | 'twitter-timeline' => '#https?://(www\.)?twitter\.com/.+?/timelines/.*#i', |
25 | 25 | 'twitter-moment' => '#https?://(www\.)?twitter\.com/i/moments/.*#i', |
26 | | 'vine' => '#https?://vine.co/v/.*#i', |
| 26 | 'vine' => '#https?://vine\.co/v/.*#i', |
27 | 27 | 'soundcloud' => '#https?://(www\.)?soundcloud\.com/.*#i', |
28 | 28 | 'slideshare' => '#https?://(.+?\.)?slideshare\.net/.*#i', |
29 | 29 | 'instagram' => '#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i', |
… |
… |
class Tests_oEmbed extends WP_UnitTestCase { |
40 | 40 | 'kickstarter-shorturl' => '#https?://kck\.st/.*#i', |
41 | 41 | 'cloudup' => '#https?://cloudup\.com/.*#i', |
42 | 42 | 'reverbnation' => '#https?://(www\.)?reverbnation\.com/.*#i', |
43 | | 'videopress' => '#https?://videopress.com/v/.*#', |
| 43 | 'videopress' => '#https?://videopress\.com/v/.*#', |
44 | 44 | 'reddit-comments' => '#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i', |
45 | 45 | 'speakerdeck' => '#https?://(www\.)?speakerdeck\.com/.*#i', |
46 | 46 | 'facebook-post' => '#https?://www\.facebook\.com/.*/posts/.*#i', |
… |
… |
class Tests_oEmbed extends WP_UnitTestCase { |
812 | 812 | |
813 | 813 | } |
814 | 814 | |
| 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 | } |
815 | 850 | } |