Changeset 38512
- Timestamp:
- 09/02/2016 09:35:51 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/oembed.php
r38454 r38512 4 4 protected static $oembed; 5 5 protected static $provider_map = array( 6 'youtube' => '#https?://((m|www)\.)?youtube\.com/watch.*#i',7 'youtube-playlist' => '#https?://((m|www)\.)?youtube\.com/playlist.*#i',8 'youtube-shorturl' => '#https?://youtu\.be/.*#i',9 'vimeo' => '#https?://(.+\.)?vimeo\.com/.*#i',10 'dailymotion' => '#https?://(www\.)?dailymotion\.com/.*#i',6 'youtube' => '#https?://((m|www)\.)?youtube\.com/watch.*#i', 7 'youtube-playlist' => '#https?://((m|www)\.)?youtube\.com/playlist.*#i', 8 'youtube-shorturl' => '#https?://youtu\.be/.*#i', 9 'vimeo' => '#https?://(.+\.)?vimeo\.com/.*#i', 10 'dailymotion' => '#https?://(www\.)?dailymotion\.com/.*#i', 11 11 'dailymotion-shorturl' => '#https?://dai.ly/.*#i', 12 'flickr' => '#https?://(www\.)?flickr\.com/.*#i',13 'flickr-shorturl' => '#https?://flic\.kr/.*#i',14 'smugmug' => '#https?://(.+\.)?smugmug\.com/.*#i',15 'hulu' => '#https?://(www\.)?hulu\.com/watch/.*#i',16 'photobucket-album' => 'http://i*.photobucket.com/albums/*',17 'photobucket-group' => 'http://gi*.photobucket.com/groups/*',18 'scribd' => '#https?://(www\.)?scribd\.com/doc/.*#i',19 'wordpress-tv' => '#https?://wordpress.tv/.*#i',20 'polldaddy' => '#https?://(.+\.)?polldaddy\.com/.*#i',21 'polldaddy-shorturl' => '#https?://poll\.fm/.*#i',22 'funnyordie' => '#https?://(www\.)?funnyordie\.com/videos/.*#i',23 'twitter' => '#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i',24 'twitter-timeline' => '#https?://(www\.)?twitter\.com/.+?/timelines/.*#i',25 'twitter-moment' => '#https?://(www\.)?twitter\.com/i/moments/.*#i',26 'vine' => '#https?://vine.co/v/.*#i',27 'soundcloud' => '#https?://(www\.)?soundcloud\.com/.*#i',28 'slideshare' => '#https?://(.+?\.)?slideshare\.net/.*#i',29 'instagram' => '#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i',30 'spotify' => '#https?://(open|play)\.spotify\.com/.*#i',31 'imgur' => '#https?://(.+\.)?imgur\.com/.*#i',32 'meetup' => '#https?://(www\.)?meetu(\.ps|p\.com)/.*#i',33 'issuu' => '#https?://(www\.)?issuu\.com/.+/docs/.+#i',34 'collegehumor' => '#https?://(www\.)?collegehumor\.com/video/.*#i',35 'mixcloud' => '#https?://(www\.)?mixcloud\.com/.*#i',36 'ted' => '#https?://(www\.|embed\.)?ted\.com/talks/.*#i',37 'animoto' => '#https?://(www\.)?(animoto|video214)\.com/play/.*#i',38 'tumblr' => '#https?://(.+)\.tumblr\.com/post/.*#i',39 'kickstarter' => '#https?://(www\.)?kickstarter\.com/projects/.*#i',12 'flickr' => '#https?://(www\.)?flickr\.com/.*#i', 13 'flickr-shorturl' => '#https?://flic\.kr/.*#i', 14 'smugmug' => '#https?://(.+\.)?smugmug\.com/.*#i', 15 'hulu' => '#https?://(www\.)?hulu\.com/watch/.*#i', 16 'photobucket-album' => 'http://i*.photobucket.com/albums/*', 17 'photobucket-group' => 'http://gi*.photobucket.com/groups/*', 18 'scribd' => '#https?://(www\.)?scribd\.com/doc/.*#i', 19 'wordpress-tv' => '#https?://wordpress.tv/.*#i', 20 'polldaddy' => '#https?://(.+\.)?polldaddy\.com/.*#i', 21 'polldaddy-shorturl' => '#https?://poll\.fm/.*#i', 22 'funnyordie' => '#https?://(www\.)?funnyordie\.com/videos/.*#i', 23 'twitter' => '#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i', 24 'twitter-timeline' => '#https?://(www\.)?twitter\.com/.+?/timelines/.*#i', 25 'twitter-moment' => '#https?://(www\.)?twitter\.com/i/moments/.*#i', 26 'vine' => '#https?://vine.co/v/.*#i', 27 'soundcloud' => '#https?://(www\.)?soundcloud\.com/.*#i', 28 'slideshare' => '#https?://(.+?\.)?slideshare\.net/.*#i', 29 'instagram' => '#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i', 30 'spotify' => '#https?://(open|play)\.spotify\.com/.*#i', 31 'imgur' => '#https?://(.+\.)?imgur\.com/.*#i', 32 'meetup' => '#https?://(www\.)?meetu(\.ps|p\.com)/.*#i', 33 'issuu' => '#https?://(www\.)?issuu\.com/.+/docs/.+#i', 34 'collegehumor' => '#https?://(www\.)?collegehumor\.com/video/.*#i', 35 'mixcloud' => '#https?://(www\.)?mixcloud\.com/.*#i', 36 'ted' => '#https?://(www\.|embed\.)?ted\.com/talks/.*#i', 37 'animoto' => '#https?://(www\.)?(animoto|video214)\.com/play/.*#i', 38 'tumblr' => '#https?://(.+)\.tumblr\.com/post/.*#i', 39 'kickstarter' => '#https?://(www\.)?kickstarter\.com/projects/.*#i', 40 40 'kickstarter-shorturl' => '#https?://kck\.st/.*#i', 41 'cloudup' => '#https?://cloudup\.com/.*#i', 42 'reverbnation' => '#https?://(www\.)?reverbnation\.com/.*#i', 43 'videopress' => '#https?://videopress.com/v/.*#', 44 'reddit-comments' => '#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i', 45 'speakerdeck' => '#https?://(www\.)?speakerdeck\.com/.*#i', 46 'facebook-post' => '#https?://www\.facebook\.com/.*/posts/.*#i', 47 'facebook-photo' => '#https?://www\.facebook\.com/photo(s/|\.php).*#i', 48 'facebook-permalink' => '#https?://www\.facebook\.com/permalink\.php.*#i', 49 'facebook-media' => '#https?://www\.facebook\.com/media/.*#i', 50 'facebook-notes' => '#https?://www\.facebook\.com/notes/.*#i', 51 'facebook-video' => '#https?://www\.facebook\.com/.*/videos/.*#i', 52 'facebook-videophp' => '#https?://www\.facebook\.com/video\.php.*#i', 53 // I can't find URLs in this format 54 //'facebook-activity' => '#https?://www\.facebook\.com/.*/activity/.*#i', 55 // Questions has been RIP since 2012, URLs (if you can find them) should still work 56 //'facebook-questions' => '#https?://www\.facebook\.com/questions/.*#i', 41 'cloudup' => '#https?://cloudup\.com/.*#i', 42 'reverbnation' => '#https?://(www\.)?reverbnation\.com/.*#i', 43 'videopress' => '#https?://videopress.com/v/.*#', 44 'reddit-comments' => '#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i', 45 'speakerdeck' => '#https?://(www\.)?speakerdeck\.com/.*#i', 46 'facebook-post' => '#https?://www\.facebook\.com/.*/posts/.*#i', 47 'facebook-activity' => '#https?://www\.facebook\.com/.*/activity/.*#i', 48 'facebook-photo' => '#https?://www\.facebook\.com/photo(s/|\.php).*#i', 49 'facebook-permalink' => '#https?://www\.facebook\.com/permalink\.php.*#i', 50 'facebook-media' => '#https?://www\.facebook\.com/media/.*#i', 51 'facebook-questions' => '#https?://www\.facebook\.com/questions/.*#i', 52 'facebook-notes' => '#https?://www\.facebook\.com/notes/.*#i', 53 'facebook-video' => '#https?://www\.facebook\.com/.*/videos/.*#i', 54 'facebook-videophp' => '#https?://www\.facebook\.com/video\.php.*#i', 57 55 ); 58 56 … … 77 75 * @dataProvider oEmbedProviderData 78 76 */ 79 public function testOembedTestURLsResolve( $match, array $urls , $supports_https) {77 public function testOembedTestURLsResolve( $match, array $urls ) { 80 78 81 79 if ( empty( $urls ) ) { … … 109 107 * @dataProvider oEmbedProviderData 110 108 */ 111 public function testOembedProviderReturnsExpectedResponse( $match, array $urls , $supports_https) {109 public function testOembedProviderReturnsExpectedResponse( $match, array $urls ) { 112 110 113 111 if ( empty( $urls ) ) { … … 121 119 'height' => 500, 122 120 ); 123 $test_urls = $urls; 124 125 if ( $supports_https ) { 126 foreach ( $urls as $url ) { 121 $supports_https = ( 0 === strpos( $match, '#https?' ) ); 122 123 foreach ( $urls as $url ) { 124 $test_urls[] = set_url_scheme( $url, 'http' ); 125 if ( $supports_https ) { 127 126 $test_urls[] = set_url_scheme( $url, 'https' ); 128 127 } … … 320 319 * @dataProvider oEmbedProviderData 321 320 */ 322 public function testOembedProviderHandlesInvalidData( $match, array $urls , $supports_https) {321 public function testOembedProviderHandlesInvalidData( $match, array $urls ) { 323 322 324 323 if ( empty( $urls ) ) { … … 416 415 417 416 $tests = wp_list_pluck( $this->oEmbedProviderData(), 0 ); 418 $providers = array_ values( self::$provider_map);417 $providers = array_keys( self::$oembed->providers ); 419 418 $missing = array_diff( $providers, $tests ); 420 419 … … 437 436 438 437 $this->assertEmpty( $useless, sprintf( "These tests do not cover any oEmbed provider:\n- %s", implode( "\n- ", $useless ) ) ); 438 439 } 440 441 /** 442 * Test the tests 443 * 444 * @group oembed 445 * @ticket 32360 446 * 447 */ 448 public function testOembedTestProvidersMatchActualProviders() { 449 450 $providers = array_keys( self::$oembed->providers ); 451 $provider_map = array_values( self::$provider_map ); 452 453 $this->assertEquals( $providers, $provider_map ); 439 454 440 455 } … … 449 464 450 465 return array( 451 // YouTube without www452 466 array( 453 467 $providers['youtube'], … … 455 469 'http://youtube.com/watch?v=zdtD19tXX30', 456 470 'http://m.youtube.com/watch?v=QkP_rOCBrpY', 457 ), 458 false, // HTTPS handled by different endpoints 459 ), 460 // YouTube with www 461 array( 462 $providers['youtube'], 463 array( 464 'https://www.youtube.com/watch?v=bDRQRdFaFEo', 465 'https://m.youtube.com/watch?v=yfUflij74P4', 466 ), 467 false, // HTTPS handled by different endpoints 468 ), 469 // YouTube Playlist without www 471 'http://www.youtube.com/watch?v=bDRQRdFaFEo', 472 ), 473 ), 470 474 array( 471 475 $providers['youtube-playlist'], 472 476 array( 473 'https://youtube.com/playlist?list=PL93B9F6B77FBB0160', 474 'https://m.youtube.com/playlist?list=PL1AC02C68F976A10F', 475 ), 476 false, // HTTPS handled by different endpoints 477 ), 478 // YouTube Playlist with www 479 array( 480 $providers['youtube-playlist'], 481 array( 477 'http://youtube.com/playlist?list=PL93B9F6B77FBB0160', 478 'http://m.youtube.com/playlist?list=PL1AC02C68F976A10F', 482 479 'http://www.youtube.com/playlist?list=PLC7D2959C96B8D27B', 483 'http://m.youtube.com/playlist?list=PLEC422D53B7588DC7', 484 ), 485 false, // HTTPS handled by different endpoints 486 ), 487 // YouTube HTTP Short Url 480 ), 481 ), 488 482 array( 489 483 $providers['youtube-shorturl'], 490 484 array( 491 485 'http://youtu.be/nfWlot6h_JM?list=PLirAqAtl_h2r5g8xGajEwdXd3x1sZh8hC', 492 ), 493 false, // HTTPS handled by different endpoints 494 ), 495 // YouTube HTTPS Short Url 496 array( 497 $providers['youtube-shorturl'], 498 array( 499 'https://youtu.be/U8SYRUYfs_I', 500 ), 501 false, // HTTPS handled by different endpoints 486 'http://youtu.be/U8SYRUYfs_I', 487 ), 502 488 ), 503 489 array( … … 506 492 'http://vimeo.com/12339198', 507 493 ), 508 true,509 494 ), 510 495 array( … … 513 498 'http://www.dailymotion.com/video/x27bwvb_how-to-wake-up-better_news', 514 499 ), 515 true,516 500 ), 517 501 array( … … 520 504 'http://dai.ly/x33exze', 521 505 ), 522 false, // No HTTPS support523 506 ), 524 507 array( … … 527 510 'http://www.flickr.com/photos/bon/14004280667/', 528 511 ), 529 true,530 512 ), 531 513 array( … … 534 516 'http://flic.kr/p/6BFrbQ', 535 517 ), 536 true,537 518 ), 538 519 array( … … 541 522 'http://fotoeffects.smugmug.com/Daily-shots-for-the-dailies/Dailies/6928550_9gMRmv/476011624_WhGWpts#!i=476011624&k=WhGWpts', 542 523 ), 543 true,544 524 ), 545 525 array( … … 548 528 'http://www.hulu.com/watch/807443', 549 529 ), 550 true,551 530 ), 552 531 array( … … 555 534 'http://i415.photobucket.com/albums/pp236/Keefers_/Keffers%20Animals/funny-cats-a10.jpg', 556 535 ), 557 false, // No HTTPS support558 536 ), 559 537 array( … … 562 540 // ?? 563 541 ), 564 false, // No HTTPS support565 542 ), 566 543 array( … … 569 546 'http://www.scribd.com/doc/110799637/Synthesis-of-Knowledge-Effects-of-Fire-and-Thinning-Treatments-on-Understory-Vegetation-in-Dry-U-S-Forests', 570 547 ), 571 true,572 548 ), 573 549 array( … … 576 552 'http://wordpress.tv/2015/08/18/billie/', 577 553 ), 578 true,579 554 ), 580 555 array( … … 583 558 'http://polldaddy.com/poll/9066794/', 584 559 ), 585 true,586 560 ), 587 561 array( … … 590 564 'http://poll.fm/5ebze', 591 565 ), 592 false, // No HTTPS support593 566 ), 594 567 array( … … 597 570 'http://www.funnyordie.com/videos/e5ef40bf2a/cute-overload', 598 571 ), 599 true,600 572 ), 601 573 array( … … 604 576 'http://twitter.com/WordPress/status/633718182335922177', 605 577 ), 606 true,607 578 ), 608 579 array( … … 611 582 'https://twitter.com/wordpress', 612 583 ), 613 true,614 584 ), 615 585 array( … … 618 588 'https://twitter.com/i/moments/770661957397573633', 619 589 ), 620 true,621 590 ), 622 591 array( … … 625 594 'https://www.reddit.com/r/Wordpress/comments/3xerq8/list_of_useful_wordpress_functions/' 626 595 ), 627 true,628 596 ), 629 597 array( … … 632 600 'http://vine.co/v/OjiLun5LuQ6', 633 601 ), 634 true,635 602 ), 636 603 array( … … 639 606 'http://soundcloud.com/steveaoki/kid-cudi-pursuit-of-happiness', 640 607 ), 641 true,642 608 ), 643 609 array( … … 646 612 'http://www.slideshare.net/haraldf/business-quotes-for-2011', 647 613 ), 648 true,649 614 ), 650 615 array( … … 652 617 array( 653 618 'http://instagram.com/p/68WqXbTcfl/', 654 'https://instagram.com/p/68WqXbTcfl/',655 619 'http://instagr.am/p/MRM3HQy6kh/', 656 620 ), 657 false, // No HTTPS support on instagr.am658 621 ), 659 622 array( … … 662 625 'http://open.spotify.com/track/2i1KmyEXN3pNLwdxAWSGcg', 663 626 ), 664 true,665 627 ), 666 628 array( … … 670 632 'http://i.imgur.com/mbOPX2L.png', 671 633 ), 672 true,673 634 ), 674 635 array( … … 678 639 'http://meetu.ps/2L533w', 679 640 ), 680 true,681 641 ), 682 642 array( … … 685 645 'http://issuu.com/vmagazine/docs/v87', 686 646 ), 687 true,688 647 ), 689 648 array( … … 692 651 'http://www.collegehumor.com/video/2862877/jake-and-amir-math', 693 652 ), 694 true,695 653 ), 696 654 array( … … 699 657 'http://www.mixcloud.com/8_8s/disclosurefriends/', 700 658 ), 701 true,702 659 ), 703 660 array( … … 706 663 'http://www.ted.com/talks/rodney_mullen_pop_an_ollie_and_innovate', 707 664 ), 708 true,709 665 ), 710 666 array( … … 714 670 'http://video214.com/play/MlRRgXHhoT8gOZyHanM6TA', 715 671 ), 716 true,717 672 ), 718 673 array( … … 721 676 'http://yahoo.tumblr.com/post/50902111638/tumblr-yahoo', 722 677 ), 723 false, // No HTTPS support724 678 ), 725 679 array( … … 728 682 'http://www.kickstarter.com/projects/zackdangerbrown/potato-salad', 729 683 ), 730 true,731 684 ), 732 685 array( … … 735 688 'http://kck.st/1ukxHcx', 736 689 ), 737 false, // No HTTPS support738 690 ), 739 691 array( … … 742 694 'http://cloudup.com/cWX2Bi5DmfJ', 743 695 ), 744 true,745 696 ), 746 697 array( … … 750 701 'http://www.reverbnation.com/enemyplanes', 751 702 ), 752 true,753 703 ), 754 704 array( … … 757 707 'https://videopress.com/v/kUJmAcSf', 758 708 ), 759 true,760 709 ), 761 710 array( … … 764 713 'https://speakerdeck.com/tollmanz/scaling-wordpress' 765 714 ), 766 true767 715 ), 768 716 array( … … 771 719 'https://www.facebook.com/WordPress/posts/10154220015487911' 772 720 ), 773 true 774 ), 775 // array( 776 // $providers['facebook-activity'], 777 // array( 778 // '' 779 // ), 780 // true 781 // ), 721 ), 722 array( 723 $providers['facebook-activity'], 724 array( 725 // ?? 726 ), 727 ), 782 728 array( 783 729 $providers['facebook-photo'], … … 785 731 'https://www.facebook.com/WordPress/photos/a.111006762910.97747.6427302910/10153207719422911/' 786 732 ), 787 true788 733 ), 789 734 array( … … 792 737 'https://www.facebook.com/permalink.php?story_fbid=10154220015487911' 793 738 ), 794 true795 739 ), 796 740 array( … … 799 743 'https://www.facebook.com/media/set/?set=a.164630483698579.1073741878.150601778434783&type=1&l=6c3a7725d5' 800 744 ), 801 true 802 ), 803 // array( 804 // $providers['facebook-questions'], 805 // array( 806 // '' 807 // ), 808 // true 809 // ), 745 ), 746 array( 747 $providers['facebook-questions'], 748 array( 749 // ?? 750 ), 751 ), 810 752 array( 811 753 $providers['facebook-notes'], … … 813 755 'https://www.facebook.com/notes/facebook/searching-for-answers-ask-facebook-questions/411795942130/' 814 756 ), 815 true816 757 ), 817 758 array( … … 820 761 'https://www.facebook.com/WordPress/videos/317622575398/' 821 762 ), 822 true823 763 ), 824 764 array( … … 828 768 'https://www.facebook.com/video.php?id=317622575398', 829 769 ), 830 true831 770 ), 832 771 );
Note: See TracChangeset
for help on using the changeset viewer.