MediaWiki
master
|
00001 <?php 00002 00003 class ParserOutputTest extends MediaWikiTestCase { 00004 00005 function dataIsLinkInternal() { 00006 return array( 00007 // Different domains 00008 array( false, 'http://example.org', 'http://mediawiki.org' ), 00009 // Same domains 00010 array( true, 'http://example.org', 'http://example.org' ), 00011 array( true, 'https://example.org', 'https://example.org' ), 00012 array( true, '//example.org', '//example.org' ), 00013 // Same domain different cases 00014 array( true, 'http://example.org', 'http://EXAMPLE.ORG' ), 00015 // Paths, queries, and fragments are not relevant 00016 array( true, 'http://example.org', 'http://example.org/wiki/Main_Page' ), 00017 array( true, 'http://example.org', 'http://example.org?my=query' ), 00018 array( true, 'http://example.org', 'http://example.org#its-a-fragment' ), 00019 // Different protocols 00020 array( false, 'http://example.org', 'https://example.org' ), 00021 array( false, 'https://example.org', 'http://example.org' ), 00022 // Protocol relative servers always match http and https links 00023 array( true, '//example.org', 'http://example.org' ), 00024 array( true, '//example.org', 'https://example.org' ), 00025 // But they don't match strange things like this 00026 array( false, '//example.org', 'irc://example.org' ), 00027 ); 00028 } 00029 00034 function testIsLinkInternal( $shouldMatch, $server, $url ) { 00035 00036 $this->assertEquals( $shouldMatch, ParserOutput::isLinkInternal( $server, $url ) ); 00037 } 00038 }