MediaWiki  1.23.0
ParserOutputTest.php
Go to the documentation of this file.
1 <?php
2 
4 
5  public static function provideIsLinkInternal() {
6  return array(
7  // Different domains
8  array( false, 'http://example.org', 'http://mediawiki.org' ),
9  // Same domains
10  array( true, 'http://example.org', 'http://example.org' ),
11  array( true, 'https://example.org', 'https://example.org' ),
12  array( true, '//example.org', '//example.org' ),
13  // Same domain different cases
14  array( true, 'http://example.org', 'http://EXAMPLE.ORG' ),
15  // Paths, queries, and fragments are not relevant
16  array( true, 'http://example.org', 'http://example.org/wiki/Main_Page' ),
17  array( true, 'http://example.org', 'http://example.org?my=query' ),
18  array( true, 'http://example.org', 'http://example.org#its-a-fragment' ),
19  // Different protocols
20  array( false, 'http://example.org', 'https://example.org' ),
21  array( false, 'https://example.org', 'http://example.org' ),
22  // Protocol relative servers always match http and https links
23  array( true, '//example.org', 'http://example.org' ),
24  array( true, '//example.org', 'https://example.org' ),
25  // But they don't match strange things like this
26  array( false, '//example.org', 'irc://example.org' ),
27  );
28  }
29 
35  public function testIsLinkInternal( $shouldMatch, $server, $url ) {
36  $this->assertEquals( $shouldMatch, ParserOutput::isLinkInternal( $server, $url ) );
37  }
38 
43  public function testExtensionData() {
44  $po = new ParserOutput();
45 
46  $po->setExtensionData( "one", "Foo" );
47 
48  $this->assertEquals( "Foo", $po->getExtensionData( "one" ) );
49  $this->assertNull( $po->getExtensionData( "spam" ) );
50 
51  $po->setExtensionData( "two", "Bar" );
52  $this->assertEquals( "Foo", $po->getExtensionData( "one" ) );
53  $this->assertEquals( "Bar", $po->getExtensionData( "two" ) );
54 
55  $po->setExtensionData( "one", null );
56  $this->assertNull( $po->getExtensionData( "one" ) );
57  $this->assertEquals( "Bar", $po->getExtensionData( "two" ) );
58  }
59 }
ParserOutput
Definition: ParserOutput.php:24
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
ParserOutput\isLinkInternal
static isLinkInternal( $internal, $url)
Checks, if a url is pointing to the own server.
Definition: ParserOutput.php:188
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
ParserOutputTest
Definition: ParserOutputTest.php:3
ParserOutputTest\provideIsLinkInternal
static provideIsLinkInternal()
Definition: ParserOutputTest.php:5
ParserOutputTest\testIsLinkInternal
testIsLinkInternal( $shouldMatch, $server, $url)
Test to make sure ParserOutput::isLinkInternal behaves properly @dataProvider provideIsLinkInternal @...
Definition: ParserOutputTest.php:35
ParserOutputTest\testExtensionData
testExtensionData()
@covers ParserOutput::setExtensionData @covers ParserOutput::getExtensionData
Definition: ParserOutputTest.php:43