MediaWiki  REL1_22
ParserOutputTest.php
Go to the documentation of this file.
00001 <?php
00002 
00003 class ParserOutputTest extends MediaWikiTestCase {
00004 
00005     public static function provideIsLinkInternal() {
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 
00035     public function testIsLinkInternal( $shouldMatch, $server, $url ) {
00036         $this->assertEquals( $shouldMatch, ParserOutput::isLinkInternal( $server, $url ) );
00037     }
00038 
00043     public function testExtensionData() {
00044         $po = new ParserOutput();
00045 
00046         $po->setExtensionData( "one", "Foo" );
00047 
00048         $this->assertEquals( "Foo", $po->getExtensionData( "one" ) );
00049         $this->assertNull( $po->getExtensionData( "spam" ) );
00050 
00051         $po->setExtensionData( "two", "Bar" );
00052         $this->assertEquals( "Foo", $po->getExtensionData( "one" ) );
00053         $this->assertEquals( "Bar", $po->getExtensionData( "two" ) );
00054 
00055         $po->setExtensionData( "one", null );
00056         $this->assertNull( $po->getExtensionData( "one" ) );
00057         $this->assertEquals( "Bar", $po->getExtensionData( "two" ) );
00058     }
00059 }