test: coverage recording now needs to be explicit
[mediawiki.git] / tests / phpunit / includes / parser / ParserOutputTest.php
blob68f77ab53791e3bbd1df9350fb81ed67a9be0a8b
1 <?php
3 class ParserOutputTest extends MediaWikiTestCase {
5 function dataIsLinkInternal() {
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' ),
30 /**
31 * Test to make sure ParserOutput::isLinkInternal behaves properly
32 * @dataProvider dataIsLinkInternal
34 function testIsLinkInternal( $shouldMatch, $server, $url ) {
36 $this->assertEquals( $shouldMatch, ParserOutput::isLinkInternal( $server, $url ) );
39 public function testExtensionData() {
40 $po = new ParserOutput();
42 $po->setExtensionData( "one", "Foo" );
44 $this->assertEquals( "Foo", $po->getExtensionData( "one" ) );
45 $this->assertNull( $po->getExtensionData( "spam" ) );
47 $po->setExtensionData( "two", "Bar" );
48 $this->assertEquals( "Foo", $po->getExtensionData( "one" ) );
49 $this->assertEquals( "Bar", $po->getExtensionData( "two" ) );
51 $po->setExtensionData( "one", null );
52 $this->assertNull( $po->getExtensionData( "one" ) );
53 $this->assertEquals( "Bar", $po->getExtensionData( "two" ) );